amyroh 2003/02/14 17:54:25
Modified: catalina/src/share/org/apache/catalina/util RequestUtil.java
Log:
Back port fixes from tomcat 5.
Use the specified encoding to extract bytes out of the given string so
that the encoding is not lost. If an encoding is not specified, let it
use the platform default encoding.
Allow query string values to contain '=' characters.
Revision Changes Path
1.20 +35 -13
jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/util/RequestUtil.java
Index: RequestUtil.java
===================================================================
RCS file:
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/util/RequestUtil.java,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- RequestUtil.java 21 Feb 2002 22:51:55 -0000 1.19
+++ RequestUtil.java 15 Feb 2003 01:54:25 -0000 1.20
@@ -331,9 +331,20 @@
throws UnsupportedEncodingException {
if ((data != null) && (data.length() > 0)) {
- int len = data.length();
- byte[] bytes = new byte[len];
- data.getBytes(0, len, bytes, 0);
+
+ // use the specified encoding to extract bytes out of the
+ // given string so that the encoding is not lost. If an
+ // encoding is not specified, let it use platform default
+ byte[] bytes = null;
+ try {
+ if (encoding == null) {
+ bytes = data.getBytes();
+ } else {
+ bytes = data.getBytes(encoding);
+ }
+ } catch (UnsupportedEncodingException uee) {
+ }
+
parseParameters(map, bytes, encoding);
}
@@ -371,9 +382,17 @@
if (str == null)
return (null);
- int len = str.length();
- byte[] bytes = new byte[len];
- str.getBytes(0, len, bytes, 0);
+ // use the specified encoding to extract bytes out of the
+ // given string so that the encoding is not lost. If an
+ // encoding is not specified, let it use platform default
+ byte[] bytes = null;
+ try {
+ if (enc == null) {
+ bytes = str.getBytes();
+ } else {
+ bytes = str.getBytes(enc);
+ }
+ } catch (UnsupportedEncodingException uee) {}
return URLDecode(bytes, enc);
@@ -506,8 +525,12 @@
ox = 0;
break;
case '=':
- key = new String(data, 0, ox, encoding);
- ox = 0;
+ if (key == null) {
+ key = new String(data, 0, ox, encoding);
+ ox = 0;
+ } else {
+ data[ox++] = c;
+ }
break;
case '+':
data[ox++] = (byte)' ';
@@ -532,4 +555,3 @@
}
-
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]