diff options
| author | jvoisin | 2018-10-03 16:35:36 +0200 |
|---|---|---|
| committer | jvoisin | 2018-10-03 16:38:05 +0200 |
| commit | 5a5c642a463523bf8cc56ad13817b82900661bd4 (patch) | |
| tree | 2b1af032e2801a3848e7906c8c897296f5177862 /libmat2 | |
| parent | 84e302ac9394397c98845cbdb4334ab646f8ae4b (diff) | |
Don't break office files for MS Office
We didn't take the whitelist into account while
removing dangling files from [Content_types].xml
Diffstat (limited to 'libmat2')
| -rw-r--r-- | libmat2/office.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/libmat2/office.py b/libmat2/office.py index 997a247..372d69a 100644 --- a/libmat2/office.py +++ b/libmat2/office.py | |||
| @@ -217,8 +217,13 @@ class MSOfficeParser(ArchiveBasedAbstractParser): | |||
| 217 | removed_fnames = set() | 217 | removed_fnames = set() |
| 218 | with zipfile.ZipFile(self.filename) as zin: | 218 | with zipfile.ZipFile(self.filename) as zin: |
| 219 | for fname in [item.filename for item in zin.infolist()]: | 219 | for fname in [item.filename for item in zin.infolist()]: |
| 220 | if any(map(lambda r: r.search(fname), self.files_to_omit)): # type: ignore | 220 | for file_to_omit in self.files_to_omit: |
| 221 | removed_fnames.add(fname) | 221 | if file_to_omit.search(fname): |
| 222 | matches = map(lambda r: r.search(fname), self.files_to_keep) | ||
| 223 | if any(matches): # the file is whitelisted | ||
| 224 | continue | ||
| 225 | removed_fnames.add(fname) | ||
| 226 | break | ||
| 222 | 227 | ||
| 223 | root = tree.getroot() | 228 | root = tree.getroot() |
| 224 | for item in root.findall('{%s}Override' % namespace['']): | 229 | for item in root.findall('{%s}Override' % namespace['']): |
