Repository navigation
fix(images): resolve relative images when base path is a file URI - #4921
taran-dev4u wants to merge 1 commit into
Conversation
Allow file:// URIs as base_path in ImageResourceLoader.resolve_relative_path and normalize them to filesystem paths for directory confinement and local resolution. Support file URI base paths in HTML and JATS figure loading, and add unit tests. Fixes docling-project#4911. Signed-off-by: Taran Mamidala <mamidalataran6333@gmail.com>
|
✅ DCO Check Passed Thanks @taran-dev4u, all your commits are properly signed off. 🎉 |
Merge Protections🟢 Merge protection satisfied — ready to merge. Show 1 satisfied protection🟢 Enforce conventional commitMake sure that we follow https://www.conventionalcommits.org/en/v1.0.0/
|
AI triage (advisory)Checked commit The PR makes Topic labels added: CI safety: no concern found. A maintainer must still approve CI. Possible duplicates
The |
|
Closing in favor of #4912, which was opened earlier. |
Issue resolved by this Pull Request:
Resolves #4911
When
source_uriis supplied as afile://URI,ImageResourceLoader.resolve_relative_pathpreviously rejected it withValueError: Invalid base_path formatbecauseis_local_pathonly recognized raw filesystem paths. This addsis_file_uriandfile_uri_to_pathhelpers to normalize file URIs to local paths for directory confinement and relative image resolution, and allows file URI base paths in HTML and JATS figure loading.Checklist:
Review evidence:
Before this change, passing a
file://URI assource_uriwithfetch_images=TrueraisedValueError: Invalid base_path format: 'file:///...'during image resolution. After this change, relative images resolve against the local file URI directory while preserving path traversal and absolute path guards. Added unit tests intests/test_backend_html.py(test_resolve_relative_path_file_uri) andtests/test_backend_markdown.py(test_local_relative_image_resolved_with_file_uri_source).