Repository navigation
fix(muya): load relative images from folders named with #, ? or % (#5302) - #5301
Merged
Merged
Conversation
) getImageSrc joined the raw window.DIRNAME into a file:// URL, so a `#` or `?` in the document's folder name started a fragment or query and the image failed to load, and a literal `%xx` in the name was percent-decoded. Encode those characters in the directory only: the markdown path is already URL-form and must not be encoded twice. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01Tn9MCAxQ8NDX7trUiCvMTH
…and % (#5212) Opens the real app on a document in `C# 100%25 what?/` and waits for the image to load off disk; it times out on a build without the fix. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01Tn9MCAxQ8NDX7trUiCvMTH
1 task done
|
Build artifacts for PR #5301: Run: https://github.com/marktext/marktext/actions/runs/34550166948
|
2 of 6 tasks
Jocs
pushed a commit
that referenced
this pull request
Sep 14, 2026
…? or % (#5320) resolveLocalLinkHref joined the raw window.DIRNAME into a file:// URL, so a `#` or `?` in the document's folder name started a fragment or query in the exported HTML / PDF link, and a literal `%xx` in the name was percent-decoded. Escape those characters in the directory only, as getImageSrc does in muya since #5301: the markdown link is already URL-form and keeps its own fragment.
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.
Fixes #5302.
Summary
#or?, e.g.C# notes/note.mdwith.getImageSrcjoined the rawwindow.DIRNAMEinto afile://URL, so Chromium read the rest of the path as a fragment or query. A literal%xxin the folder name was percent-decoded the same way.getImageSrcnow percent-encodes%,?and#in the directory only. The markdown path is left as written: it is already URL-form (my%20image.jpg) and would otherwise be double-encoded.Relation to #5212
Related to #5212. The steps there (
next toassets/image.jpg) do not reproduce on the published v0.20.0-rc.1 macOS arm64 build. Tested: launching with the file as an argument, cold start through Finder (open), opening into a running window, and folders named with spaces, CJK characters and%. The one failure found for that setup is a folder name containing#or?, filed as #5302 and fixed here. It is not an rc regression: legacy muyajs built the URL as'file://' + path.resolve(DIRNAME, src)too.Not changed
packages/desktop/src/renderer/src/util/resolveImageSrc.ts(HTML/PDF export) andresolveLinkHref.tsbuildfile://URLs fromDIRNAMEthe same way; left for a follow-up.Test plan
packages/muya/src/utils/__tests__/image.spec.ts:#,?and%25in the directory (the URL's path decodes back to the file, with no hash or query), and no re-encoding of the markdown path. All 4 fail before the fix and pass after.packages/desktop/test/e2e/image-relative-path.spec.ts: new real-app case opening a document inC# 100%25 what?/. Fails on the unfixed build (the image never reaches.mu-image-success), passes with the fix.tsc --noEmit; desktop eslint + typecheck.🤖 Generated with Claude Code
https://claude.ai/code/session_01Tn9MCAxQ8NDX7trUiCvMTH