Skip to content

fix(router): handle outlet named __proto__ when parsing url - #69501

Merged
leonsenft merged 1 commit into
angular:mainfrom
arshsmith1:router-proto-outlet-name
Jul 6, 2026
Merged

fix(router): handle outlet named __proto__ when parsing url#69501
leonsenft merged 1 commit into
angular:mainfrom
arshsmith1:router-proto-outlet-name

Conversation

@arshsmith1

Copy link
Copy Markdown
Contributor

PR Checklist

PR Type

  • Bugfix

What is the current behavior?

Issue Number: N/A

A named outlet in a url group like /(name:child) is read verbatim from the url, so a url such as /one(__proto__:two) makes UrlParser.parseParens assign a UrlSegmentGroup to segments['__proto__']. On a plain object that assignment goes through the inherited __proto__ setter instead of creating an outlet, so the outlet is silently dropped and the map's prototype is replaced. url.parse('/one(__proto__:two)') therefore round-trips back to /one and reports a single child, and under Node started with --disable-proto=throw the same parse throws ERR_PROTO_ACCESS.

What is the new behavior?

The outlet map is built with Object.create(null), so __proto__ is treated as an ordinary key. The outlet is kept, the prototype is left untouched, and /one(__proto__:two) serializes back unchanged.

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

@pullapprove
pullapprove Bot requested a review from atscott June 24, 2026 16:50
@ngbot ngbot Bot added this to the Backlog milestone Jun 24, 2026
@atscott

atscott commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Thanks! Can you please also update the following in this same PR to use Object.create(null) instead of {} and update the commit message to reflect these changes?

  1. squashSegmentGroup in packages/router/src/url_tree.ts (line 841)
  2. createSegmentGroup in packages/router/src/apply_redirects.ts (line 145)
  3. replaceSegment in packages/router/src/create_url_tree.ts (line 228)
  4. updateSegmentGroupChildren in packages/router/src/create_url_tree.ts (line 422)

Outlet maps are keyed by names read verbatim from the url, so a name like
`__proto__` (e.g. `/one(__proto__:two)`) is assigned through the inherited
`__proto__` setter instead of creating an outlet. This drops the outlet and
mutates the map's prototype, and throws under Node's `--disable-proto=throw`.

Build these outlet maps with `Object.create(null)` so `__proto__` is treated as
an ordinary key. Covers `parseParens` and `squashSegmentGroup` in url_tree.ts,
`createSegmentGroup` in apply_redirects.ts, and `replaceSegment` and
`updateSegmentGroupChildren` in create_url_tree.ts.
@arshsmith1
arshsmith1 force-pushed the router-proto-outlet-name branch from 7b5c8a9 to 29641ba Compare June 25, 2026 07:20
@arshsmith1

Copy link
Copy Markdown
Contributor Author

Done. Switched all four to Object.create(null) (squashSegmentGroup, createSegmentGroup, replaceSegment, and updateSegmentGroupChildren) and updated the commit message to cover them. They're all keyed by outlet names so the same __proto__ issue applies.

@arshsmith1

Copy link
Copy Markdown
Contributor Author

gentle ping

@atscott
atscott requested a review from JeanMeche July 6, 2026 15:08
@JeanMeche
JeanMeche removed the request for review from atscott July 6, 2026 15:19
@JeanMeche JeanMeche added action: merge The PR is ready for merge by the caretaker target: patch This PR is targeted for the next patch release merge: caretaker note Alert the caretaker performing the merge to check the PR for an out of normal action needed or note labels Jul 6, 2026
@JeanMeche

Copy link
Copy Markdown
Member

caretaker note: presubmit is "green", this is good to go !

@leonsenft
leonsenft merged commit cbbb1d8 into angular:main Jul 6, 2026
24 of 26 checks passed
@leonsenft

Copy link
Copy Markdown
Contributor

This PR was merged into the repository. The changes were merged into the following branches:

@angular-automatic-lock-bot

Copy link
Copy Markdown

This pull request has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot Bot locked and limited conversation to collaborators Aug 6, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

action: merge The PR is ready for merge by the caretaker area: router merge: caretaker note Alert the caretaker performing the merge to check the PR for an out of normal action needed or note target: patch This PR is targeted for the next patch release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants