fix(router): fix = not parsed in router segment name#47332
fix(router): fix = not parsed in router segment name#47332DW8Reaper wants to merge 4 commits intoangular:mainfrom
Conversation
|
I did some testing in a sample app and when I have my routing configured as then it correctly loads TestComponent when I go to http://localhost;4200/another=test where previously it would have tried to got to a route another. There is one thing that may be unexpected and that is after routing completes the new URL will encode the = so the URL becomes http://localhost:4200/another%3Dtest (that route also works though if you try load it). So now I'm wondering if that result after loading the page should keep the = unencoded it kinda seems like it should any opinion on that? |
|
@DW8Reaper sorry for the delay on reviewing / merging this one. It is likely that this change introduces a breaking change so we need to run some internal tests and go over their results. |
|
Note: This is related to the internal issue b/234604699. These issues are related but actually solve distinctly separate parts of the parsing. The solution here parses We'll need to evaluate both scenarios and may want to include both in the single solution. The matrix proposal does not appear to take a stance on the |
|
@atscott I'd be happy to update mine if you can provide some details on where the other place was that this was changed on your side. Of course if it is simpler to just update things internally that makes sense to and then I can decline this PR |
|
@DW8Reaper I think essentially you just need to update |
|
Cool I can do that, not sure if you saw my other comment @atscott about it not preserving the = when the page navigation completes instead it the % escapes it. Should I see if I can fix that as well to make this more complete? |
I didn't see that. Yea, that seems like something we might want to address at the same time if possible. |
|
@atscott sorry that it took a while to update this PR but I have changed it so that if now will keep the = sign after routing in the URL bar of the browser |
1cbe11a to
34d8fc0
Compare
|
@atscott just following up is there anything else I need to do from my side for this PR? |
|
@DW8Reaper No, I'm just waiting to hear back about the results from the internal experiment. |
packages/router/src/url_tree.ts
Outdated
There was a problem hiding this comment.
As alluded to in #47332 (comment) we've got an internal bug using = in matrix parameter values that would be convenient to fix in this PR, all that's needed is to leave this line as calling matchSegments
That will also make it worth renaming matchMatrixParamSegments to add more precision, maybe something like matchMatrixKeySegment
packages/router/src/url_tree.ts
Outdated
There was a problem hiding this comment.
After some additional discussion with @atscott we think it would be better to leave this change for a separate PR, i.e. this PR will handle parsing = in router segments and leave them encoded (the same way = are currently handled in query parameters), and in a different PR we can look into leaving them unencoded (sorry for the back and forth!)
There was a problem hiding this comment.
Man I hope I got this straight I think all an all after you comments I was supposed to remove the URL encoding part then which I did by just reverting that whole second commit.
I wasn't sure if I was still supposed to remove the second call to matchMatrixParamSegments in the parseParam function from this comment:
As alluded to in #47332 (comment) we've got an internal bug using
=in matrix parameter values that would be convenient to fix in this PR, all that's needed is to leave this line as callingmatchSegmentsThat will also make it worth renaming
matchMatrixParamSegmentsto add more precision, maybe something likematchMatrixKeySegment
There was a problem hiding this comment.
Sorry for the delay! I was down with the flu
Yep these are the only changes left to do now:
- Change the second
matchMatrixParamSegmentscall tomatchSegments(which will let=be an allowed character in matrix parameter values) - With (1),
matchMatrixParamSegmentswill only be used for matrix keys so it is probably worth renaming it tomatchMatrixKeySegment - A test to cover the functionality mentioned in (1), I mentioned one option in this comment: https://github.com/angular/angular/pull/47332/files#r1029601032
After those I think the PR will be good to go!
There was a problem hiding this comment.
Cool I'll update it then but it'll probably only be in about 2 weeks I'm traveling and don't have my notebook with me
DW
34d8fc0 to
7bf9688
Compare
fix router segment name parsing to allow segements to container an unscaped = character. Currently if you have a url like /some-site/folder=/some-file then then middle segment "folder=" will stop parsing at the = sign and register that part of the path as just "folder" Fixes angular#21381
This reverts commit 2279f4d4620eba083a9832ed096890b69a25ec42. Reverting that commit based off PR feedback that this change should only affect the parsing of sergments and node encoding of the url
michaelgriscom
left a comment
There was a problem hiding this comment.
Looks great!
@atscott this looks ready to merge to me
|
@michaelgriscom Great, thanks for helping out on the review here! I'll take one last look and run a global presubmit |
|
This PR was merged into the repository by commit ee816e1. |
|
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |


fix router segment name parsing to allow segements to container an unscaped = character. Currently if you have a url like /some-site/folder=/some-file then then middle segment "folder=" will stop parsing at the = sign and register that part of the path as just "folder"
Fixes #21381
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
As outlined in this issue (#21381) when you have a url where a path segment contains an = character angular will parse that segment as only the characters before the =. For example password/de/MDAtMNTk= the last segment will be parsed in angular as only MDAtMNTk without the = character
Issue Number: 21381
What is the new behavior?
After this change you may include any number of = characters in a segment name and correspondingly define those as route paths in your route configuration.
Does this PR introduce a breaking change?
I think this PR could potentially be a breaking change since someone might have specifically handled cases where = was ignored by angular. Suppose they had path segments that were base 64 encoded strings for example IMz3bg==, those could possibly end with one or two = characters. It is therefore conceivable that someone might have implemented a workaround where if they received the id as IMz3bg they could infer based on the missing bit count that two == characters should be added. In that case if angular now accepted = their resource names could suddenly become IMz3bg====
A counter argument would be that if you had logic to determine the number of missing bits if angular now parsed the = there wouldn't be any missing bits and your logic would not trigger
Other information
Based off of comments in the issue here (#21381 (comment)) and (#21381 (comment)) I looked into RFC 3986 and RFC 1630 and it would seem that there isn't any specific limitation on using = in a segment name. Consider this excerpt from RFC 3986:
This seems to clearly indicate that you can use = and that is further substantiated by angulars special handling of matric parameters which uses the name;v=1.1 syntax from this excerpt