amyroh      2003/02/14 14:23:04

  Modified:    catalina/src/share/org/apache/catalina/util RequestUtil.java
  Log:
  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.  Fixes bugtraq 4697359.
  
  Revision  Changes    Path
  1.3       +29 -10    
jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/util/RequestUtil.java
  
  Index: RequestUtil.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/util/RequestUtil.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- RequestUtil.java  14 Feb 2003 22:04:47 -0000      1.2
  +++ RequestUtil.java  14 Feb 2003 22:23:04 -0000      1.3
  @@ -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);
   
  
  
  

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

Reply via email to