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
e2362b86
Commit
e2362b86
authored
Mar 07, 2021
by
jvoisin
Browse files
Improve epub support
Warn when there are encrypted fonts in an epub file
parent
626669f9
Changes
1
Hide whitespace changes
Inline
Side-by-side
libmat2/epub.py
View file @
e2362b86
import
logging
import
re
import
uuid
import
zipfile
import
xml.etree.ElementTree
as
ET
# type: ignore
from
typing
import
Dict
,
Any
...
...
@@ -27,7 +28,16 @@ class EPUBParser(archive.ZipParser):
}))
self
.
uniqid
=
uuid
.
uuid4
()
def
_specific_get_meta
(
self
,
full_path
,
file_path
):
def
is_archive_valid
(
self
):
super
().
is_archive_valid
()
with
zipfile
.
ZipFile
(
self
.
filename
)
as
zin
:
for
item
in
self
.
_get_all_members
(
zin
):
member_name
=
self
.
_get_member_name
(
item
)
if
member_name
.
endswith
(
'META-INF/encryption.xml'
):
raise
ValueError
(
'the file contains encrypted fonts'
)
def
_specific_get_meta
(
self
,
full_path
,
file_path
)
->
Dict
[
str
,
Any
]:
if
not
file_path
.
endswith
(
'.opf'
):
return
{}
...
...
jvoisin
@jvoisin
mentioned in issue
#148 (closed)
·
Mar 07, 2021
mentioned in issue
#148 (closed)
mentioned in issue #148
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