Skip to content

fix(ci): url-encode file paths in react-doctor comment links#2526

Open
pauldambra wants to merge 1 commit into
mainfrom
posthog-code/react-doctor-encode-link-path
Open

fix(ci): url-encode file paths in react-doctor comment links#2526
pauldambra wants to merge 1 commit into
mainfrom
posthog-code/react-doctor-encode-link-path

Conversation

@pauldambra

Copy link
Copy Markdown
Member

Problem

Follow-up to the markdown hardening in #2525 (merged before this could be folded in). Two PR review bots (chatgpt-codex, greptile) correctly flagged a gap: the comment renderer's fileLink sanitizes the link display text via inline(file), but the link URL target still interpolated the raw file path. A path containing an unbalanced ) — reasonably common in React codebases (e.g. Button(deprecated).tsx, or worse weird)name.tsx) — closes the GFM link early and leaks the remainder as visible text, which defeats the spoofing protection the hardening added.

Changes

react-doctor-comment.mjs: percent-encode each path segment in the markdown link target (encodedPath), including parens and spaces (encodeURIComponent leaves (/) literal, so they're encoded explicitly to %28/%29). Slashes are preserved as path separators. Display text is unchanged (still the readable, backtick/angle-bracket-stripped path).

How did you test this?

I'm an agent. Ran the renderer against a synthetic report with a path containing an unbalanced ) and a space (src/weird)name (x).tsx) and confirmed the URL renders as .../src/weird%29name%20%28x%29.tsx#L7 (link intact, nothing leaks), and ran Biome (biome ci) on the file.

Publish to changelog?

no


Created with PostHog Code

Follow-up to the markdown hardening in #2525. The link display text was
sanitized but the URL target still interpolated the raw file path, so a
path containing an unbalanced `)` (e.g. a React file with parens in its
name) could close the GFM link early and leak the remainder as visible
text -- defeating the spoofing protection. Percent-encode each path
segment (including parens and spaces) in the link target.

Generated-By: PostHog Code
Task-Id: ac09988a-6c71-4856-87d6-32b9e44b7684
@github-actions

github-actions Bot commented Jun 8, 2026

Copy link
Copy Markdown

React Doctor found no issues in the changed files. 🎉

Reviewed by React Doctor for commit bbb169b.

@greptile-apps

greptile-apps Bot commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Reviews (1): Last reviewed commit: "fix(ci): url-encode file paths in react-..." | Re-trigger Greptile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant