Skip to content

fix(router-core): handle excessive parent relative links - #8018

Merged
Sheraff merged 1 commit into
mainfrom
fix-router-core-below-zero-relative-links
Aug 9, 2026
Merged

fix(router-core): handle excessive parent relative links#8018
Sheraff merged 1 commit into
mainfrom
fix-router-core-below-zero-relative-links

Conversation

@Sheraff

@Sheraff Sheraff commented Aug 9, 2026

Copy link
Copy Markdown
Collaborator

Summary by CodeRabbit

  • Bug Fixes

    • Improved relative path handling to keep navigation safely within the application root.
    • Correctly normalized empty, dot-prefixed, absolute, and parent-directory paths.
  • Tests

    • Added regression coverage for root traversal and potentially unsafe-looking URL segments.

@nx-cloud

nx-cloud Bot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

View your CI Pipeline Execution ↗ for commit 3de5c4c

Command Status Duration Result
nx affected --targets=test:eslint,test:unit,tes... ✅ Succeeded 12m 15s View ↗
nx run-many --target=build --exclude=examples/*... ✅ Succeeded 2m 18s View ↗

☁️ Nx Cloud last updated this comment at 2026-08-09 17:36:56 UTC

@github-actions

github-actions Bot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

🚀 Changeset Version Preview

No changeset entries found. Merging this PR will not cause a version bump for any packages.

@coderabbitai

coderabbitai Bot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: d2f6641a-d1b4-43d3-b5ac-d64b4721879f

📥 Commits

Reviewing files that changed from the base of the PR and between 6f8f534 and 3de5c4c.

📒 Files selected for processing (4)
  • packages/react-router/tests/link.test.tsx
  • packages/router-core/src/path.ts
  • packages/router-core/tests/build-location.test.ts
  • packages/router-core/tests/path.test.ts

📝 Walkthrough

Walkthrough

resolvePath now prevents relative traversal above the root and treats protocol-like text as pathname content. Regression tests cover path normalization, location building, and generated link hrefs.

Changes

Root-relative path resolution

Layer / File(s) Summary
Path resolution normalization
packages/router-core/src/path.ts, packages/router-core/tests/path.test.ts
resolvePath handles . directly, preserves root boundaries during .. traversal, and keeps javascript: and data: text in the pathname.
Navigation location validation
packages/router-core/tests/build-location.test.ts, packages/react-router/tests/link.test.tsx
Tests verify that over-root targets generate rooted pathname, href, and publicHref values.

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

Suggested reviewers: schiller-manuel

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the fix for relative links that traverse above the root, which is the main change in the pull request.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-router-core-below-zero-relative-links

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Bundle Size Benchmarks

  • Commit: f015e413d436
  • Measured at: 2026-08-09T17:25:46.193Z
  • Baseline source: history:6f8f534bf3a8
  • Dashboard: bundle-size history

The following scenarios have bundle-size changes compared with the baseline:

Scenario Current (gzip) Delta vs baseline Initial gzip Raw Brotli Trend
react-router.minimal 83.92 KiB +4 B (+0.00%) 83.78 KiB 262.68 KiB 73.02 KiB ██████▁▁▁▁▁▁
react-router.full 87.43 KiB +3 B (+0.00%) 87.29 KiB 274.40 KiB 76.04 KiB ██████▁▁▁▁▁▁
solid-router.minimal 33.24 KiB +3 B (+0.01%) 33.12 KiB 96.52 KiB 30.00 KiB ██████▁▁▁▁▁▁
solid-router.full 38.07 KiB +5 B (+0.01%) 37.94 KiB 111.15 KiB 34.28 KiB ██████▁▁▁▁▁▁
vue-router.minimal 49.53 KiB +1 B (+0.00%) 49.40 KiB 138.26 KiB 44.63 KiB ██████▁▁▁▁▁▁
vue-router.full 55.10 KiB +1 B (+0.00%) 54.98 KiB 156.44 KiB 49.64 KiB ██████▁▁▁▁▁▁
react-start.full 99.93 KiB +6 B (+0.01%) 99.79 KiB 314.61 KiB 86.59 KiB ██████▁▁▁▁▁▁
react-start.rsbuild.minimal 100.07 KiB +2 B (+0.00%) 99.90 KiB 315.45 KiB 86.30 KiB ▂▂▁▁▂▂▂▂▆███
react-start.rsbuild.minimal-iife 100.47 KiB +4 B (+0.00%) 100.31 KiB 316.38 KiB 86.67 KiB ▂▂▁▁▂▂▂▂▆███
react-start.rsbuild.full 103.39 KiB +4 B (+0.00%) 103.22 KiB 325.54 KiB 89.08 KiB ▂▂▁▁▃▃▃▃▆███
solid-start.minimal 46.01 KiB +1 B (+0.00%) 45.89 KiB 137.57 KiB 40.95 KiB ██████▁▁▁▁▁▁
solid-start.deferred-hydration 49.09 KiB +4 B (+0.01%) 45.95 KiB 145.04 KiB 43.69 KiB ██████▁▁▁▁▁▁
solid-start.full 51.09 KiB +3 B (+0.01%) 50.97 KiB 152.96 KiB 45.33 KiB ██████▁▁▁▁▁▁
vue-start.minimal 65.55 KiB +2 B (+0.00%) 65.42 KiB 189.08 KiB 58.40 KiB ██████▁▁▁▁▁▁
vue-start.full 69.38 KiB +4 B (+0.01%) 69.25 KiB 201.36 KiB 61.60 KiB ██████▁▁▁▁▁▁

Current gzip tracks all emitted client JS chunks. Initial gzip tracks only the entry/import graph. Trend sparkline is historical current gzip ending with this PR measurement; lower is better.

@pkg-pr-new

pkg-pr-new Bot commented Aug 9, 2026

Copy link
Copy Markdown
More templates

@tanstack/arktype-adapter

npm i https://pkg.pr.new/@tanstack/arktype-adapter@8018

@tanstack/eslint-plugin-router

npm i https://pkg.pr.new/@tanstack/eslint-plugin-router@8018

@tanstack/eslint-plugin-start

npm i https://pkg.pr.new/@tanstack/eslint-plugin-start@8018

@tanstack/history

npm i https://pkg.pr.new/@tanstack/history@8018

@tanstack/nitro-v2-vite-plugin

npm i https://pkg.pr.new/@tanstack/nitro-v2-vite-plugin@8018

@tanstack/react-router

npm i https://pkg.pr.new/@tanstack/react-router@8018

@tanstack/react-router-devtools

npm i https://pkg.pr.new/@tanstack/react-router-devtools@8018

@tanstack/react-router-ssr-query

npm i https://pkg.pr.new/@tanstack/react-router-ssr-query@8018

@tanstack/react-start

npm i https://pkg.pr.new/@tanstack/react-start@8018

@tanstack/react-start-client

npm i https://pkg.pr.new/@tanstack/react-start-client@8018

@tanstack/react-start-rsc

npm i https://pkg.pr.new/@tanstack/react-start-rsc@8018

@tanstack/react-start-server

npm i https://pkg.pr.new/@tanstack/react-start-server@8018

@tanstack/router-cli

npm i https://pkg.pr.new/@tanstack/router-cli@8018

@tanstack/router-core

npm i https://pkg.pr.new/@tanstack/router-core@8018

@tanstack/router-devtools

npm i https://pkg.pr.new/@tanstack/router-devtools@8018

@tanstack/router-devtools-core

npm i https://pkg.pr.new/@tanstack/router-devtools-core@8018

@tanstack/router-generator

npm i https://pkg.pr.new/@tanstack/router-generator@8018

@tanstack/router-plugin

npm i https://pkg.pr.new/@tanstack/router-plugin@8018

@tanstack/router-ssr-query-core

npm i https://pkg.pr.new/@tanstack/router-ssr-query-core@8018

@tanstack/router-utils

npm i https://pkg.pr.new/@tanstack/router-utils@8018

@tanstack/router-vite-plugin

npm i https://pkg.pr.new/@tanstack/router-vite-plugin@8018

@tanstack/solid-router

npm i https://pkg.pr.new/@tanstack/solid-router@8018

@tanstack/solid-router-devtools

npm i https://pkg.pr.new/@tanstack/solid-router-devtools@8018

@tanstack/solid-router-ssr-query

npm i https://pkg.pr.new/@tanstack/solid-router-ssr-query@8018

@tanstack/solid-start

npm i https://pkg.pr.new/@tanstack/solid-start@8018

@tanstack/solid-start-client

npm i https://pkg.pr.new/@tanstack/solid-start-client@8018

@tanstack/solid-start-server

npm i https://pkg.pr.new/@tanstack/solid-start-server@8018

@tanstack/start-client-core

npm i https://pkg.pr.new/@tanstack/start-client-core@8018

@tanstack/start-fn-stubs

npm i https://pkg.pr.new/@tanstack/start-fn-stubs@8018

@tanstack/start-plugin-core

npm i https://pkg.pr.new/@tanstack/start-plugin-core@8018

@tanstack/start-server-core

npm i https://pkg.pr.new/@tanstack/start-server-core@8018

@tanstack/start-static-server-functions

npm i https://pkg.pr.new/@tanstack/start-static-server-functions@8018

@tanstack/start-storage-context

npm i https://pkg.pr.new/@tanstack/start-storage-context@8018

@tanstack/valibot-adapter

npm i https://pkg.pr.new/@tanstack/valibot-adapter@8018

@tanstack/virtual-file-routes

npm i https://pkg.pr.new/@tanstack/virtual-file-routes@8018

@tanstack/vue-router

npm i https://pkg.pr.new/@tanstack/vue-router@8018

@tanstack/vue-router-devtools

npm i https://pkg.pr.new/@tanstack/vue-router-devtools@8018

@tanstack/vue-router-ssr-query

npm i https://pkg.pr.new/@tanstack/vue-router-ssr-query@8018

@tanstack/vue-start

npm i https://pkg.pr.new/@tanstack/vue-start@8018

@tanstack/vue-start-client

npm i https://pkg.pr.new/@tanstack/vue-start-client@8018

@tanstack/vue-start-server

npm i https://pkg.pr.new/@tanstack/vue-start-server@8018

@tanstack/zod-adapter

npm i https://pkg.pr.new/@tanstack/zod-adapter@8018

commit: 3de5c4c

@codspeed-hq

codspeed-hq Bot commented Aug 9, 2026

Copy link
Copy Markdown

Merging this PR will regress 0 benchmarks

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

⚡ 1 improved benchmark
❌ 2 (👁 2) regressed benchmarks
✅ 177 untouched benchmarks

Performance Changes

Mode Benchmark BASE HEAD Efficiency
Memory mem server error-paths not-found (vue) 1,808.8 KB 318.4 KB ×5.7
👁 Memory mem client navigation-churn (solid) 568.4 KB 636.6 KB -10.73%
👁 Memory mem client interrupted-navigations (react) 249.1 KB 281.1 KB -11.38%

Tip

Curious why this is faster? Comment @codspeedbot explain why this is faster on this PR, or directly use the CodSpeed MCP with your agent.


Comparing fix-router-core-below-zero-relative-links (3de5c4c) with main (6f8f534)

Open in CodSpeed

@Sheraff
Sheraff merged commit 5500fd3 into main Aug 9, 2026
26 checks passed
@Sheraff
Sheraff deleted the fix-router-core-below-zero-relative-links branch August 9, 2026 17:40
@coderabbitai coderabbitai Bot mentioned this pull request Aug 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant