Skip to content

Commit

Permalink
Fix encoding of '?' in query parameter values by Encode.encodeQueryPa…
Browse files Browse the repository at this point in the history
…ram(..)

Previously `?` in query parameter values where encoded as is which caused
invalid URL values. We now replace `?` characters in query parameter values with
`%3F`.

Fixes #41060

Signed-off-by: Thomas Darimont <thomas.darimont@googlemail.com>
  • Loading branch information
thomasdarimont committed Jun 7, 2024
1 parent f17c985 commit 964b238
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 964b238

Please sign in to comment.