Skip to content

Commit d466fef

Browse files
committed
Ignore query parameters that are not correctly encoded - #88
1 parent 70a9a1f commit d466fef

2 files changed

Lines changed: 14 additions & 0 deletions

File tree

‎CHANGELOG.txt‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ Bugfixes:
66
* Fixed incorrect encoding of URLs when using the 'url' attribute for rewrite rules.
77
* MultiPageMessagesSupport doesn't duplicate messages any more if using MyFaces.
88
* Fixed potential NullPointerExceptions on FacesContext access.
9+
* Ignore query parameters that are not correctly encoded (#88)
10+
911

1012
------------------------------------
1113
VERSION 3.2.0

‎core/src/main/java/com/ocpsoft/pretty/faces/url/QueryString.java‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@
3030
import java.util.Map.Entry;
3131
import java.util.TreeMap;
3232

33+
import org.apache.commons.logging.Log;
34+
import org.apache.commons.logging.LogFactory;
35+
3336
import com.ocpsoft.pretty.PrettyException;
3437
import com.ocpsoft.pretty.faces.config.mapping.RequestParameter;
3538

@@ -38,6 +41,9 @@
3841
*/
3942
public class QueryString
4043
{
44+
45+
private final static Log log = LogFactory.getLog(QueryString.class);
46+
4147
private final Map<String, List<String>> parameters = new LinkedHashMap<String, List<String>>();
4248

4349
/**
@@ -244,6 +250,12 @@ public void addParameters(String url)
244250
name = URLDecoder.decode(pair.substring(0, pos), "UTF-8");
245251
value = URLDecoder.decode(pair.substring(pos + 1, pair.length()), "UTF-8");
246252
}
253+
catch (IllegalArgumentException e)
254+
{
255+
// thrown by URLDecoder if character decoding fails
256+
log.warn("Ignoring invalid query parameter: "+pair);
257+
continue;
258+
}
247259
catch (UnsupportedEncodingException e)
248260
{
249261
throw new PrettyException(

0 commit comments

Comments
 (0)