You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug] Relative images fail to load when the document's folder name contains # or ? #5302
A relative-path image () shows "Load image failed" when the document's folder name contains # or ?, for example C# notes/note.md. The same document in a folder without those characters renders the image.
getImageSrc (packages/muya/src/utils/image.ts) resolves a relative image path against window.DIRNAME and puts the raw directory into a file:// URL. Chromium reads everything after # as a fragment and everything after ? as a query, so it requests a file that doesn't exist. A literal % followed by two hex digits in a folder name is percent-decoded the same way: getImageSrc turns a folder named 50%25 off into a URL for 50% off.
This is not new in 0.20: legacy muyajs built the URL as 'file://' + path.resolve(DIRNAME, src) too.
Measured on the published v0.20.0-rc.1 macOS arm64 build, opening note.md that contains  next to assets/image.jpg (a real JPEG):
Document folder
Image
fixture/
loads
with space/
loads
中文 目录/
loads
100% done/
loads
C# notes/
Load image failed
what? notes/
Load image failed
This issue covers images in the editor. HTML/PDF export (packages/desktop/src/renderer/src/util/resolveImageSrc.ts) and local link resolution (resolveLinkHref.ts) join DIRNAME into file:// URLs the same way; that is not verified in the app and not covered here.
Found while investigating #5212, whose own steps don't reproduce.
Steps to Reproduce
Create a folder named C# notes with an assets subfolder, and save any JPEG in it as assets/image.jpg.
In C# notes, create note.md containing .
Open note.md in MarkText.
Expected Behavior
The image renders, as it does when the folder is named notes.
Activity
fix(muya): load relative images from folders named with #, ? or % (#5302