Skip to content

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

Merged
juliusmarminge merged 3 commits into
pingdotgg:mainfrom
saphid:hunter/c-6fe3aa9571
Nov 26, 2026
Merged

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

Conversation

@saphid

@saphid saphid commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

Problem

Markdown links and images lose their targets when an author writes HTTPS: instead of https:. Words preserves that casing, but the shared HAST sanitizer checks allowed protocols case-sensitively; the image collector also drops these images.

Deterministic repro on origin/main (44a533378653164dea96435e23c8ea27efaffedb)

Fixture: [site](HTTPS://example.com/a.png) ![x](HTTPS://example.com/a.png).

Run the actual shared pre-sanitize passes and image collector from the repository root:

cd packages/shared
node --input-type=module <<'JS'
import { rehypePreserveImageSourceMeta, rehypeNormalizeLocalFileLinks, sanitizeChatHast } from './src/markdownHast.ts';
import { chatMarkdownImageSources } from './src/markdownPipeline.ts';
import { toHtml } from 'hast-util-to-html';
for (const scheme of ['https', 'HTTPS', 'JAVASCRIPT']) {
  const url = `${scheme}://example.com/a.png`;
  const tree = { type: 'root', children: [
    { type: 'element', tagName: 'a', properties: { href: url }, children: [{ type: 'text', value: 'site' }] },
    { type: 'element', tagName: 'img', properties: { src: url, alt: 'x' }, children: [] }
  ] };
  rehypePreserveImageSourceMeta()(tree);
  rehypeNormalizeLocalFileLinks()(tree);
  console.log(scheme, toHtml(sanitizeChatHast(tree)), chatMarkdownImageSources(`![x](${url})`));
}
JS

Observed: the uppercase HTTPS row yields <a>site</a><img alt="x"> and []; lowercase retains both targets. Expected: both HTTPS rows retain href and src as https://example.com/a.png and collect one image source; JavaScript remains stripped.

Change

Lowercase only the HTTP(S) scheme in anchor targets and image sources before sanitization, including theme-specific picture sources. The URL remainder and protocol allowlist stay intact. Both web/desktop Words rendering and shared Markdown image collection use these passes; native mobile has its own renderer and needs no change here.

Scope

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

Verification

  • Added one regression case to the existing lowest-layer shared pipeline test file. On base, vp test run packages/shared/src/markdownPipeline.test.ts -t "preserves HTTP" failed: HTTPS: expected undefined to be 'https://Example.com/A%2Fb.png?Key=Value#Part'.
  • vp test run packages/shared/src/markdownPipeline.test.ts passed 3 consecutive times (26/26 each), covering lowercase, uppercase and mixed-case HTTP(S), image theme sources, URL remainder preservation, and disallowed schemes alongside existing local-file cases.
  • vp run check:changed: exit 0.
  • Before/after runtime transcript and executable fixture: uppercase HTTP(S) targets and collected images survive after the fix; JavaScript still does not.
  • Not shown: Real-client rendering or screenshots; desktop shell/IPC; native mobile rendering; image network fetching; live provider turns. Evidence exercises the shared parser/sanitizer directly.

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:S 10-29 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 Markdown HAST pipeline now lowercases HTTP(S) schemes in image source properties and anchor links before further processing. A test covers mixed-case HTTP(S) and JavaScript schemes across these properties.

Changes: Markdown URL normalization

Layer / File(s) Summary
Normalize URL schemes and test sanitization
packages/shared/src/markdownHast.ts, packages/shared/src/markdownPipeline.test.ts
A helper lowercases HTTP(S) schemes without changing the rest of the URL. Image source properties and anchor links use this helper. The test checks mixed-case HTTP(S) and JavaScript schemes after pipeline processing and sanitization.

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

Change: Bug fix

Suggested reviewers: juliusmarminge

Merge Risk: Minimal · up to 0e1e1

Markdown links and images with uppercase HTTPS: schemes will now render instead of being stripped. The change is small and low risk, and it is covered by a regression test.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the change: Markdown links and images with uppercase HTTPS URLs keep their URLs. The raw summary confirms the change lowercases the http/https scheme in image sources and anchor hrefs …
Description check Passed The description follows the repository template. It has Problem, Change, Scope, and Verification sections, and each is filled with specific content. The Problem section gives a reproduction and expect…
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 change: Markdown links and images with uppercase HTTPS URLs keep their URLs. The raw summary confirms the change lowercases the http/https scheme in image sources and anchor hrefs before sanitization, and adds a regression test. The title uses the conventional commit format and is specific. It is a single sentence, 75 characters, and does not use vague terms.

Full details: Description check

Explanation

The description follows the repository template. It has Problem, Change, Scope, and Verification sections, and each is filled with specific content. The Problem section gives a reproduction and expected behavior. The Change section explains the scheme lowercasing and the scope of platforms affected. The Scope section explains why no issue is linked. The Verification section lists focused test runs, the base-branch failure, the check command result, and what was not verified. The description does not state the model and harness used by the agent, which the template asks for when an agent was used. The author did include a model attribution line at the end, so this is covered. The description has a few minor template-following gaps, but it is mostly complete.

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 23c793c and 0e1e134.

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

Render the reported Markdown links and images in a Replay assistant response, alongside themed picture sources and JavaScript controls. Open the same seeded thread on each commit and capture Chromium at 1280×800 in both themes.

Proven: uppercase/mixed-case links lose their destinations and uppercase/themed images fail on base; all work on head. JavaScript destinations remain stripped.

Environment Before — d6061ec8ad After — 0e1e134fff
Web, dark, 1280×800 Before: uppercase and themed images unavailable; uppercase links lack favicons After: all HTTPS links and images render correctly
Web, light, 1280×800 Before: uppercase and themed images unavailable in light theme After: HTTPS links and images work in light theme

Scenario source

Not shown:

  • Desktop shell and mobile clients were not exercised; this proof covers the real web client.
  • Theme-specific rendering was captured in both themes, but identical source images do not independently prove which picture source was selected.

@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 26, 2026
@juliusmarminge
juliusmarminge merged commit 40958c3 into pingdotgg:main Nov 26, 2026
60 checks passed
@juliusmarminge juliusmarminge removed the takeover:ready Takeover done; auto-lands when gates pass label Nov 26, 2026
github-actions Bot pushed a commit to Ryoku-dev/hyakki that referenced this pull request Nov 26, 2026
…r URLs (pingdotgg#43685)

Co-authored-by: SAPHID <saphid@users.noreply.github.com>
Co-authored-by: Julius Marminge <julius0216@outlook.com>
(cherry picked from commit 40958c3)
github-actions Bot pushed a commit to Ryoku-dev/hyakki that referenced this pull request Nov 26, 2026
…r URLs (pingdotgg#43685)

Co-authored-by: SAPHID <saphid@users.noreply.github.com>
Co-authored-by: Julius Marminge <julius0216@outlook.com>
(cherry picked from commit 40958c3)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:S 10-29 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