From c186fc42929b2660e5c507adeb8a8fb406593b11 Mon Sep 17 00:00:00 2001 From: jvoisin Date: Sun, 1 Apr 2018 00:17:06 +0200 Subject: Clean deep metadata for zip files --- tests/test_libmat2.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'tests/test_libmat2.py') diff --git a/tests/test_libmat2.py b/tests/test_libmat2.py index c065237..888c782 100644 --- a/tests/test_libmat2.py +++ b/tests/test_libmat2.py @@ -57,7 +57,7 @@ class TestGetMeta(unittest.TestCase): class TestDeepCleaning(unittest.TestCase): - def __check_zip_clean(self, p): + def __check_deep_meta(self, p): tempdir = tempfile.mkdtemp() zipin = zipfile.ZipFile(p.filename) zipin.extractall(tempdir) @@ -72,6 +72,15 @@ class TestDeepCleaning(unittest.TestCase): self.assertEqual(inside_p.get_meta(), {}) shutil.rmtree(tempdir) + + def __check_zip_meta(self, p): + zipin = zipfile.ZipFile(p.filename) + for item in zipin.infolist(): + self.assertEqual(item.comment, b'') + self.assertEqual(item.date_time, (1980, 1, 1, 0, 0, 0)) + self.assertEqual(item.create_system, 3) # 3 is UNIX + + def test_office(self): shutil.copy('./tests/data/dirty.docx', './tests/data/clean.docx') p = office.OfficeParser('./tests/data/clean.docx') @@ -85,7 +94,8 @@ class TestDeepCleaning(unittest.TestCase): p = office.OfficeParser('./tests/data/clean.docx.cleaned') self.assertEqual(p.get_meta(), {}) - self.__check_zip_clean(p) + self.__check_zip_meta(p) + self.__check_deep_meta(p) os.remove('./tests/data/clean.docx') @@ -103,7 +113,8 @@ class TestDeepCleaning(unittest.TestCase): p = libreoffice.LibreOfficeParser('./tests/data/clean.odt.cleaned') self.assertEqual(p.get_meta(), {}) - self.__check_zip_clean(p) + self.__check_zip_meta(p) + self.__check_deep_meta(p) os.remove('./tests/data/clean.odt') -- cgit v1.3