1
0
Fork 0
mirror of synced 2025-07-03 20:07:28 +02:00

Improve the reliability of the office parser

This commit is contained in:
jvoisin 2018-06-21 23:18:50 +02:00
parent 846a261465
commit 5b38bd7ccd
2 changed files with 12 additions and 0 deletions

View file

@ -16,6 +16,13 @@ class ArchiveBasedAbstractParser(abstract.AbstractParser):
files_to_keep = set() # type: Set[str]
files_to_omit = set() # type: Set[Pattern]
def __init__(self, filename):
super().__init__(filename)
try: # better fail here than later
zipfile.ZipFile(self.filename)
except zipfile.BadZipFile:
raise ValueError
def _clean_zipinfo(self, zipinfo: zipfile.ZipInfo) -> zipfile.ZipInfo:
zipinfo.create_system = 3 # Linux
zipinfo.comment = b''