fix(router): handle outlet named __proto__ when parsing url - #69501
Conversation
|
Thanks! Can you please also update the following in this same PR to use
|
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.
7b5c8a9 to
29641ba
Compare
|
Done. Switched all four to |
|
gentle ping |
|
caretaker note: presubmit is "green", this is good to go ! |
|
This pull request has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
PR Checklist
PR Type
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)makesUrlParser.parseParensassign aUrlSegmentGrouptosegments['__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/oneand reports a single child, and under Node started with--disable-proto=throwthe same parse throwsERR_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?
Other information