diff options
| -rw-r--r-- | libmat2/office.py | 1 | ||||
| -rw-r--r-- | tests/data/revision.odt | bin | 0 -> 14458 bytes | |||
| -rw-r--r-- | tests/test_libmat2.py | 17 |
3 files changed, 18 insertions, 0 deletions
diff --git a/libmat2/office.py b/libmat2/office.py index e813fae..34ae7a2 100644 --- a/libmat2/office.py +++ b/libmat2/office.py | |||
| @@ -146,6 +146,7 @@ class LibreOfficeParser(ArchiveBasedAbstractParser): | |||
| 146 | files_to_omit = set(map(re.compile, { # type: ignore | 146 | files_to_omit = set(map(re.compile, { # type: ignore |
| 147 | '^meta\.xml$', | 147 | '^meta\.xml$', |
| 148 | '^Configurations2/', | 148 | '^Configurations2/', |
| 149 | '^Thumbnails/', | ||
| 149 | })) | 150 | })) |
| 150 | 151 | ||
| 151 | def get_meta(self) -> Dict[str, str]: | 152 | def get_meta(self) -> Dict[str, str]: |
diff --git a/tests/data/revision.odt b/tests/data/revision.odt new file mode 100644 index 0000000..d3b209b --- /dev/null +++ b/tests/data/revision.odt | |||
| Binary files differ | |||
diff --git a/tests/test_libmat2.py b/tests/test_libmat2.py index b34e7a4..3ea044f 100644 --- a/tests/test_libmat2.py +++ b/tests/test_libmat2.py | |||
| @@ -105,6 +105,23 @@ class TestGetMeta(unittest.TestCase): | |||
| 105 | self.assertEqual(meta['meta:generator'], 'LibreOffice/3.3$Unix LibreOffice_project/330m19$Build-202') | 105 | self.assertEqual(meta['meta:generator'], 'LibreOffice/3.3$Unix LibreOffice_project/330m19$Build-202') |
| 106 | 106 | ||
| 107 | 107 | ||
| 108 | class TestRemovingThumbnails(unittest.TestCase): | ||
| 109 | def test_odt(self): | ||
| 110 | shutil.copy('./tests/data/revision.odt', './tests/data/clean.odt') | ||
| 111 | |||
| 112 | zipin = zipfile.ZipFile(os.path.abspath('./tests/data/clean.odt')) | ||
| 113 | self.assertIn('Thumbnails/thumbnail.png', zipin.namelist()) | ||
| 114 | zipin.close() | ||
| 115 | |||
| 116 | p = office.LibreOfficeParser('./tests/data/clean.odt') | ||
| 117 | self.assertTrue(p.remove_all()) | ||
| 118 | |||
| 119 | zipin = zipfile.ZipFile(os.path.abspath('./tests/data/clean.cleaned.odt')) | ||
| 120 | self.assertNotIn('Thumbnails/thumbnail.png', zipin.namelist()) | ||
| 121 | zipin.close() | ||
| 122 | |||
| 123 | os.remove('./tests/data/clean.cleaned.odt') | ||
| 124 | |||
| 108 | class TestDeepCleaning(unittest.TestCase): | 125 | class TestDeepCleaning(unittest.TestCase): |
| 109 | def __check_deep_meta(self, p): | 126 | def __check_deep_meta(self, p): |
| 110 | tempdir = tempfile.mkdtemp() | 127 | tempdir = tempfile.mkdtemp() |
