Skip to content

Commit

Permalink
Merge pull request #41062 from thomasdarimont/issue/gh-41060-fix-inva…
Browse files Browse the repository at this point in the history
…lid-query-param-encoding

Fix encoding of '?' in query parameter values by Encode.encodeQueryParam(..)
  • Loading branch information
geoand committed Jun 8, 2024
2 parents b27a39b + f244de0 commit ec7291d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,9 @@ public class Encode {
case '.':
case '_':
case '~':
continue;
case '?':
queryNameValueEncoding[i] = "%3F";
continue;
case ' ':
queryNameValueEncoding[i] = "+";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,11 @@ void encodeEmoji() {
assertEquals(encodedEmoji, Encode.encodePath(emoji));
assertEquals(encodedEmoji, Encode.encodeQueryParam(emoji));
}

@Test
void encodeQuestionMarkQueryParameterValue() {
String uriQueryValue = "bar?a=b";
String encoded = URLEncoder.encode(uriQueryValue, StandardCharsets.UTF_8);
assertEquals(encoded, Encode.encodeQueryParam(uriQueryValue));
}
}

0 comments on commit ec7291d

Please sign in to comment.