File tree Expand file tree Collapse file tree 2 files changed +13
-1
lines changed
main/java/org/springframework/web/util
test/java/org/springframework/web/util Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -62,7 +62,7 @@ public class UriComponentsBuilder {
62
62
63
63
private static final String HTTP_PATTERN = "(?i)(http|https):" ;
64
64
65
- private static final String USERINFO_PATTERN = "([^@/ ]*)" ;
65
+ private static final String USERINFO_PATTERN = "([^@\\ [/?# ]*)" ;
66
66
67
67
private static final String HOST_IPV4_PATTERN = "[^\\ [/?#:]*" ;
68
68
Original file line number Diff line number Diff line change 26
26
27
27
import org .springframework .util .LinkedMultiValueMap ;
28
28
import org .springframework .util .MultiValueMap ;
29
+ import org .springframework .util .StringUtils ;
29
30
30
31
import static org .hamcrest .Matchers .*;
31
32
import static org .junit .Assert .*;
@@ -216,6 +217,17 @@ public void fromUriStringIPv6Host() throws URISyntaxException {
216
217
assertEquals ("[::192.168.1.1]" , resultIPv4compatible .getHost ());
217
218
}
218
219
220
+ // SPR-11970
221
+
222
+ @ Test
223
+ public void fromUriStringNoPathWithReservedCharInQuery () {
224
+ UriComponents result = UriComponentsBuilder .fromUriString ("http://example.com?foo=bar@baz" ).build ();
225
+ assertTrue (StringUtils .isEmpty (result .getUserInfo ()));
226
+ assertEquals ("example.com" , result .getHost ());
227
+ assertTrue (result .getQueryParams ().containsKey ("foo" ));
228
+ assertEquals ("bar@baz" , result .getQueryParams ().getFirst ("foo" ));
229
+ }
230
+
219
231
@ Test
220
232
public void path () throws URISyntaxException {
221
233
UriComponentsBuilder builder = UriComponentsBuilder .fromPath ("/foo/bar" );
You can’t perform that action at this time.
0 commit comments