-
Notifications
You must be signed in to change notification settings - Fork 37.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
UriComponentsBuilder handles invalid port numbers correctly #26905
UriComponentsBuilder handles invalid port numbers correctly #26905
Conversation
4e11755
to
fd6659e
Compare
Sorry. I made a mistake. (before) Fix bug when 'UriComponentsBuilder#fromUriString()' port was not numer. |
Hello @rstoyanchev |
This has broken a Boot test case with a URL such as |
@glqdlt my apologies, I saw your comment but missed the fact you had opened a separate PR. For future reference, simply push your changes to the same branch in order to update the PR. |
@rstoyanchev thank you very much for the comments. |
This commit revisits the recently updated `PORT_PATTERN` in `UriComponentsBuilder`. The fix introduced in gh-26905 fails with ambiguous URL patterns, especially when the port and path parts of the pattern are hard to differentiate, for example "https://localhost:{port}{path}". This commit reinstates the previous behavior without undoing the actual fix. The only limitation introduced here is the fact that only a single pattern variable is allowed for the port pattern part. Fixes gh-27039
The pattern was changed in 65797d0 to check for characters up until "/", instead of for digits, but now also checks up until "?" and "#". Closes spring-projectsgh-26905
This commit revisits the recently updated `PORT_PATTERN` in `UriComponentsBuilder`. The fix introduced in spring-projectsgh-26905 fails with ambiguous URL patterns, especially when the port and path parts of the pattern are hard to differentiate, for example "https://localhost:{port}{path}". This commit reinstates the previous behavior without undoing the actual fix. The only limitation introduced here is the fact that only a single pattern variable is allowed for the port pattern part. Fixes spring-projectsgh-27039
The pattern was changed in 65797d0 to check for characters up until "/", instead of for digits, but now also checks up until "?" and "#". Closes spring-projectsgh-26905
This commit revisits the recently updated `PORT_PATTERN` in `UriComponentsBuilder`. The fix introduced in spring-projectsgh-26905 fails with ambiguous URL patterns, especially when the port and path parts of the pattern are hard to differentiate, for example "https://localhost:{port}{path}". This commit reinstates the previous behavior without undoing the actual fix. The only limitation introduced here is the fact that only a single pattern variable is allowed for the port pattern part. Fixes spring-projectsgh-27039
Hello.
Fixed a bug in the'UriComponentBuilder' class.
The bug occurs in'UriComponentBuilder#fromUriString()'.
A bug occurs when the port of the argument is not a number.
This issue occurs with the 'PORT_PATTERN' regular expression.
If port is not a number, the regular expression is not captured.
This is a good regex, but it causes problems.
You can check the issue in the test code below.
'PORT' that is not captured is captured by'PATH_PATTERN'.
private static final String PATH_PATTERN = "([^?#]*)";
I have fixed this bug.
Thank you.