diff options
Diffstat (limited to 'libmat2/epub.py')
| -rw-r--r-- | libmat2/epub.py | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/libmat2/epub.py b/libmat2/epub.py index 83f5728..af059d2 100644 --- a/libmat2/epub.py +++ b/libmat2/epub.py | |||
| @@ -1,6 +1,7 @@ | |||
| 1 | import logging | 1 | import logging |
| 2 | import re | 2 | import re |
| 3 | import uuid | 3 | import uuid |
| 4 | import zipfile | ||
| 4 | import xml.etree.ElementTree as ET # type: ignore | 5 | import xml.etree.ElementTree as ET # type: ignore |
| 5 | from typing import Dict, Any | 6 | from typing import Dict, Any |
| 6 | 7 | ||
| @@ -27,7 +28,16 @@ class EPUBParser(archive.ZipParser): | |||
| 27 | })) | 28 | })) |
| 28 | self.uniqid = uuid.uuid4() | 29 | self.uniqid = uuid.uuid4() |
| 29 | 30 | ||
| 30 | def _specific_get_meta(self, full_path, file_path): | 31 | |
| 32 | def is_archive_valid(self): | ||
| 33 | super().is_archive_valid() | ||
| 34 | with zipfile.ZipFile(self.filename) as zin: | ||
| 35 | for item in self._get_all_members(zin): | ||
| 36 | member_name = self._get_member_name(item) | ||
| 37 | if member_name.endswith('META-INF/encryption.xml'): | ||
| 38 | raise ValueError('the file contains encrypted fonts') | ||
| 39 | |||
| 40 | def _specific_get_meta(self, full_path, file_path) -> Dict[str, Any]: | ||
| 31 | if not file_path.endswith('.opf'): | 41 | if not file_path.endswith('.opf'): |
| 32 | return {} | 42 | return {} |
| 33 | 43 | ||
