diff options
| author | Michael Williamson <mike@zwobble.org> | 2025-09-10 16:15:28 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2025-09-10 16:15:28 +0100 |
| commit | 150bf98e7ae2fd8ae874c3e756c39f01b3c01a23 (patch) | |
| tree | 22844fd319ceba4c54d4e95ddb6246fd2e9b17d2 /mammoth/docx/__init__.py | |
| parent | 603f8b83c0389be91ca90a3cb7690d7f237699d8 (diff) | |
Support disabling external file access
Diffstat (limited to 'mammoth/docx/__init__.py')
| -rw-r--r-- | mammoth/docx/__init__.py | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/mammoth/docx/__init__.py b/mammoth/docx/__init__.py index 3848736..a0576cf 100644 --- a/mammoth/docx/__init__.py +++ b/mammoth/docx/__init__.py @@ -19,13 +19,14 @@ from ..zips import open_zip _empty_result = results.success([]) -def read(fileobj): +def read(fileobj, external_file_access=False): zip_file = open_zip(fileobj, "r") part_paths = _find_part_paths(zip_file) read_part_with_body = _part_with_body_reader( getattr(fileobj, "name", None), zip_file, part_paths=part_paths, + external_file_access=external_file_access, ) return results.combine([ @@ -134,7 +135,7 @@ def _read_document(zip_file, read_part_with_body, notes, comments, part_paths): ) -def _part_with_body_reader(document_path, zip_file, part_paths): +def _part_with_body_reader(document_path, zip_file, part_paths, external_file_access): content_types = _try_read_entry_or_default( zip_file, "[Content_Types].xml", @@ -156,7 +157,10 @@ def _part_with_body_reader(document_path, zip_file, part_paths): default=Numbering.EMPTY, ) - files = Files(None if document_path is None else os.path.dirname(document_path)) + files = Files( + None if document_path is None else os.path.dirname(document_path), + external_file_access=external_file_access, + ) def read_part(name, reader, default=_undefined): relationships = _read_relationships(zip_file, _find_relationships_path_for(name)) |
