summaryrefslogtreecommitdiff
path: root/src/libreoffice.py
diff options
context:
space:
mode:
authorjvoisin2018-04-01 00:17:06 +0200
committerjvoisin2018-04-01 00:17:06 +0200
commitc186fc42929b2660e5c507adeb8a8fb406593b11 (patch)
treec82d071d61ceec3a20d48961390e73f6139f2136 /src/libreoffice.py
parent6d506b87575ded3a59c9fc4f7b28d4160d9e9c43 (diff)
Clean deep metadata for zip files
Diffstat (limited to 'src/libreoffice.py')
-rw-r--r--src/libreoffice.py12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/libreoffice.py b/src/libreoffice.py
index a3481a1..809ae3c 100644
--- a/src/libreoffice.py
+++ b/src/libreoffice.py
@@ -34,6 +34,13 @@ class LibreOfficeParser(abstract.AbstractParser):
34 zipin.close() 34 zipin.close()
35 return metadata 35 return metadata
36 36
37 def __clean_zipinfo(self, zipinfo:zipfile.ZipInfo) -> zipfile.ZipInfo:
38 zipinfo.compress_type = zipfile.ZIP_DEFLATED
39 zipinfo.create_system = 3 # Linux
40 zipinfo.comment = b''
41 zipinfo.date_time = (1980, 1, 1, 0, 0, 0)
42 return zipinfo
43
37 def remove_all(self): 44 def remove_all(self):
38 zin = zipfile.ZipFile(self.filename, 'r') 45 zin = zipfile.ZipFile(self.filename, 'r')
39 zout = zipfile.ZipFile(self.output_filename, 'w') 46 zout = zipfile.ZipFile(self.output_filename, 'w')
@@ -51,7 +58,10 @@ class LibreOfficeParser(abstract.AbstractParser):
51 print("%s isn't supported" % item.filename) 58 print("%s isn't supported" % item.filename)
52 continue 59 continue
53 tmp_parser.remove_all() 60 tmp_parser.remove_all()
54 zout.write(tmp_parser.output_filename, item.filename) 61 zinfo = zipfile.ZipInfo(item.filename)
62 item = self.__clean_zipinfo(item)
63 with open(tmp_parser.output_filename, 'rb') as f:
64 zout.writestr(zinfo, f.read())
55 shutil.rmtree(temp_folder) 65 shutil.rmtree(temp_folder)
56 zout.close() 66 zout.close()
57 zin.close() 67 zin.close()