Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
mat2
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
tails
mat2
Commits
5b38bd7c
Commit
5b38bd7c
authored
6 years ago
by
Julien (jvoisin) Voisin
Browse files
Options
Downloads
Patches
Plain Diff
Improve the reliability of the office parser
parent
846a2614
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
libmat2/office.py
+7
-0
7 additions, 0 deletions
libmat2/office.py
tests/test_libmat2.py
+5
-0
5 additions, 0 deletions
tests/test_libmat2.py
with
12 additions
and
0 deletions
libmat2/office.py
+
7
−
0
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
''
...
...
This diff is collapsed.
Click to expand it.
tests/test_libmat2.py
+
5
−
0
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
'
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment