Prevent multiple variations of the same sncoding filling up the cache
authormarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Mon, 27 Jun 2011 13:23:28 +0000 (13:23 +0000)
committermarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Mon, 27 Jun 2011 13:23:28 +0000 (13:23 +0000)
git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1140153 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/tomcat/util/buf/B2CConverter.java

index 4d1cf7e..542f02c 100644 (file)
@@ -25,6 +25,7 @@ import java.io.UnsupportedEncodingException;
 import java.nio.charset.Charset;
 import java.nio.charset.IllegalCharsetNameException;
 import java.nio.charset.UnsupportedCharsetException;
+import java.util.Locale;
 import java.util.concurrent.ConcurrentHashMap;
 
 /** Efficient conversion of bytes  to character .
@@ -50,7 +51,10 @@ public class B2CConverter {
     public static Charset getCharset(String enc)
             throws UnsupportedEncodingException{
 
-        Charset charset = encodingToCharsetCache.get(enc);
+        // Encoding names should all be ASCII
+        String lowerCaseEnc = enc.toLowerCase(Locale.US);
+
+        Charset charset = encodingToCharsetCache.get(lowerCaseEnc);
         if (charset == null) {
             try {
                 charset = Charset.forName(enc);