Repository navigation
Conversation
- Decode each Markdown URL path segment exactly once before resolving workspace paths - Share the decoder between local images and relative Markdown links - Refuse malformed escapes and encoded separators without falling back to the raw path - Treat a leading slash in Markdown links as the workspace root, matching images - Judge disk paths by their real file name so `#` and `?` stay part of the name - Stamp image MIME from the disk file name instead of the full absolute path - Restrict image MIME lookup to the table's own extension keys - Settle synchronous image read failures into the visible error state - Show localized chip notes when a local image source is refused - Cover parser output, same-name collisions, and disk MIME cases in tests
5896d15 to
a1c08b7
Compare
|
/copilot-review claude-opus-5.5 medium |
Copilot reviewAsked by @HsienW. Model: claude-opus-5.5. Effort: medium. Head: 1. A
react-markdown passes a literal
Images don't have this problem, because
I found no other real problems:
|
- check .md/.markdown on the decoded last segment, the name that is opened - `secrets.env?.md` and `secrets.env#.md` no longer open secrets.env - a query after a real .md (`notes.md?v=2`) now opens notes.md, as for images - drop isRelativeMd, which no longer has a caller - add a regression test for links whose href and opened path disagree
|
/copilot-review claude-opus-5.5 medium |
Copilot reviewAsked by @HsienW. Model: claude-opus-5.5. Effort: medium. Head: No blocking problems found. I checked the decoding and link/image resolution against the base code and the call sites ( One case looked risky at first. An encoded drive letter, such as |
What & why
Markdown preview was handing URL-encoded paths straight to the filesystem. So
tried to read a file literally namedQA%20Shot.png, which fails withENOENTeven thoughQA Shot.pngis sitting right there. Worse, if both files exist, it quietly shows the wrong one.The root cause is that we mix two kinds of strings: Markdown hrefs (URLs) and disk file names. This PR keeps them apart. Each URL path segment now gets decoded exactly once, right at the Markdown boundary. Relative
.mdlinks had the same bug, so they share the same decoder. On the disk side, extension checks now look at the real file name, so a#or?in a name likeQA#1.pngno longer breaks image detection. MIME lookup also only checks the table's own keys now, so something likex.constructorno longer counts as an image.If a path can't be decoded safely (a malformed escape like
%zz, or an encoded/), we refuse it instead of falling back to the raw string. The image chip then shows the reason in every shipped locale instead of failing silently. A sync throw from the read call used to take down the whole preview pane. Now it settles into the same visible error state.Closes: #820
Updated for 0.6.0
IdePanel.tsxand the imports inImagePreview.tsx, so the switch toisImageDiskPath/isSvgDiskPathnow sits on the new image tab, the "view source" control and the "view image" button.markdownImagestrings are now translated for all 11, so German, Spanish, French, Italian, Japanese, Korean, Brazilian Portuguese and Turkish are new in this update.zh-TW.jsononly arrives with feat(i18n): add Traditional Chinese (Taiwan) locale #914. Until both are in, a zh-TW user sees these six strings in English through theenfallback. I'll add the zh-TW strings in a follow-up PR.rulesPanelthere,markdownImagehere). Git reports it as a conflict in each file, but there is nothing to choose between. Whichever lands second should keep both blocks..mdlinks now check the extension on the decoded file name, the one that actually opens, so a link likesecrets.env?.mdno longer openssecrets.env. One test was added for this.Type of change
Evidence
Before
The new tests running against the code currently on
main: 14 failing (tests 34 / pass 20 / fail 14). Check outa space-named image and its literal-%20 twin each read their OWN bytes. That one shows the bug best. I re-ran this against 0.6.0mainand got the same result. The screenshots predate the link test added in this update; with it, the count onmainistests 35 / pass 20 / fail 15.The one new test that passes here is
what the parser actually hands the resolver. It only pins down whatreact-markdownhands us, so it's green on both sides by design.After
Same command with the fix applied:
tests 34 / pass 34 / fail 0. On the current branch, with the added link test, it istests 35 / pass 35 / fail 0.How I tested it
test/ide-image.test.cjsagainst 0.6.0mainand confirmed that 15 of them fail. The 16th is the parser test described above, which passes on both sides by design. The failures are the missing functions and a byte comparison showing the wrong file was read.node --test test/ide-image.test.cjson this branch: 35/35 pass.npm run test:focusedwith and without the change, then diffed the failure lists by file and test name. Before: 922 tests, 812 pass, 99 fail. After: 938 tests, 828 pass, 99 fail. The 99 failures are the exact same tests on both sides, and none of them is in the image or Markdown code. They're pre-existing on my Windows box.npm run typecheck. Bothtypecheck:nodeandtypecheck:webexit 0.npm run buildandgit diff --check. Both pass.markdownImageblocks against the English key set. Each has the same six keys and a real translation for every value.react-markdownoutput, so they cover what the resolver actually receives, including%25and%5Cnormalization, and not just hand-written inputs.Checklist
npm run typecheckpasses.npm run test:focusedpasses. It does not pass onmaineither. No new failures: the same 99 pre-existing failures show up with and without this change (details above).npm run buildsucceeds.commented-out code, or unrelated formatting churn in it.
DESIGN.md/tokens.ts. No ad-hoc colors,spacing, or fonts.
ATTRIBUTION.md. Not applicable: no art was added.