Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
jvoisin
mat2
Commits
5b38bd7c
Commit
5b38bd7c
authored
Jun 21, 2018
by
jvoisin
Browse files
Improve the reliability of the office parser
parent
846a2614
Changes
2
Hide whitespace changes
Inline
Side-by-side
libmat2/office.py
View file @
5b38bd7c
...
...
@@ -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
''
...
...
tests/test_libmat2.py
View file @
5b38bd7c
...
...
@@ -90,6 +90,11 @@ class TestCorruptedFiles(unittest.TestCase):
os
.
remove
(
'./tests/data/clean.torrent'
)
def
test_odg
(
self
):
shutil
.
copy
(
'./tests/data/dirty.png'
,
'./tests/data/clean.odg'
)
with
self
.
assertRaises
(
ValueError
):
office
.
LibreOfficeParser
(
'./tests/data/clean.odg'
)
class
TestGetMeta
(
unittest
.
TestCase
):
def
test_pdf
(
self
):
p
=
pdf
.
PDFParser
(
'./tests/data/dirty.pdf'
)
...
...
jvoisin
@jvoisin
mentioned in issue
#24 (closed)
·
Jun 21, 2018
mentioned in issue
#24 (closed)
mentioned in issue #24
Toggle commit list
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment