Repository navigation
parse: resolve percent-encoded image destinations - #7735
Batianxieshen1 wants to merge 3 commits into
Conversation
|
I verified The path exercised was
Plain names, There is also a reproducible test failure: the four focused modules ( AI-only verification on macOS arm64 / Python 3.14.10 / Node 26.13.1, using the published OpenViking 0.5.3 native component and Studio's lockfile renderer versions. The renderer recorded image targets without mounting the UI or downloading assets; no network, model, full service or native Windows run. |
|
Thanks — both findings were real and are fixed in 1. Downstream serialization (
2. The test failure. Root cause was exactly as you said: Verification limits, same as before: local direct-call exercises of |
|
Confirmed the two functional fixes on I compared The same four focused parser modules now pass 38/38; the One lint detail remains: AI-only verification on macOS arm64 / Python 3.14.10 / Node 26.13.1. The renderer uses Studio's lockfile dependencies and production URL-resolution functions, recording targets without mounting the UI or downloading assets. No real server/model or native Windows/Linux run. |
|
Fixed in The I001 was real: No behavior change in this commit — only the import position. |
Fixes the URI-encoded local image path issue reported in volcengine#7725. Markdown image destinations may be percent-encoded (e.g. ), but _resolve_image_path passed the encoded spelling straight to Path(), so an existing "space chart.png" was reported as not found and the image was silently dropped from ingestion and attribution. Decode percent escapes once at the destination-to-filesystem boundary (urllib.parse.unquote). The confinement checks (absolute-path rejection and allowed-root containment) run on the decoded path, so encoded traversal stays rejected. Callers keep the original encoded spelling as the mapping key, and literal percent signs without a valid escape are untouched. AI-assisted: generated with ZCode (GLM); reproduced locally on Windows against main, and verified and reviewed by a human. Assisted-by: ZCode (GLM)
Addresses the review on this PR. The decoding change in _resolve_image_path copies the right bytes, but the rewritten destination still embedded the decoded filename verbatim, so the final Markdown/HTML renderer broke on names containing a space, ')', '#' or '%'. Percent-encode only the emitted filename in _mapped_uri; the filesystem name and the mapping key keep their original spelling. Tests: cover the emitted Markdown image node and the <img> tag for exactly the reported cases (space, CJK with space, literal percent, '#', ')', '+', plain). Also fix the reported test failure: tempfile was imported inside a helper while another test used it at module scope (NameError), pytest was imported unused, and import ordering is fixed. AI-assisted: generated with ZCode (GLM); the review findings were reproduced and the fix verified locally by a human. Assisted-by: ZCode (GLM)
Sort the stdlib imports in markdown.py as isort expects (I001 reported by ruff check). No behavior change.
Fixes #7725.
Problem
Markdown image destinations may be percent-encoded (e.g.
), but_resolve_image_pathpassed the encoded spelling straight toPath(), so an existingspace chart.pngwas reported asImage file not foundand the image was silently dropped from ingestion and lineage attribution — the Experience never appears in trajectory attribution.Change
Decode percent escapes once at the destination-to-filesystem boundary (
urllib.parse.unquoteinside_resolve_image_path, after_unwrap_link_destination). The confinement checks (absolute-path rejection and allowed-root containment) run on the decoded path, so encoded traversal (%2e%2e) stays rejected. Callers keep the original encoded spelling as the mapping key (file_mappings[origin_link]), and literal percent signs without a valid escape are untouched (100%.pngstill resolves;100%25.pngalso decodes to it).Verification
_resolve_image_path("space%20chart.png", base_dir_with_existing_file)returnedNone; after, it resolves to the existing file.tests/parse/test_markdown_encoded_image_dests.pycovers: encoded spaces, encoded Unicode, literal percent (untouched),%25decoding, unencoded paths, missing files, encoded traversal confinement, and<encoded>HTML-style destinations._resolve_image_pathdirectly and CI will run the new tests.AI disclosure
This PR was generated with AI assistance (ZCode, GLM); the issue was reproduced locally on Windows against
main(f9bf90b3), and the fix and its tests were reviewed and verified by a human before submission.