Skip to content

fix(shared): Markdown links and images with uppercase FILE keep their URLs - #43836

Merged
juliusmarminge merged 3 commits into
pingdotgg:mainfrom
saphid:hunter/c-ff31a6fd2a
Nov 27, 2026
Merged

juliusmarminge merged 3 commits into
pingdotgg:mainfrom
saphid:hunter/c-ff31a6fd2a

Conversation

@saphid

@saphid saphid commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

Problem

Markdown links and images written with uppercase FILE: lose their targets during sanitization, although lowercase file: works and local-file resolvers accept either casing. Theme-specific picture sources are stripped too.

Deterministic repro on origin/main (beb24ffed87bbb45e81dd27c7f253c30e83b2599)

Run from the repository root:

cd packages/shared
node --input-type=module <<'JS'
import { unified } from 'unified';
import remarkParse from 'remark-parse';
import remarkRehype from 'remark-rehype';
import { CHAT_MARKDOWN_REHYPE_PLUGINS, chatMarkdownImageSources } from './src/markdownPipeline.ts';
const processor = unified().use(remarkParse).use(remarkRehype).use(CHAT_MARKDOWN_REHYPE_PLUGINS);
for (const scheme of ['file', 'FILE']) {
  const markdown = `[link](${scheme}:///tmp/demo.png) ![](${scheme}:///tmp/demo.png)`;
  console.log(scheme, JSON.stringify(processor.runSync(processor.parse(markdown))), chatMarkdownImageSources(markdown));
}
JS

Observed: lowercase retains href and src and collects ["file:///tmp/demo.png"]; uppercase loses both targets and returns []. Expected: both retain href and src as file:///tmp/demo.png and collect the same source. The linked transcript includes an executable fixture for the real wordsHast renderer and collector.

Change

Extend the existing HTTP(S) scheme normalizer to lowercase file: before sanitizing link href and image src, dataDarkSrc, and dataLightSrc, preserving the rest of each URL. The shared pass covers web/desktop Words rendering and server image collection; native mobile uses its own renderer. Existing local-file classification and host-path checks remain in place. This is independent of providers and connection modes; no contracts, UI copy, entry points, or documentation change is needed.

Scope

Small fix for an obvious bug; no issue needed under CONTRIBUTING.md.

Verification

  • The regression failed on unmodified base: FILE:///tmp/demo.png yielded an image without src; the expanded Markdown/HTML link assertions received [{}, {}] instead of two href values.
  • vp test run packages/shared/src/markdownPipeline.test.ts: 3 consecutive passes, 29/29 tests each. The regression compares lowercase, uppercase, and mixed-case Markdown/HTML links and image sources, both theme variants, Windows paths, percent escapes, query/hash casing, and host URLs, with a disallowed-scheme control.
  • vp run check:changed: exit 0.
  • Real before/after Words WASM and shared collector transcript: uppercase and mixed-case links and images now match lowercase; disallowed JavaScript targets remain stripped.
  • Not shown: Real-client rendering or screenshots; actual filesystem image loading; remote/relay/tunnel asset transport; desktop shell/IPC; native mobile rendering; live provider turns. Evidence exercises the real parser and sanitizer directly with synthetic URLs.

Authored by GPT-6.1 Sol (Codex); reviewed by Gemini 4 Neon (Antigravity).

@github-actions github-actions Bot added vouch:trusted Author is trusted by repo permissions or the VOUCHED list. size:XS 0-9 changed lines (additions + deletions). labels Nov 26, 2026
@coderabbitai

coderabbitai Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The URL scheme normalizer now lowercases file schemes in image sources and anchor links. Tests cover Markdown and raw HTML URLs, dark and light picture sources, fallback images, and image-source extraction.

Changes: File URL Normalization

Layer / File(s) Summary
Normalize file schemes and test URL handling
packages/shared/src/markdownHast.ts, packages/shared/src/markdownPipeline.test.ts
The normalizer lowercases file schemes in image and anchor URL attributes. Tests cover uppercase FILE URLs in Markdown and raw HTML links, images, and picture sources. They also check image-source extraction.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Possibly related PRs

Suggested labels: bugfix

Suggested reviewers: juliusmarminge, macroscopeapp

Merge Risk: Minimal · up to b1b7c

Uppercase FILE: links and images now keep their URLs, matching lowercase file: behavior. The change is small, tested, and low risk to merge.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the actual change: uppercase FILE links and images in Markdown keep their URLs, which matches the scheme-lowercasing fix in markdownHast.ts and the FILE-scheme regression test. It foll…
Description check Passed The description follows the template: it has Problem, Change, Scope, and Verification sections, plus a model attribution line. Problem explains the uppercase FILE: bug with a reproduction. Change desc…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the actual change: uppercase FILE links and images in Markdown keep their URLs, which matches the scheme-lowercasing fix in markdownHast.ts and the FILE-scheme regression test. It follows conventional commit form and is specific, though at 74 characters it is slightly long.

Full details: Description check

Explanation

The description follows the template: it has Problem, Change, Scope, and Verification sections, plus a model attribution line. Problem explains the uppercase FILE: bug with a reproduction. Change describes the normalizer extension and its reach. Scope states it is a small obvious bug fix and explains why no issue is needed. Verification lists focused test runs, a regression failure on base, a linked transcript, and explicit untested areas. The template's preamble about CONTRIBUTING.md is not addressed by a checkbox, but the required content is present.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 1e23206 and b1b7c6a.

Files selected for processing: 1

  • packages/shared/src/markdownPipeline.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.

@juliusmarminge juliusmarminge added the takeover:in-progress A takeover lead is working on this PR label Nov 26, 2026
@juliusmarminge

Copy link
Copy Markdown
Member

Evidence

Replayed the reported lowercase, uppercase, and mixed-case file links/images and lowercase/uppercase themed pictures in fresh projects. Opened the same response at 1280×800 in light and dark mode. Base loses the affected link destinations and images; head retains destinations, loads all images, and preserves LIGHT/DARK variants. scenarios:prove exited 0.

Theme Before — 7068f98453 After — b1b7c6a91c
Light Before: unavailable uppercase and mixed-case images After: all images and LIGHT variants load
Dark Before: uppercase picture unavailable After: all images and DARK variants load

Scenario source · Before recording · After recording

Not shown:

  • Query and fragment casing preservation was not separately exercised; the reported reproduction uses plain PNG paths.

@juliusmarminge juliusmarminge added takeover:ready Takeover done; auto-lands when gates pass and removed takeover:in-progress A takeover lead is working on this PR labels Nov 27, 2026
@juliusmarminge
juliusmarminge merged commit 5478b88 into pingdotgg:main Nov 27, 2026
60 checks passed
@juliusmarminge juliusmarminge removed the takeover:ready Takeover done; auto-lands when gates pass label Nov 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XS 0-9 changed lines (additions + deletions). vouch:trusted Author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants