remm 01/01/30 11:41:54
Modified: catalina/src/share/org/apache/catalina/servlets
DefaultServlet.java
Log:
- Experimental patch : encode and decode the paths using UTF-8.
Revision Changes Path
1.23 +17 -32
jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/servlets/DefaultServlet.java
Index: DefaultServlet.java
===================================================================
RCS file:
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/servlets/DefaultServlet.java,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -r1.22 -r1.23
--- DefaultServlet.java 2001/01/30 03:50:08 1.22
+++ DefaultServlet.java 2001/01/30 19:41:50 1.23
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/servlets/DefaultServlet.java,v
1.22 2001/01/30 03:50:08 remm Exp $
- * $Revision: 1.22 $
- * $Date: 2001/01/30 03:50:08 $
+ * $Header:
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/servlets/DefaultServlet.java,v
1.23 2001/01/30 19:41:50 remm Exp $
+ * $Revision: 1.23 $
+ * $Date: 2001/01/30 19:41:50 $
*
* ====================================================================
*
@@ -113,6 +113,7 @@
import org.apache.catalina.Globals;
import org.apache.catalina.util.MD5Encoder;
import org.apache.catalina.util.StringManager;
+import org.apache.catalina.util.RequestUtil;
/**
@@ -121,7 +122,7 @@
*
* @author Craig R. McClanahan
* @author Remy Maucherat
- * @version $Revision: 1.22 $ $Date: 2001/01/30 03:50:08 $
+ * @version $Revision: 1.23 $ $Date: 2001/01/30 19:41:50 $
*/
public class DefaultServlet
@@ -858,37 +859,15 @@
if (path == null)
return null;
- String normalized = path;
-
// Resolve encoded characters in the normalized path,
// which also handles encoded spaces so we can skip that later.
// Placed at the beginning of the chain so that encoded
// bad stuff(tm) can be caught by the later checks
- while (true) {
- int index = normalized.indexOf("%");
- if (index < 0)
- break;
- char replaceChar;
- try {
- replaceChar = (char) (
- Short.parseShort(
- normalized.substring( index + 1, index + 3 ), 16
- )
- );
- } catch ( NumberFormatException nfe ) {
- return (null); // bad encoded characters in url
- }
- // check for control characters ( values 00-1f and 7f-9f),
- // return null if present. See:
- // http://www.unicode.org/charts/PDF/U0000.pdf
- // http://www.unicode.org/charts/PDF/U0080.pdf
- if ( Character.isISOControl( replaceChar ) ) {
- return (null);
- }
- normalized = normalized.substring(0, index) +
- replaceChar +
- normalized.substring(index + 3);
- }
+ String normalized = path;
+ if (normalized.indexOf('%') >= 0)
+ normalized = RequestUtil.URLDecode(normalized, "UTF-8");
+ if (normalized == null)
+ return (null);
// Normalize the slashes and add leading slash if necessary
if (normalized.indexOf('\\') >= 0)
@@ -950,7 +929,13 @@
int caseDiff = ('a' - 'A');
StringBuffer rewrittenPath = new StringBuffer(path.length());
ByteArrayOutputStream buf = new ByteArrayOutputStream(maxBytesPerChar);
- OutputStreamWriter writer = new OutputStreamWriter(buf);
+ OutputStreamWriter writer = null;
+ try {
+ writer = new OutputStreamWriter(buf, "UTF-8");
+ } catch (Exception e) {
+ e.printStackTrace();
+ writer = new OutputStreamWriter(buf);
+ }
for (int i = 0; i < path.length(); i++) {
int c = (int) path.charAt(i);
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]