From 683c9cabe5bcf76032190f10882f18212395c493 Mon Sep 17 00:00:00 2001 From: markt Date: Mon, 27 Jun 2011 13:23:28 +0000 Subject: [PATCH] Prevent multiple variations of the same sncoding filling up the cache 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 | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/java/org/apache/tomcat/util/buf/B2CConverter.java b/java/org/apache/tomcat/util/buf/B2CConverter.java index 4d1cf7e57..542f02cbc 100644 --- a/java/org/apache/tomcat/util/buf/B2CConverter.java +++ b/java/org/apache/tomcat/util/buf/B2CConverter.java @@ -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); -- 2.11.0