Skip to content
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

Revisit fix for gh-26905 in UriComponentsBuilder #27039

Closed
bclozel opened this issue Jun 8, 2021 · 0 comments
Closed

Revisit fix for gh-26905 in UriComponentsBuilder #27039

bclozel opened this issue Jun 8, 2021 · 0 comments
Assignees
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: regression A bug that is also a regression
Milestone

Comments

@bclozel
Copy link
Member

bclozel commented Jun 8, 2021

The fix for gh-26905 introduced an unintended behavior change for some ambiguous URL patterns:

URI uri = UriComponentsBuilder
				.fromUriString("ws://localhost:{port}{path}")
				.buildAndExpand(7777, "/test")
				.toUri();

// Now fails because it's parsing "7777/test" as an integer port value.

While the fix for gh-26905 better warns against invalid port values, it now fails for ambiguous patterns and matches more than expected if a "/" is not present before variable expansion. We should refine the PORT_PATTERN and ensure that such use cases are still working.

@bclozel bclozel added in: web Issues in web modules (web, webmvc, webflux, websocket) type: regression A bug that is also a regression labels Jun 8, 2021
@bclozel bclozel added this to the 5.3.8 milestone Jun 8, 2021
@bclozel bclozel self-assigned this Jun 8, 2021
@bclozel bclozel closed this as completed in e35fe33 Jun 8, 2021
Zoran0104 pushed a commit to Zoran0104/spring-framework that referenced this issue Aug 20, 2021
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
lxbzmy pushed a commit to lxbzmy/spring-framework that referenced this issue Mar 26, 2022
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: regression A bug that is also a regression
Projects
None yet
Development

No branches or pull requests

1 participant