Repository navigation
fix(images): complete JATS file URI figure loading - #5017
bushidapengyou-cell wants to merge 2 commits into
Conversation
Signed-off-by: 苍穹外卖-01 <2046083414@qq.com>
Signed-off-by: 苍穹外卖-01 <2046083414@qq.com>
|
✅ DCO Check Passed Thanks @bushidapengyou-cell, 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 This pull request adds support for local Topic labels added: CI safety: needs maintainer care before you approve CI.
4 related pull request(s) in the same code
The |
There was a problem hiding this comment.
AI first review (advisory): no blocker found
This review covers the full diff at db3bbb8813. It read the code and did not run it.
The logic changes in _load_figure_image and normalize_local_base_path are correct and well-tested. The only merge blocker is the PR title, which does not follow the fix(...): conventional-commit format that Mergify requires. No code defects were found.
A maintainer makes the merge decision. This review never approves the pull request.
| or self.base_path is None | ||
| or not ImageResourceLoader.is_local_path(self.base_path) | ||
| ): | ||
| if not self.options.fetch_images or self.base_path is None: |
There was a problem hiding this comment.
question: JATS images require enable_local_fetch=True but the gate does not check it
The old guard checked is_local_path(self.base_path); the new guard skips the enable_local_fetch flag entirely. The permission is still enforced later inside ImageResourceLoader.load_image_data (which raises OperationNotAllowed, caught in create_image_ref and silently swallowed). But the function now calls normalize_local_base_path, Path.is_file, and emits warnings for root-URI cases even when enable_local_fetch=False. The test test_local_permission_prevents_image_bytes covers only the case where fetch_images=True and enable_local_fetch=False; it patches builtins.open to prove bytes are not read, which is correct. The normalize_local_base_path and is_file calls are not patched, so they do run. This is not a security regression (bytes are never read without the flag) but it is a behavioral change: the function now touches the filesystem even when local fetch is disabled. Confirm this is acceptable, or add an early return when not self.options.enable_local_fetch.
Resolves #5016. Follow-up to #4912 and the JATS work identified by @taran-dev4u in #4921.
Support local file URI sources in JATS, reject root-only JATS file URIs and non-localhost authorities outside Windows, and preserve article content when figure decoding raises OSError. Fetch permissions and directory confinement remain unchanged.
The separate Makefile commit aligns the line limit with the existing CI hook. It is independent of the image fix and can be split out if preferred.
Checklist:
Review evidence:
Verified image pixels, caption links, body ownership/order, and embedded Markdown export. No reference data changed.
Linux/Python 3.10: 333 passed, 3 skipped, including POSIX authority regressions:
PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 NO_PROXY='*' uv run --no-sync python -m coverage run --branch --source=docling.backend.xml.jats_backend,docling.backend.utils.image_resource_loader -m pytest -p no:cacheprovider -o addopts= tests/test_image_resource_loader.py tests/test_backend_jats.py tests/test_backend_jats_sub_articles.py tests/test_backend_jats_images.py tests/test_image_resource_file_uri.py tests/test_backend_markdown.py tests/test_backend_html.py tests/test_check_skill_routes.py -q --tb=short UV_NO_SYNC=1 make check UV_NO_SYNC=1 make validateBoth Make targets passed; non-blocking ty diagnostics remain.
Local Windows/Python 3.12: 320 passed, 4 failed, 5 skipped, with process-scoped
PYTEST_DISABLE_PLUGIN_AUTOLOAD=1andNO_PROXY=*:The same 4 HTML path assertion failures reproduce on the base. These are local results; full online CI awaits maintainer action. macOS was not tested.