diff options
| author | jvoisin | 2018-06-21 23:18:50 +0200 |
|---|---|---|
| committer | jvoisin | 2018-06-21 23:18:59 +0200 |
| commit | 5b38bd7ccd97cdca864351b4af0fcbaa227f509e (patch) | |
| tree | 503037b7e2f0426db11fcee7acfbe3af138a5ff3 /libmat2 | |
| parent | 846a261465a95a594e9bfc5398cf09fd5deb437f (diff) | |
Improve the reliability of the office parser
Diffstat (limited to 'libmat2')
| -rw-r--r-- | libmat2/office.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/libmat2/office.py b/libmat2/office.py index a5a49cf..aea56b9 100644 --- a/libmat2/office.py +++ b/libmat2/office.py | |||
| @@ -16,6 +16,13 @@ class ArchiveBasedAbstractParser(abstract.AbstractParser): | |||
| 16 | files_to_keep = set() # type: Set[str] | 16 | files_to_keep = set() # type: Set[str] |
| 17 | files_to_omit = set() # type: Set[Pattern] | 17 | files_to_omit = set() # type: Set[Pattern] |
| 18 | 18 | ||
| 19 | def __init__(self, filename): | ||
| 20 | super().__init__(filename) | ||
| 21 | try: # better fail here than later | ||
| 22 | zipfile.ZipFile(self.filename) | ||
| 23 | except zipfile.BadZipFile: | ||
| 24 | raise ValueError | ||
| 25 | |||
| 19 | def _clean_zipinfo(self, zipinfo: zipfile.ZipInfo) -> zipfile.ZipInfo: | 26 | def _clean_zipinfo(self, zipinfo: zipfile.ZipInfo) -> zipfile.ZipInfo: |
| 20 | zipinfo.create_system = 3 # Linux | 27 | zipinfo.create_system = 3 # Linux |
| 21 | zipinfo.comment = b'' | 28 | zipinfo.comment = b'' |
