chkal/pf-issue-test — Issue #120: Quotes in parameter value cause an exception
Author: chkal
Created: 2012-03-06 07:39:15+00:00
State: open
Labels: Type-Defect

Originally filed by **brunoaranda** on 2011-09-19T10:46:25

Google Code issue: http://code.google.com/p/prettyfaces/issues/detail?id=122

What steps will reproduce the problem?
1. Create some pretty faces config, with a parameter, e.g.

/myPage.xhtml

2. Execute a URL with quotes in the parameter, e.g.

http://localhost/page/myquery:"partofquery"

3. An exception is thrown, by the com.ocpsoft.pretty.faces.url.URL class

PrettyFaces 3.3
JSF 2.1 (MyFaces)

The problem seems to be line 149 at https://github.com/ocpsoft/prettyfaces/blob/master/core/src/main/java/com/ocpsoft/pretty/faces/url/URL.java

When decoding the segment, spaces are encoded, but not other symbols like the quotes causing an exception. A quick fix is to encode the quotes. Line 149, in the decodeSegment method can be fixed from:

final URI uri = new URI(("http://localhost/" + segment).replace(" ", "%20"));

to

final URI uri = new URI(("http://localhost/" + segment).replace(" ", "%20").replace("\"", "%22"));