Skip to content

Commit f2e293a

Browse files
committed
UriComponents allows "+" in a query param
Issue: SPR-14828
1 parent 8703cdd commit f2e293a

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

spring-web/src/main/java/org/springframework/web/util/HierarchicalUriComponents.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,7 @@ public boolean isAllowed(int c) {
554554
QUERY_PARAM {
555555
@Override
556556
public boolean isAllowed(int c) {
557-
if ('=' == c || '+' == c || '&' == c) {
557+
if ('=' == c || '&' == c) {
558558
return false;
559559
}
560560
else {

spring-web/src/test/java/org/springframework/web/util/UriComponentsBuilderTests.java

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2016 the original author or authors.
2+
* Copyright 2002-2017 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -189,6 +189,14 @@ public void fromUriStringQueryParamWithReservedCharInValue() throws URISyntaxExc
189189
assertEquals("1USD=?EUR", result.getQueryParams().getFirst("q"));
190190
}
191191

192+
@Test // SPR-14828
193+
public void fromUriStringQueryParamEncodedAndContainingPlus() throws Exception {
194+
String httpUrl = "http://localhost:8080/test/print?value=%EA%B0%80+%EB%82%98";
195+
URI uri = UriComponentsBuilder.fromHttpUrl(httpUrl).build(true).toUri();
196+
197+
assertEquals(httpUrl, uri.toString());
198+
}
199+
192200
@Test // SPR-10779
193201
public void fromHttpUrlStringCaseInsesitiveScheme() {
194202
assertEquals("http", UriComponentsBuilder.fromHttpUrl("HTTP://www.google.com").build().getScheme());

0 commit comments

Comments
 (0)