Updated Branches: refs/heads/wicket-1.5.x fb6330bc4 -> f7b4df17f
WICKET-5157 URL query parameter values containing equals sign get cut off Project: http://git-wip-us.apache.org/repos/asf/wicket/repo Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/f7b4df17 Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/f7b4df17 Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/f7b4df17 Branch: refs/heads/wicket-1.5.x Commit: f7b4df17fe757a138dc2212f37a2af1c2c96c630 Parents: fb6330b Author: Martin Tzvetanov Grigorov <mgrigo...@apache.org> Authored: Fri Apr 26 14:57:08 2013 +0200 Committer: Martin Tzvetanov Grigorov <mgrigo...@apache.org> Committed: Fri Apr 26 14:57:08 2013 +0200 ---------------------------------------------------------------------- .../main/java/org/apache/wicket/request/Url.java | 9 +++++---- .../java/org/apache/wicket/request/UrlTest.java | 14 ++++++++++++++ 2 files changed, 19 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/wicket/blob/f7b4df17/wicket-request/src/main/java/org/apache/wicket/request/Url.java ---------------------------------------------------------------------- diff --git a/wicket-request/src/main/java/org/apache/wicket/request/Url.java b/wicket-request/src/main/java/org/apache/wicket/request/Url.java index f2d4394..e47142a 100755 --- a/wicket-request/src/main/java/org/apache/wicket/request/Url.java +++ b/wicket-request/src/main/java/org/apache/wicket/request/Url.java @@ -97,15 +97,16 @@ public class Url implements Serializable */ private static QueryParameter parseQueryParameter(final String qp, final Charset charset) { - if (qp.indexOf('=') == -1) + int idxOfEquals = qp.indexOf('='); + if (idxOfEquals == -1) { // name => empty value return new QueryParameter(decodeParameter(qp, charset), ""); } - String parts[] = Strings.split(qp, '='); - return new QueryParameter(decodeParameter(parts[0], charset), decodeParameter(parts[1], - charset)); + String parameterName = qp.substring(0, idxOfEquals); + String parameterValue = qp.substring(idxOfEquals + 1); + return new QueryParameter(decodeParameter(parameterName, charset), decodeParameter(parameterValue, charset)); } /** http://git-wip-us.apache.org/repos/asf/wicket/blob/f7b4df17/wicket-request/src/test/java/org/apache/wicket/request/UrlTest.java ---------------------------------------------------------------------- diff --git a/wicket-request/src/test/java/org/apache/wicket/request/UrlTest.java b/wicket-request/src/test/java/org/apache/wicket/request/UrlTest.java index 09e6b93..617938b 100644 --- a/wicket-request/src/test/java/org/apache/wicket/request/UrlTest.java +++ b/wicket-request/src/test/java/org/apache/wicket/request/UrlTest.java @@ -816,4 +816,18 @@ public class UrlTest extends Assert url.toString(StringMode.FULL); } + /** + * Should accept parameter values containing equals sign(s) + * https://issues.apache.org/jira/browse/WICKET-5157 + */ + @Test + public void parseQueryStringWithEqualsSignInParameterValue() + { + String s = "/?a=b=c&d=e=f"; + Url url = Url.parse(s); + assertTrue(url.isAbsolute()); + checkSegments(url, "", ""); + checkQueryParams(url, "a", "b=c", "d", "e=f"); + } + }