Author: remy.maucherat(a)jboss.com
Date: 2007-08-15 11:33:21 -0400 (Wed, 15 Aug 2007)
New Revision: 223
Modified:
branches/2.0.x/src/share/classes/org/apache/catalina/util/RequestUtil.java
Log:
- Fix handling of '+' in URLs.
Modified: branches/2.0.x/src/share/classes/org/apache/catalina/util/RequestUtil.java
===================================================================
--- branches/2.0.x/src/share/classes/org/apache/catalina/util/RequestUtil.java 2007-08-10
16:16:57 UTC (rev 222)
+++ branches/2.0.x/src/share/classes/org/apache/catalina/util/RequestUtil.java 2007-08-15
15:33:21 UTC (rev 223)
@@ -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)
Show replies by date