Author: markt
Date: Fri Aug  3 17:15:53 2007
New Revision: 562625

URL: http://svn.apache.org/viewvc?view=rev&rev=562625
Log:
Fix bug 42944. + should only decoded to space in query strings. All current 
uses of URLDecide() are not for query strings.
Modified:
    
tomcat/container/tc5.5.x/catalina/src/share/org/apache/catalina/util/RequestUtil.java
    tomcat/container/tc5.5.x/webapps/docs/changelog.xml

Modified: 
tomcat/container/tc5.5.x/catalina/src/share/org/apache/catalina/util/RequestUtil.java
URL: 
http://svn.apache.org/viewvc/tomcat/container/tc5.5.x/catalina/src/share/org/apache/catalina/util/RequestUtil.java?view=diff&rev=562625&r1=562624&r2=562625
==============================================================================
--- 
tomcat/container/tc5.5.x/catalina/src/share/org/apache/catalina/util/RequestUtil.java
 (original)
+++ 
tomcat/container/tc5.5.x/catalina/src/share/org/apache/catalina/util/RequestUtil.java
 Fri Aug  3 17:15:53 2007
@@ -74,7 +74,6 @@
             buf.append("\"");
         }
 
-        long age = cookie.getMaxAge();
         if (cookie.getMaxAge() >= 0) {
             buf.append("; Max-Age=\"");
             buf.append(cookie.getMaxAge());
@@ -308,7 +307,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
      *
@@ -316,14 +315,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
@@ -331,7 +329,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);
 
@@ -347,13 +357,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
@@ -365,7 +376,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
@@ -373,7 +385,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);
 
@@ -382,7 +407,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)
@@ -461,7 +486,6 @@
         throws UnsupportedEncodingException {
 
         if (data != null && data.length > 0) {
-            int    pos = 0;
             int    ix = 0;
             int    ox = 0;
             String key = null;

Modified: tomcat/container/tc5.5.x/webapps/docs/changelog.xml
URL: 
http://svn.apache.org/viewvc/tomcat/container/tc5.5.x/webapps/docs/changelog.xml?view=diff&rev=562625&r1=562624&r2=562625
==============================================================================
--- tomcat/container/tc5.5.x/webapps/docs/changelog.xml (original)
+++ tomcat/container/tc5.5.x/webapps/docs/changelog.xml Fri Aug  3 17:15:53 2007
@@ -54,6 +54,10 @@
         <bug>42547</bug>: Fix NPE when a ResourceLink in context.xml tries to
         override an env-entry in web.xml. (markt)
       </fix>
+      <fix>
+        <bug>42944</bug>: Correctly handle servlet mappings that use a '+'
+        character as part of the url pattern. (markt)
+      </fix>
     </changelog>
   </subsection>
   <subsection name="Jasper">



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

Reply via email to