Author: simoneg
Date: Tue Jan 5 14:03:36 2010
New Revision: 896041
URL: http://svn.apache.org/viewvc?rev=896041&view=rev
Log:
Decode the pathInfo from URL encoding
Modified:
labs/magma/trunk/foundation-website/src/main/java/org/apache/magma/website/Dispatch.java
labs/magma/trunk/foundation-website/src/test/java/org/apache/magma/website/DefaultExpectations.java
Modified:
labs/magma/trunk/foundation-website/src/main/java/org/apache/magma/website/Dispatch.java
URL:
http://svn.apache.org/viewvc/labs/magma/trunk/foundation-website/src/main/java/org/apache/magma/website/Dispatch.java?rev=896041&r1=896040&r2=896041&view=diff
==============================================================================
---
labs/magma/trunk/foundation-website/src/main/java/org/apache/magma/website/Dispatch.java
(original)
+++
labs/magma/trunk/foundation-website/src/main/java/org/apache/magma/website/Dispatch.java
Tue Jan 5 14:03:36 2010
@@ -27,7 +27,9 @@
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintStream;
+import java.io.UnsupportedEncodingException;
import java.lang.reflect.Method;
+import java.net.URLDecoder;
import java.util.HashMap;
import java.util.Map;
@@ -72,6 +74,15 @@
protected void handle(HttpServletRequest req, HttpServletResponse resp)
{
String pathInfo = req.getPathInfo();
+ String enc = req.getCharacterEncoding();
+ if (enc == null) enc = "UTF-8";
+ try {
+ pathInfo = URLDecoder.decode(pathInfo, enc);
+ } catch (UnsupportedEncodingException uee) {
+ try {
+ pathInfo = URLDecoder.decode(pathInfo, "UTF-8");
+ } catch (UnsupportedEncodingException uee2) {}
+ }
while (pathInfo.indexOf("//") != -1) {
pathInfo = pathInfo.replaceAll("//", "/");
}
Modified:
labs/magma/trunk/foundation-website/src/test/java/org/apache/magma/website/DefaultExpectations.java
URL:
http://svn.apache.org/viewvc/labs/magma/trunk/foundation-website/src/test/java/org/apache/magma/website/DefaultExpectations.java?rev=896041&r1=896040&r2=896041&view=diff
==============================================================================
---
labs/magma/trunk/foundation-website/src/test/java/org/apache/magma/website/DefaultExpectations.java
(original)
+++
labs/magma/trunk/foundation-website/src/test/java/org/apache/magma/website/DefaultExpectations.java
Tue Jan 5 14:03:36 2010
@@ -54,6 +54,7 @@
this.path = path;
allowing(req).getMethod(); will(returnValue("GET"));
allowing(req).getLocale(); will(returnValue(Locale.ITALY));
+ allowing(req).getCharacterEncoding();
will(returnValue("UTF-8"));
one(req).getPathInfo(); will(returnValue(path));
atMost(1).of(req).getContextPath(); will(returnValue("/app"));
atMost(1).of(req).getServletPath(); will(returnValue("/tests"));
@@ -86,6 +87,7 @@
public void setupMinimal(String path) throws IOException {
allowing(req).getMethod(); will(returnValue("GET"));
allowing(req).getLocale(); will(returnValue(Locale.ITALY));
+ allowing(req).getCharacterEncoding();
will(returnValue("UTF-8"));
one(req).getPathInfo(); will(returnValue(path));
allowing(req).getContextPath(); will(returnValue("/app"));
allowing(req).getServletPath(); will(returnValue("/tests"));
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]