Fix the remaining instances of new String(byte[] b, String enc) that can be fixed
authormarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Tue, 28 Jun 2011 07:22:28 +0000 (07:22 +0000)
committermarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Tue, 28 Jun 2011 07:22:28 +0000 (07:22 +0000)
git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1140463 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/catalina/connector/Request.java
java/org/apache/catalina/ssi/SSIServletExternalResolver.java
java/org/apache/catalina/util/Base64.java

index 5ae0226..2d26be0 100644 (file)
@@ -1592,12 +1592,12 @@ public class Request
         // Ensure that the specified encoding is valid
         byte buffer[] = new byte[1];
         buffer[0] = (byte) 'a';
-        @SuppressWarnings("unused")
-        String s = new String(buffer, enc);
 
+        // Confirm that the encoding name is valid
+        B2CConverter.getCharset(enc);
+        
         // Save the validated encoding
         coyoteRequest.setCharacterEncoding(enc);
-
     }
 
 
index b358094..40682c4 100644 (file)
@@ -36,6 +36,7 @@ import javax.servlet.http.HttpServletResponse;
 import org.apache.catalina.connector.Request;
 import org.apache.catalina.util.RequestUtil;
 import org.apache.coyote.Constants;
+import org.apache.tomcat.util.buf.B2CConverter;
 
 /**
  * An implementation of SSIExternalResolver that is used with servlets.
@@ -542,7 +543,8 @@ public class SSIServletExternalResolver implements SSIExternalResolver {
             if (inputEncoding == null) {
                 retVal = new String( bytes );
             } else {
-                retVal = new String (bytes, inputEncoding);
+                retVal = new String (bytes,
+                        B2CConverter.getCharset(inputEncoding));
             }
 
             //make an assumption that an empty response is a failure. This is
index c5f037d..f2fa111 100644 (file)
@@ -19,6 +19,7 @@ package org.apache.catalina.util;
 
 import java.io.UnsupportedEncodingException;
 
+import org.apache.tomcat.util.buf.B2CConverter;
 import org.apache.tomcat.util.buf.ByteChunk;
 import org.apache.tomcat.util.buf.CharChunk;
 
@@ -173,7 +174,8 @@ public final class  Base64
 
         String result;
         try {
-            result = new String(encodedData, "ISO-8859-1");
+            result = new String(encodedData,
+                    B2CConverter.getCharset("ISO-8859-1"));
         } catch (UnsupportedEncodingException e) {
             // Should never happen but in case it does...
             result = new String(encodedData);