HTTP Interface client handles query param with ":"
Closes gh-34364
This commit is contained in:
parent
9f55296049
commit
d04883f839
|
@ -493,7 +493,7 @@ public class HttpRequestValues {
|
||||||
|
|
||||||
UriComponentsBuilder uriComponentsBuilder = UriComponentsBuilder.fromUriString(uriTemplate);
|
UriComponentsBuilder uriComponentsBuilder = UriComponentsBuilder.fromUriString(uriTemplate);
|
||||||
for (Map.Entry<String, List<String>> entry : requestParams.entrySet()) {
|
for (Map.Entry<String, List<String>> entry : requestParams.entrySet()) {
|
||||||
String nameVar = entry.getKey();
|
String nameVar = entry.getKey().replace(":", "%3A"); // suppress treatment as regex
|
||||||
uriVars.put(nameVar, entry.getKey());
|
uriVars.put(nameVar, entry.getKey());
|
||||||
for (int j = 0; j < entry.getValue().size(); j++) {
|
for (int j = 0; j < entry.getValue().size(); j++) {
|
||||||
String valueVar = nameVar + "[" + j + "]";
|
String valueVar = nameVar + "[" + j + "]";
|
||||||
|
|
|
@ -99,6 +99,24 @@ class HttpRequestValuesTests {
|
||||||
.isEqualTo("/path?param1=1st%20value¶m2=2nd%20value%20A¶m2=2nd%20value%20B");
|
.isEqualTo("/path?param1=1st%20value¶m2=2nd%20value%20A¶m2=2nd%20value%20B");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test // gh-34364
|
||||||
|
void queryParamWithSemicolon() {
|
||||||
|
HttpRequestValues requestValues = HttpRequestValues.builder().setHttpMethod(HttpMethod.POST)
|
||||||
|
.setUriTemplate("/path")
|
||||||
|
.addRequestParameter("userId:eq", "test value")
|
||||||
|
.build();
|
||||||
|
|
||||||
|
String uriTemplate = requestValues.getUriTemplate();
|
||||||
|
assertThat(uriTemplate).isEqualTo("/path?{userId%3Aeq}={userId%3Aeq[0]}");
|
||||||
|
|
||||||
|
URI uri = UriComponentsBuilder.fromUriString(uriTemplate)
|
||||||
|
.encode()
|
||||||
|
.build(requestValues.getUriVariables());
|
||||||
|
|
||||||
|
assertThat(uri.toString())
|
||||||
|
.isEqualTo("/path?userId%3Aeq=test%20value");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void queryParamsWithPreparedUri() {
|
void queryParamsWithPreparedUri() {
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue