Author: markt Date: Mon Jan 7 23:05:49 2013 New Revision: 1430083 URL: http://svn.apache.org/viewvc?rev=1430083&view=rev Log: Need to reset the decoder when the B2C converter is recycled to ensure BOMs are correctly handled for those encodings that require them.
Added: tomcat/tc7.0.x/trunk/test/org/apache/tomcat/util/buf/TestB2CConverter.java - copied unchanged from r1430079, tomcat/trunk/test/org/apache/tomcat/util/buf/TestB2CConverter.java Modified: tomcat/tc7.0.x/trunk/ (props changed) tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/buf/B2CConverter.java tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml Propchange: tomcat/tc7.0.x/trunk/ ------------------------------------------------------------------------------ Merged /tomcat/trunk:r1430079 Modified: tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/buf/B2CConverter.java URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/buf/B2CConverter.java?rev=1430083&r1=1430082&r2=1430083&view=diff ============================================================================== --- tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/buf/B2CConverter.java (original) +++ tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/buf/B2CConverter.java Mon Jan 7 23:05:49 2013 @@ -21,6 +21,7 @@ import java.io.InputStream; import java.io.InputStreamReader; import java.io.UnsupportedEncodingException; import java.nio.charset.Charset; +import java.nio.charset.CharsetDecoder; import java.util.HashMap; import java.util.Locale; import java.util.Map; @@ -93,6 +94,7 @@ public class B2CConverter { private IntermediateInputStream iis; private ReadConvertor conv; + private CharsetDecoder decoder; private String encoding; /** @@ -117,6 +119,7 @@ public class B2CConverter { */ public void recycle() { conv.recycle(); + decoder.reset(); } static final int BUFFER_SIZE=8192; @@ -165,12 +168,11 @@ public class B2CConverter { } - public void reset() - throws IOException - { - // destroy the reader/iis - iis=new IntermediateInputStream(); - conv = new ReadConvertor(iis, getCharset(encoding)); + public void reset() throws IOException { + // Re-create the reader and iis + iis = new IntermediateInputStream(); + decoder = getCharset(encoding).newDecoder(); + conv = new ReadConvertor(iis, decoder); } } @@ -182,12 +184,12 @@ public class B2CConverter { /** * */ -final class ReadConvertor extends InputStreamReader { +final class ReadConvertor extends InputStreamReader { /** Create a converter. */ - public ReadConvertor(IntermediateInputStream in, Charset charset) { - super(in, charset); + public ReadConvertor(IntermediateInputStream in, CharsetDecoder decoder) { + super(in, decoder); } /** Overridden - will do nothing but reset internal state. Modified: tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml?rev=1430083&r1=1430082&r2=1430083&view=diff ============================================================================== --- tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml (original) +++ tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml Mon Jan 7 23:05:49 2013 @@ -111,6 +111,15 @@ </fix> </changelog> </subsection> + <subsection name="Coyote"> + <changelog> + <fix> + <bug>54248</bug>: Ensure that byte order marks are swallowed when using + a Reader to read a request body with a BOM for those encodings that + require byte order marks. (markt) + </fix> + </changelog> + </subsection> <subsection name="Jasper"> <changelog> <fix> --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org