This is an automated email from the ASF dual-hosted git repository.
markt pushed a commit to branch 10.1.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/10.1.x by this push:
new 1ad4013340 Support parsing multiple path parameters in a single URL
segment.
1ad4013340 is described below
commit 1ad40133401c22bc5de5165381e640a8b7806ad7
Author: Mark Thomas <[email protected]>
AuthorDate: Tue May 27 09:24:22 2025 +0100
Support parsing multiple path parameters in a single URL segment.
Parameters separated by ';'
Based on #860 by Chenjp.
---
java/org/apache/catalina/util/RequestUtil.java | 23 ++++++++++++----------
.../TestApplicationContextStripPathParams.java | 4 ++++
webapps/docs/changelog.xml | 5 +++++
3 files changed, 22 insertions(+), 10 deletions(-)
diff --git a/java/org/apache/catalina/util/RequestUtil.java
b/java/org/apache/catalina/util/RequestUtil.java
index 36f5f072a6..bc123387cb 100644
--- a/java/org/apache/catalina/util/RequestUtil.java
+++ b/java/org/apache/catalina/util/RequestUtil.java
@@ -60,8 +60,10 @@ public final class RequestUtil {
/**
* Strip parameters for given path.
- * @param input the input path
+ *
+ * @param input the input path
* @param request the request to add the parameters to
+ *
* @return the cleaned path
*/
public static String stripPathParams(String input, Request request) {
@@ -85,19 +87,20 @@ public final class RequestUtil {
} else {
pos = followingSlash;
}
- if (request != null && nextSemiColon + 1 <pos) {
- String pathVariable = input.substring(nextSemiColon + 1, pos);
- int equals = pathVariable.indexOf('=');
- if (equals > -1 && equals + 1 < pathVariable.length()) {
- String name = pathVariable.substring(0, equals);
- String value = pathVariable.substring(equals + 1);
- request.addPathParameter(name, value);
+ if (request != null && nextSemiColon + 1 < pos) {
+ String pathVariablesString = input.substring(nextSemiColon +
1, pos);
+ String[] pathVariables = pathVariablesString.split(";");
+ for (String pathVariable : pathVariables) {
+ int equals = pathVariable.indexOf('=');
+ if (equals > -1 && equals + 1 < pathVariable.length()) {
+ String name = pathVariable.substring(0, equals);
+ String value = pathVariable.substring(equals + 1);
+ request.addPathParameter(name, value);
+ }
}
}
}
return sb.toString();
}
-
-
}
diff --git
a/test/org/apache/catalina/core/TestApplicationContextStripPathParams.java
b/test/org/apache/catalina/core/TestApplicationContextStripPathParams.java
index 3d8a52b7e1..3739770644 100644
--- a/test/org/apache/catalina/core/TestApplicationContextStripPathParams.java
+++ b/test/org/apache/catalina/core/TestApplicationContextStripPathParams.java
@@ -62,6 +62,10 @@ public class TestApplicationContextStripPathParams extends
TomcatBaseTest {
{ ";/foo;=/bar", "/foo/bar", Boolean.FALSE },
{ ";/foo;a=/bar", "/foo/bar", Boolean.FALSE },
{ ";/foo;=1/bar", "/foo/bar", Boolean.FALSE },
+ { "/foo;a=1;b=1/bar", "/foo/bar", Boolean.TRUE },
+ { ";/foo;a=1;b=1/bar", "/foo/bar", Boolean.TRUE },
+ { "/foo;b=1;a=1/bar", "/foo/bar", Boolean.TRUE },
+ { ";/foo;b=1;a=1/bar", "/foo/bar", Boolean.TRUE },
});
}
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index c00031277d..748b14a55e 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -111,6 +111,11 @@
Add support for the <code>java:module</code> namespace which mirrors
the <code>java:comp</code> namespace. (markt)
</fix>
+ <fix>
+ Support parsing of multiple path parameters separated by <code>;</code>
+ in a single URL segment. Based on pull request <pr>860</pr> by Chenjp.
+ (markt)
+ </fix>
</changelog>
</subsection>
<subsection name="Jasper">
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]