diff options
Diffstat (limited to 'libmat2/office.py')
| -rw-r--r-- | libmat2/office.py | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/libmat2/office.py b/libmat2/office.py index 1765896..d945f6a 100644 --- a/libmat2/office.py +++ b/libmat2/office.py | |||
| @@ -1,3 +1,4 @@ | |||
| 1 | import uuid | ||
| 1 | import logging | 2 | import logging |
| 2 | import os | 3 | import os |
| 3 | import re | 4 | import re |
| @@ -82,7 +83,7 @@ class MSOfficeParser(ZipParser): | |||
| 82 | r'^(?:word|ppt)/_rels/header[0-9]*\.xml\.rels$', | 83 | r'^(?:word|ppt)/_rels/header[0-9]*\.xml\.rels$', |
| 83 | r'^ppt/slideLayouts/_rels/slideLayout[0-9]+\.xml\.rels$', | 84 | r'^ppt/slideLayouts/_rels/slideLayout[0-9]+\.xml\.rels$', |
| 84 | r'^ppt/slideLayouts/slideLayout[0-9]+\.xml$', | 85 | r'^ppt/slideLayouts/slideLayout[0-9]+\.xml$', |
| 85 | 86 | r'^(?:word|ppt)/tableStyles\.xml$', | |
| 86 | # https://msdn.microsoft.com/en-us/library/dd908153(v=office.12).aspx | 87 | # https://msdn.microsoft.com/en-us/library/dd908153(v=office.12).aspx |
| 87 | r'^(?:word|ppt)/stylesWithEffects\.xml$', | 88 | r'^(?:word|ppt)/stylesWithEffects\.xml$', |
| 88 | })) | 89 | })) |
| @@ -302,6 +303,13 @@ class MSOfficeParser(ZipParser): | |||
| 302 | f.write(b'<?xml version="1.0" encoding="UTF-8" standalone="yes"?>') | 303 | f.write(b'<?xml version="1.0" encoding="UTF-8" standalone="yes"?>') |
| 303 | f.write(b'<cp:coreProperties xmlns:cp="http://schemas.openxmlformats.org/package/2006/metadata/core-properties">') | 304 | f.write(b'<cp:coreProperties xmlns:cp="http://schemas.openxmlformats.org/package/2006/metadata/core-properties">') |
| 304 | f.write(b'</cp:coreProperties>') | 305 | f.write(b'</cp:coreProperties>') |
| 306 | elif full_path.endswith('/ppt/tableStyles.xml'): # pragma: no cover | ||
| 307 | # This file must be present and valid, | ||
| 308 | # so we're removing as much as we can. | ||
| 309 | with open(full_path, 'wb') as f: | ||
| 310 | f.write(b'<?xml version="1.0">') | ||
| 311 | uid = str(uuid.uuid4()).encode('utf-8') | ||
| 312 | f.write(b'<a:tblStyleLst def="{%s}" xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main"/>' % uid) | ||
| 305 | 313 | ||
| 306 | if self.__remove_rsid(full_path) is False: | 314 | if self.__remove_rsid(full_path) is False: |
| 307 | return False | 315 | return False |
