Skip to content

fix(ui): decode reserved characters in chat file links - #595

Merged
alphaxiv-bot[bot] merged 17 commits into
alphaXiv:mainfrom
KennyMcSimpson:fix/markdown-encoded-filenames
Oct 28, 2026
Merged

alphaxiv-bot[bot] merged 17 commits into
alphaXiv:mainfrom
KennyMcSimpson:fix/markdown-encoded-filenames

Conversation

@KennyMcSimpson

@KennyMcSimpson KennyMcSimpson commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Closes #594

Chat file links without a file resolver open chart%231.png instead of chart#1.png. Decode reserved filename characters in citedFilePath()'s fallback.

Regression coverage stays in the existing markdownTarget suite. It checks encoded punctuation, %2523 decoded once, malformed escapes and NUL rejection. The contribution changes one production line and adds 14 lines to the existing test file.

Validation against main 7bfa16d, with Node 22 and pnpm 10:

  • All 20 Markdown target tests pass. Running the same tests against unchanged main gives 19 passes and one failure in the new reserved-filename regression.
  • All 507 UI tests and 25 CI selection/release-safety tests pass.
  • Localization and style checks, TypeScript and pnpm build pass.
  • git diff --check passes.

Local Windows verification sends the CI tests' Bash snippets through temporary files to preserve backslashes. The workflow, test cases and assertions are unchanged.

Add regression tests for encoded filenames, query preservation, and traversal rejection. UI bundle regeneration is pending until the execution environment reconnects.
@KennyMcSimpson
KennyMcSimpson marked this pull request as ready for review October 8, 2026 11:32
@greptile-apps

greptile-apps Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 4/5

[Medium risk] Changes how markdown file paths decode special characters.

Fix repeated path decoding in file and figure links before merging.

Findings

  1. P1 Links open the wrong file ▶
Fix with agent prompt
### Issue 1
ui/src/markdownTarget.ts:27
`decodeURIComponent` now exposes reserved characters to callers that decode or split the path again. In a Markdown file, a captioned image at `figures/chart%231.png` with a matching `[Figure 1]` link becomes `figures/chart#1.png` in `chatImageTarget`. `Md` passes that decoded path to `resolveFilePath`, which treats `#1.png` as a fragment and opens `figures/chart` instead.

Plain links also decode twice: `Md` calls `decodeURI` before the resolver, so `chart%25231.png` now opens `chart#1.png` instead of the literal filename `chart%231.png`.

Keep paths encoded until the final resolver call, and add tests through both link paths.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Summary

This PR decodes reserved characters in local Markdown filenames and updates the embedded UI assets.

  • Adds tests for reserved characters, single decoding, query preservation, and rejected paths.
  • Image requests preserve decoded filenames.
  • File links still process some paths twice, which can open the wrong file.

Reviews (1) · Last reviewed commit: "build(ui): regenerate assets for encoded..." · Reviewed by Greptile

Comment thread ui/src/markdownTarget.ts
@KennyMcSimpson KennyMcSimpson changed the title fix(ui): decode reserved characters in local markdown paths fix(ui): decode reserved characters in chat file links Oct 10, 2026
paperclover
paperclover previously approved these changes Oct 28, 2026
Comment thread ui/tests/markdownEncodedFilenames.test.mjs Outdated
@paperclover paperclover added the auto-merge Queue for automatic merge once all checks pass label Oct 28, 2026
@alphaxiv-bot
alphaxiv-bot Bot merged commit f10b3f3 into alphaXiv:main Oct 28, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

auto-merge Queue for automatic merge once all checks pass

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Local Markdown images fail for percent-encoded reserved filename characters

2 participants