text: Keep document image sources URI-backed - #2735
Merged
huacnlee merged 2 commits intoAug 16, 2026
Merged
Conversation
Member
|
cc @madcodelife |
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.
Closes #2733
Description
Keep image sources originating from
TextViewdocuments URI-backed instead ofimplicitly converting
file://and scheme-less strings intoResource::Path.The previous conversion allowed Markdown and HTML content, including LSP hover
and completion documentation, to trigger reads of attacker-selected local
filesystem paths.
Inline images, block images, and intrinsic-size measurement already share the
image_sourcehelper, so this change is confined to that conversion and itsexisting unit test. Relative paths, absolute paths, Windows paths, and
file://values are now all kept asResource::Uri.This intentionally removes implicit local-filesystem image loading from generic
TextViewcontent. As a result, relative images such aswebsite/public/logo.svgin the Story Gallery README will no longer load aslocal files. Supporting trusted local document resources requires a separate,
explicit API; base-directory confinement, path normalization, file-size
limits, and other resource-policy changes are outside the scope of this patch.
How to Test
The following checks pass:
The updated
test_image_sourceverifies that remote URLs, data URLs, relativepaths (including
..traversal), Unix absolute paths, Windows paths, pathscontaining colons, and
file://values all remainResource::Uri.Manual runtime verification was also performed on Linux with the existing
markdown_tableexample and a Markdown document containing:Under
strace, the vulnerable implementation opened the referenced SVG:With this patch, the example opened the injected Markdown document but did not
issue any
openoropenatcall for the referenced SVG.Checklist
cargo runfor story tests related to the changes. The StoryGallery starts successfully; the README relative image is no longer loaded
from the local filesystem, as documented above.