You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by jb...@apache.org on 2007/09/05 17:07:33 UTC
svn commit: r572965 - in
/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http:
RequestUtils.java servlet/ServletWebRequest.java
Author: jbq
Date: Wed Sep 5 08:07:32 2007
New Revision: 572965
URL: http://svn.apache.org/viewvc?rev=572965&view=rev
Log:
Add new method RequestUtils.decode() to avoid checked exception
Modified:
wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/RequestUtils.java
wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/servlet/ServletWebRequest.java
Modified: wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/RequestUtils.java
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/RequestUtils.java?rev=572965&r1=572964&r2=572965&view=diff
==============================================================================
--- wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/RequestUtils.java (original)
+++ wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/RequestUtils.java Wed Sep 5 08:07:32 2007
@@ -22,6 +22,7 @@
import java.util.Arrays;
import java.util.List;
+import org.apache.wicket.WicketRuntimeException;
import org.apache.wicket.util.string.Strings;
import org.apache.wicket.util.value.ValueMap;
@@ -100,5 +101,22 @@
*/
private RequestUtils()
{
+ }
+
+ /**
+ * Does a URLDecoder.decode() in UTF-8
+ * @param servletPath
+ * @return
+ */
+ public static String decode(String path)
+ {
+ try
+ {
+ return URLDecoder.decode(path, "UTF-8");
+ }
+ catch (UnsupportedEncodingException e)
+ {
+ throw new WicketRuntimeException(e);
+ }
}
}
Modified: wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/servlet/ServletWebRequest.java
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/servlet/ServletWebRequest.java?rev=572965&r1=572964&r2=572965&view=diff
==============================================================================
--- wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/servlet/ServletWebRequest.java (original)
+++ wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/servlet/ServletWebRequest.java Wed Sep 5 08:07:32 2007
@@ -16,8 +16,6 @@
*/
package org.apache.wicket.protocol.http.servlet;
-import java.io.UnsupportedEncodingException;
-import java.net.URLDecoder;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
@@ -28,6 +26,7 @@
import org.apache.wicket.IRedirectListener;
import org.apache.wicket.RequestListenerInterface;
import org.apache.wicket.WicketRuntimeException;
+import org.apache.wicket.protocol.http.RequestUtils;
import org.apache.wicket.protocol.http.WebApplication;
import org.apache.wicket.protocol.http.WebRequest;
import org.apache.wicket.util.lang.Bytes;
@@ -156,15 +155,8 @@
String tmp = getRelativePathPrefixToWicketHandler();
PrependingStringBuffer prepender = new PrependingStringBuffer(tmp);
- String path;
- try
- {
- path = URLDecoder.decode(Strings.replaceAll(getPath(), "%3A", ":").toString(), "UTF-8");
- }
- catch (UnsupportedEncodingException e)
- {
- throw new WicketRuntimeException(e);
- }
+ String path = RequestUtils.decode(getPath());
+
if (path == null || path.length() == 0)
{
path = "";
@@ -176,18 +168,9 @@
String wicketPath = "";
// We're running as a filter.
- String servletPath;
- try
- {
- servletPath = URLDecoder.decode(Strings.replaceAll(getServletPath(), "%3A", ":")
- .toString(), "UTF-8");
- }
- catch (UnsupportedEncodingException e)
- {
- throw new WicketRuntimeException(e);
- }
+ String servletPath = RequestUtils.decode(getServletPath());
- // We need to substibute the %3A (or the other way around) to be able to
+ // We need to substitute the %3A (or the other way around) to be able to
// get a good match, as parts of the path may have been escaped while
// others arent
if (servletPath.endsWith(path))