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.
UriComponents stringPort = UriComponentsBuilder.fromUriString("http://localhost:port/path").build();
assertThat(stringPort.getScheme()).isEqualTo("http");
assertThat(stringPort.getHost()).isEqualTo("localhost");
assertThat(stringPort.getPath()).isEqualTo("/path");
// expected: "/path", but was "port/path"
'PORT' that is not captured is captured by'PATH_PATTERN'.
private static final String PATH_PATTERN = "([^?#]*)";
I have fixed this bug. Thank you.
Comment From: glqdlt
Sorry. I made a mistake. Corrected a typo in the PR title and commit message.
(before) Fix bug when 'UriComponentsBuilder#fromUriString()' port was not numer. (after) Fix bug when 'UriComponentsBuilder#fromUriString()' port was not number.
Comment From: glqdlt
Hello @rstoyanchev Sorry, there is a serious bug in this pull request. i fixed a bug (#26918), Could you please review it? Thank you.
Comment From: rstoyanchev
This has broken a Boot test case with a URL such as "http://localhost:52567?trace=false&message=false".
Comment From: rstoyanchev
@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.
Comment From: glqdlt
@rstoyanchev thank you very much for the comments.