Repository navigation
fix: gate all local image reads behind allow_image_file_uri - #900
Merged
Merged
Conversation
ImageRef only gated file:// URIs. A plain filesystem path in an untrusted DoclingDocument was still read when exporting with embedded or referenced images, and _with_embedded_pictures (used by save_as_* in EMBEDDED mode) opened file:// URIs and paths directly, bypassing both the gate and the size limit. Route every local read through ImageRef.pil_image, which now applies the allow_image_file_uri opt-in and the size limit to both file:// URIs and plain paths. DocLang archive loading caches the images it has already validated, so loading a .dclx keeps working by default. For trusted documents, add a per-document opt-in next to the global setting: DoclingDocument.load_local_images() reads the locally referenced images into memory, and load_from_json / load_from_yaml call it via allow_local_images=True, resolving relative paths against the file's directory. Document both in the README. Reading local image paths now requires DOCLINGCORE_ALLOW_IMAGE_FILE_URI=true or allow_local_images=True. Signed-off-by: Panos Vagenas <[email protected]>
Contributor
|
✅ DCO Check Passed Thanks @vagenas, all your commits are properly signed off. 🎉 |
Contributor
Merge Protections🟢 All 2 merge protections satisfied — ready to merge. Show 2 satisfied protections🟢 Enforce conventional commitMake sure that we follow https://www.conventionalcommits.org/en/v1.0.0/
🟢 Require two reviewer for test updatesWhen test data is updated, we require two reviewers
|
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
PeterStaar-IBM
approved these changes
Oct 19, 2026
dolfim-ibm
approved these changes
Oct 19, 2026
This was referenced Oct 19, 2026
2 of 3 tasks
1 of 3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes
ImageRef.pil_image, which now requiresallow_image_file_urifor bothfile://URIs and plain filesystem paths, and applies the image size limit to both. Previously plain paths, and the embedded-image path used bysave_as_*, did not go through this setting.DoclingDocument.load_local_images(base_dir=None)reads the locally referenced picture and page images into memory, andload_from_json/load_from_yamlacceptallow_local_images=True, which resolves relative paths against the file's directory..dclxloading keeps its images in memory after reading them from the archive, so it keeps working by default.save_as_*, page images and both options.Local image paths (plain filesystem paths and
file://URIs) are no longer read by default. To read them, either setDOCLINGCORE_ALLOW_IMAGE_FILE_URI=true, or load withDoclingDocument.load_from_json(..., allow_local_images=True)/ calldoc.load_local_images(). This affects, for example, a JSON saved withImageRefMode.REFERENCEDand loaded again.