Skip to content

fix(server): resolve percent-encoded local favicon hrefs - #42314

Merged
juliusmarminge merged 2 commits into
pingdotgg:mainfrom
only21mil:fix/server-favicon-percent-decode
Nov 24, 2026
Merged

juliusmarminge merged 2 commits into
pingdotgg:mainfrom
only21mil:fix/server-favicon-percent-decode

Conversation

@only21mil

Copy link
Copy Markdown
Contributor

Problem

ProjectFaviconResolver reads <link rel="icon" href="..."> from index.html (and similar sources), strips the leading /, and stats the path still percent-encoded. A local href like href="/team%20mark.svg" never matches public/team mark.svg (the file a browser loads for that URL), so the project shows a monogram instead of its icon.

Reproduced on Linux, Node v26.13.1, base f99ef08bb8d.

Change

  • Decode local favicon hrefs in apps/server/src/project/ProjectFaviconResolver.ts (resolveIconHref) with the existing safeDecodeURIComponent helper from @t3tools/shared/markdownLinks. Malformed escapes like /100%.svg keep their raw text and resolve as before. A decoded NUL (%00) is skipped, since stat rejects it with an error rather than a miss. Decoded candidates still go through the existing workspace containment check, blocking %2e%2e traversal outside the project.
  • Extend existing unit tests in apps/server/src/project/ProjectFaviconResolver.test.ts: add percent-encoded (/team%20mark.svg) and malformed (/100%.svg) href checks plus a /a%00b.svg link in the existing list of "resolves icon hrefs from project source files", and update "skips icon metadata paths outside the workspace" to place real outside.svg files one and two levels up and check both a raw (../../outside.svg) and a percent-encoded (/%2e%2e%2f%2e%2e%2foutside.svg) link.

Scope

Small fix of an obvious local favicon resolution bug, so no issue is needed.

Verification

An AI agent ran all checks below.

Setup: Linux, Chromium web client, light theme, 1280x800, fresh isolated server data on each commit, a sample project whose index.html has <link rel="icon" href="/team%20mark.svg"> and a public/team mark.svg file, server named "Test machine".

Steps: add the sample project -> open the web app -> look at the project icon next to Team site in the thread header.

f99ef08 (before) 5dc5e0e (after)
f99ef08bb8d: Team site shows the "TS" monogram 5dc5e0e8eab: Team site shows its own icon from public/team mark.svg
f99ef08: Team site shows the "TS" monogram 5dc5e0e: Team site shows its own icon from public/team mark.svg
  • Resolver run on f99ef08bb8d vs 5dc5e0e8eab (Node v26.13.1): encoded (/team%20mark.svg, public/team mark.svg) returned null (monogram) on f99ef08bb8d and encoded/ws/public/team mark.svg on 5dc5e0e8eab; control (/team-mark.svg, public/team-mark.svg) resolved to control/ws/public/team-mark.svg and malformed (/100%.svg, public/100%.svg) resolved to malformed/ws/public/100%.svg on both; traversal (/%2e%2e/%2e%2e/outside.svg with ../outside.svg outside workspace) and NUL (/a%00b.svg) returned null (monogram) on both.
  • Regression test (apps/server/src/project/ProjectFaviconResolver.test.ts): fails on base f99ef08bb8d (1 failed | 14 passed (15)); passes 3 of 3 runs on 5dc5e0e8eab (15 passed (15)).
  • NUL-guard check: removing the NUL guard fails ProjectFaviconResolver.test.ts (1 failed | 14 passed (15)) with ProjectFaviconResolutionError during stat-candidate.
  • vp run check:changed: exit 0 (format, lint, knip 1/2, knip 2/2, graphql (apps/server), typecheck (3 packages), test (2 files); unused patch check skipped with no dependency files changed).

Not shown: desktop and mobile were not run separately; they show the same server-resolved icon.

Generated with Gemini 4 Neon in T3 Code Nightly

@github-actions github-actions Bot added vouch:unvouched Author is not yet trusted in the VOUCHED list. size:XS 0-9 changed lines (additions + deletions). labels Nov 24, 2026
@coderabbitai

coderabbitai Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 5dc5e0e and 52b5eab.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review

No actionable comments were generated in the recent review.

Walkthrough

The favicon resolver now decodes percent-encoded hrefs before file lookup and rejects decoded paths containing NUL. Tests cover encoded and malformed hrefs, NUL values, and traversal paths outside the workspace.

Changes: Favicon href resolution

Layer / File(s) Summary
Normalize and validate favicon hrefs
apps/server/src/project/ProjectFaviconResolver.ts, apps/server/src/project/ProjectFaviconResolver.test.ts
The resolver decodes hrefs after trimming whitespace and removing one leading slash. It returns no candidates when the decoded path contains NUL. Tests cover encoded spaces, malformed percent encoding, NUL hrefs, and traversal paths.

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

Change: Bug fix

Possibly related PRs

  • pingdotgg/t3code#42023: Changes href selection and candidate-path error handling in ProjectFaviconResolver, which uses the candidate flow that receives decoded hrefs here.
  • pingdotgg/t3code#42082: Strips query strings and fragments from favicon URLs before lookup; this normalization interacts with percent-decoding in this change.

Suggested reviewers: geezoria, macroscopeapp

Merge Risk: Minimal · previous review 5dc5e

Percent-encoded local favicon links such as team%20mark.svg now resolve to the matching file. Malformed escapes and traversal attempts keep their existing safe handling. No actionable merge risk remains.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title "fix(server): resolve percent-encoded local favicon hrefs" names the main change: local favicon hrefs are now percent-decoded before file lookup in ProjectFaviconResolver. It follows convent…
Description check Passed The description follows the template. It has Problem, Change, Scope, and Verification sections. Problem gives the bug, reproduction environment, and expected behavior. Change names the function, the r…
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 "fix(server): resolve percent-encoded local favicon hrefs" names the main change: local favicon hrefs are now percent-decoded before file lookup in ProjectFaviconResolver. It follows conventional commit format and matches the raw summary, the objectives, and the description.

Full details: Description check

Explanation

The description follows the template. It has Problem, Change, Scope, and Verification sections. Problem gives the bug, reproduction environment, and expected behavior. Change names the function, the reused helper, the NUL guard, and the containment check. Scope explains why no issue is linked and says it is a small obvious fix. Verification lists focused regression tests, a NUL-guard check, a passing check:changed run, and before/after screenshots, and it states what was not run (desktop and mobile). The template's PR-title line is a comment and is not required. The description does not link the issue or maintainer request, but the author gives a reason, which the template allows.

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 aaadc0c and 5dc5e0e.

Files selected for processing: 2

  • apps/server/src/project/ProjectFaviconResolver.test.ts
  • apps/server/src/project/ProjectFaviconResolver.ts

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

@juliusmarminge juliusmarminge added the takeover:in-progress A takeover lead is working on this PR label Nov 24, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@juliusmarminge

Copy link
Copy Markdown
Member

Evidence

Linux Chromium, 1280×800, light theme, fresh isolated databases, Replay (dev). Seed Team site with <link rel="icon" href="/team%20mark.svg"> and public/team mark.svg; seed Control site with the same SVG under an unencoded href. Open the control thread, then Team site's thread and inspect its breadcrumb icon.

Proven: the identical scenario fails on base and passes on head. Base shows the TS monogram; head shows the SVG. Control site displays its SVG on both sides.

Before — 6c0621f78a After — 52b5eab68f
Result ❌ Header image assertion failed ✅ Header image assertion passed
Team site favicon Before: TS monogram After: red-and-yellow SVG
Recording Before recording After recording

Scenario source

Not shown:

  • Malformed percent escapes, decoded NUL rejection, and decoded workspace traversal containment were not exercised in the real app; this scenario covers the reported percent-encoded space filename.

@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 24, 2026
@juliusmarminge
juliusmarminge merged commit 11c63a9 into pingdotgg:main Nov 24, 2026
55 checks passed
@juliusmarminge juliusmarminge removed the takeover:ready Takeover done; auto-lands when gates pass label Nov 24, 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:unvouched Author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants