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
80fc4ffb
Commit
80fc4ffb
authored
6 years ago
by
Julien (jvoisin) Voisin
Browse files
Options
Downloads
Patches
Plain Diff
Remove the thumbnails from libreoffice files
parent
177184ac
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
libmat2/office.py
+1
-0
1 addition, 0 deletions
libmat2/office.py
tests/data/revision.odt
+0
-0
0 additions, 0 deletions
tests/data/revision.odt
tests/test_libmat2.py
+17
-0
17 additions, 0 deletions
tests/test_libmat2.py
with
18 additions
and
0 deletions
libmat2/office.py
+
1
−
0
View file @
80fc4ffb
...
...
@@ -146,6 +146,7 @@ class LibreOfficeParser(ArchiveBasedAbstractParser):
files_to_omit
=
set
(
map
(
re
.
compile
,
{
# type: ignore
'
^meta\.xml$
'
,
'
^Configurations2/
'
,
'
^Thumbnails/
'
,
}))
def
get_meta
(
self
)
->
Dict
[
str
,
str
]:
...
...
This diff is collapsed.
Click to expand it.
tests/data/revision.odt
0 → 100644
+
0
−
0
View file @
80fc4ffb
File added
This diff is collapsed.
Click to expand it.
tests/test_libmat2.py
+
17
−
0
View file @
80fc4ffb
...
...
@@ -105,6 +105,23 @@ class TestGetMeta(unittest.TestCase):
self
.
assertEqual
(
meta
[
'
meta:generator
'
],
'
LibreOffice/3.3$Unix LibreOffice_project/330m19$Build-202
'
)
class
TestRemovingThumbnails
(
unittest
.
TestCase
):
def
test_odt
(
self
):
shutil
.
copy
(
'
./tests/data/revision.odt
'
,
'
./tests/data/clean.odt
'
)
zipin
=
zipfile
.
ZipFile
(
os
.
path
.
abspath
(
'
./tests/data/clean.odt
'
))
self
.
assertIn
(
'
Thumbnails/thumbnail.png
'
,
zipin
.
namelist
())
zipin
.
close
()
p
=
office
.
LibreOfficeParser
(
'
./tests/data/clean.odt
'
)
self
.
assertTrue
(
p
.
remove_all
())
zipin
=
zipfile
.
ZipFile
(
os
.
path
.
abspath
(
'
./tests/data/clean.cleaned.odt
'
))
self
.
assertNotIn
(
'
Thumbnails/thumbnail.png
'
,
zipin
.
namelist
())
zipin
.
close
()
os
.
remove
(
'
./tests/data/clean.cleaned.odt
'
)
class
TestDeepCleaning
(
unittest
.
TestCase
):
def
__check_deep_meta
(
self
,
p
):
tempdir
=
tempfile
.
mkdtemp
()
...
...
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