[java-shib-shared] branch main updated: Open up query string handling to alternative encodings.
Scott Cantor
cantor.2 at osu.edu
Wed Oct 1 14:14:23 UTC 2025
This is an automated email from the git hooks/post-receive script.
scantor pushed a commit to branch main
in repository java-shib-shared.
View the commit online:
http://git.shibboleth.net/view/?p=java-shib-shared.git;a=commit;h=523a21abcfe422f4ebc762571a4f882007c7e2e7
The following commit(s) were added to refs/heads/main by this push:
new 523a21ab Open up query string handling to alternative encodings.
523a21ab is described below
commit 523a21abcfe422f4ebc762571a4f882007c7e2e7
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Wed Oct 1 10:14:20 2025 -0400
Open up query string handling to alternative encodings.
---
.../java/net/shibboleth/shared/net/URISupport.java | 48 +++++++++++++++++++---
1 file changed, 42 insertions(+), 6 deletions(-)
diff --git a/shib-networking/src/main/java/net/shibboleth/shared/net/URISupport.java b/shib-networking/src/main/java/net/shibboleth/shared/net/URISupport.java
index 14b044b8..bff4bed6 100644
--- a/shib-networking/src/main/java/net/shibboleth/shared/net/URISupport.java
+++ b/shib-networking/src/main/java/net/shibboleth/shared/net/URISupport.java
@@ -18,6 +18,7 @@ import java.net.URI;
import java.net.URISyntaxException;
import java.net.URLDecoder;
import java.net.URLEncoder;
+import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.HashMap;
@@ -374,18 +375,21 @@ public final class URISupport {
/**
* Parses a RFC-3968 encoded query string in to a set of name/value pairs. This method assumes the common query
- * string format of one or more 'paramName=paramValue' pairs separate by '&'. URL decoding of parameter names and values
- * is determined by the relevant arguments. Parameters without values will be represented in the returned map as a key associated with
- * the value <code>null</code>.
+ * string format of one or more 'paramName=paramValue' pairs separate by '&'. URL decoding of parameter
+ * names and values is determined by the relevant arguments. Parameters without values will be represented in the
+ * returned map as a key associated with the value <code>null</code>.
*
* @param queryString URL encoded query string
* @param decodeName whether the parameter names should be URL decoded in the returned list
* @param decodeValue whether the parameter values should be URL decoded in the returned list
+ * @param charset character encoding
*
* @return the parameters from the query string, never null
+ *
+ * @since 9.2.0
*/
@Nonnull @Live public static List<Pair<String, String>> parseQueryString(@Nullable final String queryString,
- final boolean decodeName, final boolean decodeValue) {
+ final boolean decodeName, final boolean decodeValue, @Nonnull final Charset charset) {
final String trimmedQuery = trimOrNullQuery(queryString);
if (trimmedQuery == null) {
@@ -407,6 +411,22 @@ public final class URISupport {
return queryParams;
}
+
+ /**
+ * Same as {@link #parseQueryString(String, boolean, boolean, Charset)} with the final parameter set
+ * to {@link StandardCharsets#UTF_8}.
+ *
+ * @param queryString URL encoded query string
+ * @param decodeName whether the parameter names should be URL decoded in the returned list
+ * @param decodeValue whether the parameter values should be URL decoded in the returned list
+ *
+ * @return the parameters from the query string, never null
+ */
+ @Nonnull @Live public static List<Pair<String, String>> parseQueryString(@Nullable final String queryString,
+ final boolean decodeName, final boolean decodeValue) {
+
+ return parseQueryString(queryString, decodeName, decodeValue, StandardCharsets.UTF_8);
+ }
/**
* Trims an RFC-3968 encoded URL path component. If the given path is null or empty then null is returned. If the
@@ -478,19 +498,35 @@ public final class URISupport {
return trimmedFragment;
}
+
/**
* Perform URL decoding on the given string.
*
* @param value the string to decode
+ * @param charset character encoding to apply
+ *
* @return the decoded string
+ *
+ * @since 9.2.0
*/
- @Nullable public static String doURLDecode(@Nullable final String value) {
+ @Nullable public static String doURLDecode(@Nullable final String value, @Nonnull final Charset charset) {
if (value == null) {
return null;
}
- return URLDecoder.decode(value, StandardCharsets.UTF_8);
+ return URLDecoder.decode(value, charset);
+ }
+
+ /**
+ * Perform URL decoding on the given string using UTF-8 as the encoding.
+ *
+ * @param value the string to decode
+ *
+ * @return the decoded string
+ */
+ @Nullable public static String doURLDecode(@Nullable final String value) {
+ return doURLDecode(value, StandardCharsets.UTF_8);
}
/**
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list