Issue Details (XML | Word | Printable)

Key: WICKET-40
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Critical Critical
Assignee: Jean-Baptiste Quenot
Reporter: Jan Bareš
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Wicket

Parameters of nice URL's pages with 'sensitive' characters

Created: 10/Nov/06 09:46 AM   Updated: 10/Jun/07 04:20 PM
Return to search
Component/s: wicket
Affects Version/s: 1.2.3
Fix Version/s: 1.3.0-beta2

Time Tracking:
Not Specified

File Attachments:
  Size
Text File Licensed for inclusion in ASF works 20070427-WICKET-40-WicketFilter-no-decoding.txt 2007-04-27 07:57 AM Jean-Baptiste Quenot 4 kB

Resolution Date: 06/May/07 08:01 PM


 Description  « Hide
Wicket uses HttpServletRequest.getPathInfo() to get the the URL. The returned string is already URL decoded, so when the request parameter pair contains %2F, it will be returned as '/', so the request pair will be broken (the same applies to other characters like '+' etc). This was cseen with Jetty 6 and Tomcat 5.5.
Wicket should use HttpServletRequest.getRequestURI() or getRequestURL() as this seems to return URL as it was passed to the server.

 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Eelco Hillenius added a comment - 31/Jan/07 07:57 AM
If you don't mind, here's another one for ya

Eelco Hillenius made changes - 31/Jan/07 07:57 AM
Field Original Value New Value
Assignee Alastair Maw [ almaw ]
Johan Compagner added a comment - 31/Jan/07 08:38 AM
this should be rewritten anyway.
Now it is a mess. We do encoding everywhere some & -> $amp; and then urlencode on params.
We should remove those everywhere. And use Request.encodeUrl or something like that
to really encode the url correctly at once.

Jean-Baptiste Quenot added a comment - 06/Mar/07 04:33 PM
Jan, can you please test it again after updating your SVN working copy. If you can still reproduce the problem, can you please be more specific and describe your usecase in details? Providing a quickstart, unit test or a patch can be useful. Thanks in advance!

Jan Bareš added a comment - 08/Mar/07 06:12 PM
I don't have the possibility to test fresh SVN copy now, but I tried on wicket-examples:
http://www.wicket-library.com/wicket-examples/niceurl/path/to/page2/param2/sla%2Fsh/param1/sss

The param2 should display "sla/sh" but instead wicket crashes.

Jean-Baptiste Quenot added a comment - 08/Mar/07 08:52 PM
What about this:

http://wicketstuff.org/wicket13/niceurl/path/to/page2/param2/sla%3Ash/param1/sss

Please use wicketstuff.org from now on for getting access to a running Wicket system.

Jean-Baptiste Quenot added a comment - 08/Mar/07 09:22 PM
I think we can close the issue now, I'm sure it has been fixed by WICKET-358

Jan Bareš added a comment - 09/Mar/07 07:32 AM
Thanks, I tried, but the problem still persist, please mind the %2F, which is '/' character, so the result should be "sla/sh". The ":" doesn't clash with parameters, but "/" does.

http://wicketstuff.org/wicket13/niceurl/path/to/page2/param2/sla%2Fsh/param1/sss

Jean-Baptiste Quenot added a comment - 09/Mar/07 08:33 AM
Using a slash in one of the parameter's key or value is another story because the URI is already decoded by the servlet container or web server. So it leads to unmatched key pair error because request.getURI() already returns a decoded URI like
/niceurl/path/to/page2/param2/sla/sh/param1/sss

You have to encode the encoded slash, like this:

http://localhost:8080/wicket-examples/niceurl/path/to/page2/param2/sla%252Fsh/param1/sss

On the older wicket snapshost, triple encode seems to be needed:

http://www.wicket-library.com/wicket-examples/niceurl/path/to/page2/param2/sla%25252Fsh/param1/sss

In other words, the servlet API does not offer a facility for parsing query parameters in this form using slashes, only using the query string beginning with "?" so you'd better avoid encoding slashes in the bookmarkable page parameters. Wicket does its best to parse the slashes-delimited query parameters, but it's far from being perfect.

Jan Bareš added a comment - 09/Mar/07 08:36 AM
Thanks for the explanation, you can close the issue.

Jean-Baptiste Quenot added a comment - 09/Mar/07 12:06 PM
Mmm actually, looking at the very description of this issue, you are right:

The Javadoc for getRequestURI() states that the URI is *not* decoded:
http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/servlet/http/HttpServletRequest.html#getRequestURI()

Whereas it is for getPathInfo(). So we may want to take a look at this issue, indeed.

Jean-Baptiste Quenot added a comment - 09/Mar/07 12:12 PM
So the culprit must be:


In ServletWebRequest I find:

public String getPath()
{
return ((WebApplication)Application.get()).getWicketFilter().getRelativePath(
httpServletRequest);
}

And in WicketFilter:

public String getRelativePath(HttpServletRequest request) {
String path = request.getServletPath();
                ...

So WicketFilter is the culprit, as getServletPath() decodes the URL, see:
http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/servlet/http/HttpServletRequest.html#getServletPath()

Jean-Baptiste Quenot added a comment - 27/Apr/07 07:57 AM
The attached patch changes the way WicketFilter computes the relative URL by avoiding by any means calling getServletPath() or getPathInfo(), only using getRequestURI(), getContextPath() and getServletPath().

There is also a temporary patch to wicket-examples to be able to reproduce the issue. Go to http://localhost:8080/wicket-examples/helloservlet/ for the servlet case and http://localhost:8080/wicket-examples/helloworld/ for the filter case.

Jean-Baptiste Quenot made changes - 27/Apr/07 07:57 AM
Jean-Baptiste Quenot added a comment - 27/Apr/07 08:17 AM
I also tested this patch successfully with:

* "/wicket-examples" servlet context path and /* servlet mapping
* "/wicket-examples" servlet context path and /* filter mapping
* "" servlet context path and /* servlet mapping
* "" servlet context path and /* filter mapping
* "" servlet context path and /helloservlet/* servlet mapping
* "" servlet context path and /helloworld/* filter mapping

Jean-Baptiste Quenot made changes - 27/Apr/07 08:21 AM
Priority Major [ 3 ] Critical [ 2 ]
Repository Revision Date User Message
ASF #534932 Thu May 03 16:47:54 UTC 2007 jbq * Adding httpunit-based tests for WICKET-40, rename bugTestXXX() to testXXX() to test the failing methods
* Allow to set custom webapp location and context path for JettyTestCaseDecorator
Files Changed
ADD /incubator/wicket/trunk/jdk-1.5/wicket-examples/src/main/testwebapp1
ADD /incubator/wicket/trunk/jdk-1.5/wicket-examples/src/test/java/org/apache/wicket/filtertest/WithoutCPWithoutFPTest.java
ADD /incubator/wicket/trunk/jdk-1.5/wicket-examples/src/test/java/org/apache/wicket/filtertest/WithCPWithoutFPTest.java
ADD /incubator/wicket/trunk/jdk-1.5/wicket-examples/src/main/testwebapp2
ADD /incubator/wicket/trunk/jdk-1.5/wicket-examples/src/test/java/org/apache/wicket/filtertest/Application.java
MODIFY /incubator/wicket/trunk/jdk-1.5/wicket-examples/src/test/java/org/apache/wicket/examples/JettyTestCaseDecorator.java
ADD /incubator/wicket/trunk/jdk-1.5/wicket-examples/src/main/testwebapp1/WEB-INF/web.xml
ADD /incubator/wicket/trunk/jdk-1.5/wicket-examples/src/test/java/org/apache/wicket/filtertest/HelloWorld.html
ADD /incubator/wicket/trunk/jdk-1.5/wicket-examples/src/main/testwebapp2/WEB-INF/web.xml
ADD /incubator/wicket/trunk/jdk-1.5/wicket-examples/src/main/testwebapp1/WEB-INF
ADD /incubator/wicket/trunk/jdk-1.5/wicket-examples/src/test/java/org/apache/wicket/filtertest/WithCPWithFPTest.java
ADD /incubator/wicket/trunk/jdk-1.5/wicket-examples/src/main/testwebapp2/WEB-INF
ADD /incubator/wicket/trunk/jdk-1.5/wicket-examples/src/test/java/org/apache/wicket/filtertest/WithoutCPWithFPTest.java
ADD /incubator/wicket/trunk/jdk-1.5/wicket-examples/src/test/java/org/apache/wicket/filtertest
ADD /incubator/wicket/trunk/jdk-1.5/wicket-examples/src/test/java/org/apache/wicket/filtertest/HelloWorld.java

Jean-Baptiste Quenot added a comment - 03/May/07 04:57 PM
Just added some httpunit-based unit tests in wicket-examples, see revision 534932. Just need to apply the patch to WicketFilter now and rename bugTestXXX() methods to testXXX()

Alastair Maw added a comment - 03/May/07 08:15 PM
I can see what you're trying to achieve with this, but it's breaking some unit tests in wicket-examples. I'm looking into fixing this right now.

Repository Revision Date User Message
ASF #535648 Sun May 06 19:56:43 UTC 2007 jbq MockHttpServletRequest#getRequestURI() is now more realistic, returns context path and servlet path concatenated

This is to avoid handling special cases in WICKET-40
Files Changed
MODIFY /incubator/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/link/IndexedParamUrlCodingTest.java
MODIFY /incubator/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/util/parse/metapattern/parsers/IndexedParamTest.java
MODIFY /incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/MockHttpServletRequest.java
MODIFY /incubator/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/request/target/coding/UrlMountingTest.java
MODIFY /incubator/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/stateless/StatelessComponentTest.java

Repository Revision Date User Message
ASF #535650 Sun May 06 20:00:38 UTC 2007 jbq WICKET-40 Parameters of nice URL's pages with 'sensitive' characters

Changes the way WicketFilter computes the relative URL by avoiding by any means
calling getPathInfo(), only using getRequestURI(), getContextPath() and
getServletPath(), as getPathInfo() decodes the URL thus breaking slash-delimited
parameters
Files Changed
MODIFY /incubator/wicket/trunk/jdk-1.5/wicket-examples/src/test/java/org/apache/wicket/filtertest/WithoutCPWithoutFPTest.java
MODIFY /incubator/wicket/trunk/jdk-1.5/wicket-examples/src/test/java/org/apache/wicket/filtertest/WithoutCPWithFPTest.java
MODIFY /incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/WicketFilter.java

Jean-Baptiste Quenot added a comment - 06/May/07 08:01 PM
WicketFilter changed, and tests fixed.

Jean-Baptiste Quenot made changes - 06/May/07 08:01 PM
Resolution Fixed [ 1 ]
Status Open [ 1 ] Resolved [ 5 ]
Assignee Alastair Maw [ almaw ] Jean-Baptiste Quenot [ jbq ]
Fix Version/s 1.3 [ 12312114 ]
Repository Revision Date User Message
ASF #535657 Sun May 06 21:13:43 UTC 2007 jbq WICKET-40 Parameters of nice URL's pages with 'sensitive' characters

Need to strip out jsessionid
Files Changed
MODIFY /incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/WicketFilter.java

Jean-Baptiste Quenot made changes - 10/Jun/07 04:20 PM
Fix Version/s trunk [ 12312514 ]
Fix Version/s 1.3.0-beta2 [ 12312502 ]