Skip to content

Commit

Permalink
HTTP Interface client handles query param with ":"
Browse files Browse the repository at this point in the history
Closes gh-34364
  • Loading branch information
rstoyanchev committed Feb 11, 2025
1 parent 9f55296 commit d04883f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ private String appendQueryParams(

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 + "]";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,24 @@ void queryParamsWithUriTemplate() {
.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() {

Expand Down

0 comments on commit d04883f

Please sign in to comment.