Author: markt
Date: Sat Aug  4 09:17:22 2007
New Revision: 562736

URL: http://svn.apache.org/viewvc?view=rev&rev=562736
Log:
Port fix for bug 42944. + should only decoded to space in query strings.

Modified:
    tomcat/tc6.0.x/trunk/java/org/apache/catalina/util/RequestUtil.java
    tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml

Modified: tomcat/tc6.0.x/trunk/java/org/apache/catalina/util/RequestUtil.java
URL: 
http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/catalina/util/RequestUtil.java?view=diff&rev=562736&r1=562735&r2=562736
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/catalina/util/RequestUtil.java 
(original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/catalina/util/RequestUtil.java Sat Aug 
 4 09:17:22 2007
@@ -187,7 +187,7 @@
      * Decode and return the specified URL-encoded String.
      * When the byte array is converted to a string, the system default
      * character encoding is used...  This may be different than some other
-     * servers.
+     * servers. It is assumed the string is not a query string.
      *
      * @param str The url-encoded string
      *
@@ -195,14 +195,13 @@
      * by a valid 2-digit hexadecimal number
      */
     public static String URLDecode(String str) {
-
         return URLDecode(str, null);
-
     }
-
-
+    
+    
     /**
-     * Decode and return the specified URL-encoded String.
+     * Decode and return the specified URL-encoded String. It is assumed the
+     * string is not a query string.
      *
      * @param str The url-encoded string
      * @param enc The encoding to use; if null, the default encoding is used
@@ -210,7 +209,19 @@
      * by a valid 2-digit hexadecimal number
      */
     public static String URLDecode(String str, String enc) {
-
+        return URLDecode(str, enc, false);
+    }
+    
+    /**
+     * Decode and return the specified URL-encoded String.
+     *
+     * @param str The url-encoded string
+     * @param enc The encoding to use; if null, the default encoding is used
+     * @param isQuery Is this a query string being processed
+     * @exception IllegalArgumentException if a '%' character is not followed
+     * by a valid 2-digit hexadecimal number
+     */
+    public static String URLDecode(String str, String enc, boolean isQuery) {
         if (str == null)
             return (null);
 
@@ -226,13 +237,14 @@
             }
         } catch (UnsupportedEncodingException uee) {}
 
-        return URLDecode(bytes, enc);
+        return URLDecode(bytes, enc, isQuery);
 
     }
 
 
     /**
-     * Decode and return the specified URL-encoded byte array.
+     * Decode and return the specified URL-encoded byte array. It is assumed
+     * the string is not a query string.
      *
      * @param bytes The url-encoded byte array
      * @exception IllegalArgumentException if a '%' character is not followed
@@ -244,7 +256,8 @@
 
 
     /**
-     * Decode and return the specified URL-encoded byte array.
+     * Decode and return the specified URL-encoded byte array. It is assumed
+     * the string is not a query string.
      *
      * @param bytes The url-encoded byte array
      * @param enc The encoding to use; if null, the default encoding is used
@@ -252,7 +265,20 @@
      * by a valid 2-digit hexadecimal number
      */
     public static String URLDecode(byte[] bytes, String enc) {
+        return URLDecode(bytes, null, false);
+    }
 
+    /**
+     * Decode and return the specified URL-encoded byte array.
+     *
+     * @param bytes The url-encoded byte array
+     * @param enc The encoding to use; if null, the default encoding is used
+     * @param isQuery Is this a query string being processed
+     * @exception IllegalArgumentException if a '%' character is not followed
+     * by a valid 2-digit hexadecimal number
+     */
+    public static String URLDecode(byte[] bytes, String enc, boolean isQuery) {
+    
         if (bytes == null)
             return (null);
 
@@ -261,7 +287,7 @@
         int ox = 0;
         while (ix < len) {
             byte b = bytes[ix++];     // Get byte to test
-            if (b == '+') {
+            if (b == '+' && isQuery) {
                 b = (byte)' ';
             } else if (b == '%') {
                 b = (byte) ((convertHexDigit(bytes[ix++]) << 4)

Modified: tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml
URL: 
http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml?view=diff&rev=562736&r1=562735&r2=562736
==============================================================================
--- tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml Sat Aug  4 09:17:22 2007
@@ -19,6 +19,10 @@
   <subsection name="Catalina">
     <changelog>
       <fix>
+        <bug>42944</bug>: Correctly handle servlet mappings that use a '+'
+        character as part of the url pattern. (markt)
+      </fix>
+      <fix>
          <bug>42951</bug>: Don't use CATALINA_OPTS when stopping Tomcat. This
          allows options for starting and stopping to be set on JAVA_OPTS and
          options for starting only to be set on CATALINA_OPTS. Without this



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to