[jbossweb-commits] JBossWeb SVN: r215 - trunk/java/org/apache/catalina/util.

jbossweb-commits at lists.jboss.org jbossweb-commits at lists.jboss.org
Wed Aug 8 13:30:06 EDT 2007


Author: remy.maucherat at jboss.com
Date: 2007-08-08 13:30:06 -0400 (Wed, 08 Aug 2007)
New Revision: 215

Modified:
   trunk/java/org/apache/catalina/util/RequestUtil.java
Log:
- Support '+' in various patterns in configuration files.

Modified: trunk/java/org/apache/catalina/util/RequestUtil.java
===================================================================
--- trunk/java/org/apache/catalina/util/RequestUtil.java	2007-08-08 17:10:08 UTC (rev 214)
+++ trunk/java/org/apache/catalina/util/RequestUtil.java	2007-08-08 17:30:06 UTC (rev 215)
@@ -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
      *
@@ -202,7 +202,8 @@
 
 
     /**
-     * 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 +211,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,7 +239,7 @@
             }
         } catch (UnsupportedEncodingException uee) {}
 
-        return URLDecode(bytes, enc);
+        return URLDecode(bytes, enc, isQuery);
 
     }
 
@@ -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)




More information about the jbossweb-commits mailing list