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 quarkusio#41060

Signed-off-by: Thomas Darimont <[email protected]>
(cherry picked from commit f244de0)
  • Loading branch information
thomasdarimont authored and gsmet committed Aug 7, 2024
1 parent aa08129 commit cfd538f
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 cfd538f

Please sign in to comment.