HTTP Interface client handles query param with ":"

Closes gh-34364
This commit is contained in:
rstoyanchev 2025-02-11 11:08:00 +00:00
parent 9f55296049
commit d04883f839
2 changed files with 19 additions and 1 deletions

View File

@ -493,7 +493,7 @@ public class HttpRequestValues {
UriComponentsBuilder uriComponentsBuilder = UriComponentsBuilder.fromUriString(uriTemplate);
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());
for (int j = 0; j < entry.getValue().size(); j++) {
String valueVar = nameVar + "[" + j + "]";

View File

@ -99,6 +99,24 @@ class HttpRequestValuesTests {
.isEqualTo("/path?param1=1st%20value&param2=2nd%20value%20A&param2=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
void queryParamsWithPreparedUri() {