[Pkg-privacy-commits] [Git][pkg-privacy-team/mat2][upstream] New upstream version 0.12.2

Georg Faerber (@georg) georg at debian.org
Sun Aug 29 13:41:00 BST 2021



Georg Faerber pushed to branch upstream at Privacy Maintainers / mat2


Commits:
8edc8161 by Georg Faerber at 2021-08-29T11:55:37+00:00
New upstream version 0.12.2
- - - - -


13 changed files:

- .gitlab-ci.yml
- CHANGELOG.md
- doc/mat2.1
- dolphin/mat2.desktop
- libmat2/audio.py
- libmat2/images.py
- libmat2/office.py
- libmat2/pdf.py
- mat2
- nautilus/mat2.py
- setup.py
- + tests/data/dirty.aiff
- tests/test_libmat2.py


Changes:

=====================================
.gitlab-ci.yml
=====================================
@@ -63,6 +63,7 @@ tests:debian:
 tests:debian_with_bubblewrap:
   image: $CONTAINER_REGISTRY:debian
   stage: test
+  allow_failure: true
   <<: *prepare_env
   script:
     - su - mat2 -c "python3-coverage run --branch -m unittest discover -s tests/"


=====================================
CHANGELOG.md
=====================================
@@ -1,3 +1,10 @@
+# 0.12.2 - 2021-08-29
+
+- Add support for aiff files
+- Improve MS Office support
+- Improve compatibility with newer/older version of mat2's dependencies
+- Fix possible issues with the resolution of processed pdf
+
 # 0.12.1 - 2021-03-19
 
 - Improve epub support


=====================================
doc/mat2.1
=====================================
@@ -1,4 +1,4 @@
-.TH mat2 "1" "March 2021" "mat2 0.12.1" "User Commands"
+.TH mat2 "1" "August 2021" "mat2 0.12.2" "User Commands"
 
 .SH NAME
 mat2 \- the metadata anonymisation toolkit 2


=====================================
dolphin/mat2.desktop
=====================================
@@ -6,6 +6,8 @@ Type=Service
 
 [Desktop Action cleanMetadata]
 Name=Clean metadata
+Name[de]=Metadaten löschen
 Name[es]=Limpiar metadatos
 Icon=/usr/share/icons/hicolor/scalable/apps/mat2.svg
 Exec=kdialog --yesno  "$( mat2 -s %U )" --title "Clean Metadata?" && mat2 %U
+Exec[de]=kdialog --yesno  "$( mat2 -s %U )" --title "Metadaten löschen?" && mat2 %U


=====================================
libmat2/audio.py
=====================================
@@ -90,3 +90,14 @@ class WAVParser(video.AbstractFFmpegParser):
                       'FileSize', 'FileType', 'FileTypeExtension',
                       'MIMEType', 'NumChannels', 'SampleRate', 'SourceFile',
                      }
+
+class AIFFParser(video.AbstractFFmpegParser):
+    mimetypes = {'audio/aiff', 'audio/x-aiff'}
+    meta_allowlist = {'AvgBytesPerSec', 'BitsPerSample', 'Directory',
+                      'Duration', 'Encoding', 'ExifToolVersion',
+                      'FileAccessDate', 'FileInodeChangeDate',
+                      'FileModifyDate', 'FileName', 'FilePermissions',
+                      'FileSize', 'FileType', 'FileTypeExtension',
+                      'MIMEType', 'NumChannels', 'SampleRate', 'SourceFile',
+                      'NumSampleFrames', 'SampleSize',
+                     }


=====================================
libmat2/images.py
=====================================
@@ -63,7 +63,7 @@ class PNGParser(exiftool.ExiftoolParser):
 
         try:  # better fail here than later
             cairo.ImageSurface.create_from_png(self.filename)
-        except Exception:  # pragma: no cover
+        except:  # pragma: no cover
             # Cairo is returning some weird exceptions :/
             raise ValueError
 


=====================================
libmat2/office.py
=====================================
@@ -88,6 +88,7 @@ class MSOfficeParser(ZipParser):
             r'^\[Content_Types\]\.xml$',
             r'^_rels/\.rels$',
             r'^xl/sharedStrings\.xml$',  # https://docs.microsoft.com/en-us/office/open-xml/working-with-the-shared-string-table
+            r'^xl/calcChain\.xml$',
             r'^(?:word|ppt|xl)/_rels/document\.xml\.rels$',
             r'^(?:word|ppt|xl)/_rels/footer[0-9]*\.xml\.rels$',
             r'^(?:word|ppt|xl)/_rels/header[0-9]*\.xml\.rels$',
@@ -107,6 +108,9 @@ class MSOfficeParser(ZipParser):
             # TODO: check if p:bgRef can be randomized
             r'^ppt/slideMasters/slideMaster[0-9]+\.xml',
             r'^ppt/slideMasters/_rels/slideMaster[0-9]+\.xml\.rels',
+            r'^xl/worksheets/_rels/sheet[0-9]+\.xml\.rels',
+            r'^xl/drawings/vmlDrawing[0-9]+\.vml',
+            r'^xl/drawings/drawing[0-9]+\.xml',
         }))
         self.files_to_omit = set(map(re.compile, {  # type: ignore
             r'^\[trash\]/',
@@ -123,6 +127,7 @@ class MSOfficeParser(ZipParser):
             # Additional presentation-wide properties like printing properties,
             # presentation show properties etc.
             r'^(?:word|ppt|xl)/presProps\.xml$',
+            r'^(?:word|ppt|xl)/comments[0-9]+\.xml$',
 
             # we have an allowlist in self.files_to_keep,
             # so we can trash everything else


=====================================
libmat2/pdf.py
=====================================
@@ -32,7 +32,7 @@ class PDFParser(abstract.AbstractParser):
     def __init__(self, filename):
         super().__init__(filename)
         self.uri = 'file://' + os.path.abspath(self.filename)
-        self.__scale = 2  # how much precision do we want for the render
+        self.__scale = 200 / 72.0  # how much precision do we want for the render
         try:  # Check now that the file is valid, to avoid surprises later
             Poppler.Document.new_from_file(self.uri, None)
         except GLib.GError:  # Invalid PDF
@@ -90,8 +90,8 @@ class PDFParser(abstract.AbstractParser):
             page_width, page_height = page.get_size()
             logging.info("Rendering page %d/%d", pagenum + 1, pages_count)
 
-            width = int(page_width) * self.__scale
-            height = int(page_height) * self.__scale
+            width = int(page_width * self.__scale)
+            height = int(page_height * self.__scale)
             img_surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, width, height)
             img_context = cairo.Context(img_surface)
 
@@ -105,7 +105,11 @@ class PDFParser(abstract.AbstractParser):
             buf.seek(0)
 
             img = cairo.ImageSurface.create_from_png(buf)
-            pdf_surface.set_size(page_width*self.__scale, page_height*self.__scale)
+            if cairo.version_info < (1, 12, 0):
+                pdf_surface.set_size(width, height)
+            else:
+                pdf_surface.set_size(page_width, page_height)
+                pdf_surface.set_device_scale(1 / self.__scale, 1 / self.__scale)
             pdf_context.set_source_surface(img, 0, 0)
             pdf_context.paint()
             pdf_context.show_page()  # draw pdf_context on pdf_surface


=====================================
mat2
=====================================
@@ -17,7 +17,7 @@ except ValueError as e:
     print(e)
     sys.exit(1)
 
-__version__ = '0.12.1'
+__version__ = '0.12.2'
 
 # Make pyflakes happy
 assert Set


=====================================
nautilus/mat2.py
=====================================
@@ -231,7 +231,7 @@ class Mat2Extension(GObject.GObject, Nautilus.MenuProvider, Nautilus.LocationWid
         """
         # Do not show the menu item if not a single file has a chance to be
         # processed by mat2.
-        if not any([is_valid for (is_valid, _) in map(self.__validate, files)]):
+        if not any((is_valid for (is_valid, _) in map(self.__validate, files))):
             return None
 
         item = Nautilus.MenuItem(


=====================================
setup.py
=====================================
@@ -5,7 +5,7 @@ with open("README.md", encoding='utf-8') as fh:
 
 setuptools.setup(
     name="mat2",
-    version='0.12.1',
+    version='0.12.2',
     author="Julien (jvoisin) Voisin",
     author_email="julien.voisin+mat2 at dustri.org",
     description="A handy tool to trash your metadata",


=====================================
tests/data/dirty.aiff
=====================================
Binary files /dev/null and b/tests/data/dirty.aiff differ


=====================================
tests/test_libmat2.py
=====================================
@@ -230,6 +230,11 @@ class TestGetMeta(unittest.TestCase):
         p = images.SVGParser('./tests/data/weird.svg')
         self.assertEqual(p.get_meta()['Xmlns'], 'http://www.w3.org/1337/svg')
 
+    def test_aiff(self):
+        p = audio.AIFFParser('./tests/data/dirty.aiff')
+        meta = p.get_meta()
+        self.assertEqual(meta['Name'], 'I am so')
+
 
 class TestRemovingThumbnails(unittest.TestCase):
     def test_odt(self):
@@ -312,6 +317,12 @@ class TestCleaning(unittest.TestCase):
             'meta': {'Comment': 'Zomg, a comment!'},
             'expected_meta': {},
         }, {
+            'name': 'aiff',
+            'parser': audio.AIFFParser,
+            'meta': {'Annotation': 'Thank you for using MAT !'},
+            'expected_meta': {},
+        },
+        {
             'name': 'mp3',
             'parser': audio.MP3Parser,
             'meta': {'TXXX:I am a': 'various comment'},
@@ -442,13 +453,17 @@ class TestCleaning(unittest.TestCase):
                 'Encoder':  'HandBrake 0.9.4 2009112300',
             },
             'expected_meta': {
+                'AverageBitrate': 465641,
+                'BufferSize': 0,
                 'CompatibleBrands': ['isom', 'iso2', 'avc1', 'mp41'],
+                'ColorRepresentation': 'nclx 1 1 1',
                 'CompressorID': 'avc1',
                 'GraphicsMode': 'srcCopy',
                 'HandlerDescription': 'SoundHandler',
                 'HandlerType': 'Metadata',
                 'HandlerVendorID': 'Apple',
-                'MajorBrand': 'MP4  Base Media v1 [IS0 14496-12:2003]',
+                'MajorBrand': 'Base Media v1 [IS0 14496-12:2003]',
+                'MaxBitrate': 465641,
                 'MediaDataOffset': 48,
                 'MediaDataSize': 379872,
                 'MediaHeaderVersion': 0,
@@ -502,7 +517,7 @@ class TestCleaning(unittest.TestCase):
             p2 = case['parser'](p1.output_filename)
             for k, v in p2.get_meta().items():
                 self.assertIn(k, case['expected_meta'])
-                self.assertEqual(v, case['expected_meta'][k])
+                self.assertIn(str(case['expected_meta'][k]), str(v))
             self.assertTrue(p2.remove_all())
 
             os.remove(target)



View it on GitLab: https://salsa.debian.org/pkg-privacy-team/mat2/-/commit/8edc8161dc49a0b92e329e0e9d5fa2a4121dc853

-- 
View it on GitLab: https://salsa.debian.org/pkg-privacy-team/mat2/-/commit/8edc8161dc49a0b92e329e0e9d5fa2a4121dc853
You're receiving this email because of your account on salsa.debian.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-privacy-commits/attachments/20210829/736c54f7/attachment-0001.htm>


More information about the Pkg-privacy-commits mailing list