Author: remy.maucherat(a)jboss.com
Date: 2008-03-25 21:38:36 -0400 (Tue, 25 Mar 2008)
New Revision: 546
Modified:
trunk/java/org/apache/catalina/connector/InputBuffer.java
trunk/java/org/apache/tomcat/util/buf/B2CConverter.java
trunk/webapps/docs/changelog.xml
Log:
- 44494: Fix reads with multibyte characters.
Modified: trunk/java/org/apache/catalina/connector/InputBuffer.java
===================================================================
--- trunk/java/org/apache/catalina/connector/InputBuffer.java 2008-03-25 15:51:30 UTC (rev
545)
+++ trunk/java/org/apache/catalina/connector/InputBuffer.java 2008-03-26 01:38:36 UTC (rev
546)
@@ -399,7 +399,6 @@
state = CHAR_STATE;
conv.convert(bb, cb, bb.getLength());
- bb.setOffset(bb.getEnd());
return cb.getLength();
Modified: trunk/java/org/apache/tomcat/util/buf/B2CConverter.java
===================================================================
--- trunk/java/org/apache/tomcat/util/buf/B2CConverter.java 2008-03-25 15:51:30 UTC (rev
545)
+++ trunk/java/org/apache/tomcat/util/buf/B2CConverter.java 2008-03-26 01:38:36 UTC (rev
546)
@@ -74,45 +74,39 @@
throws IOException
{
// Set the ByteChunk as input to the Intermediate reader
- convert(bb, cb, cb.getBuffer().length - cb.getEnd());
+ convert(bb, cb, bb.getLength());
}
- public void convert( ByteChunk bb, CharChunk cb, int limit)
- throws IOException
- {
- iis.setByteChunk( bb );
- convert(cb, limit);
- }
-
- private void convert(CharChunk cb, int limit)
- throws IOException
- {
- try {
- // read from the reader
- int count = 0;
- while( limit > 0 ) { // conv.ready() ) {
+ public void convert(ByteChunk bb, CharChunk cb, int limit)
+ throws IOException {
+ iis.setByteChunk(bb);
+ try {
+ // read from the reader
+ int l = 0;
+ while( limit > 0 ) { // conv.ready() ) {
int size = limit < BUFFER_SIZE ? limit : BUFFER_SIZE;
- int cnt=conv.read( result, 0, size );
- if( cnt <= 0 ) {
- // End of stream ! - we may be in a bad state
- if( debug>0)
- log( "EOF" );
- // reset();
- return;
- }
- if( debug > 1 )
- log("Converted: " + new String( result, 0, cnt ));
+ l = bb.getLength();
+ int cnt=conv.read( result, 0, size );
+ if( cnt <= 0 ) {
+ // End of stream ! - we may be in a bad state
+ if( debug>0)
+ log( "EOF" );
+ // reset();
+ return;
+ }
+ if( debug > 1 )
+ log("Converted: " + new String( result, 0, cnt ));
- // XXX go directly
- cb.append( result, 0, cnt );
- limit -= cnt;
- }
- } catch( IOException ex) {
- if( debug>0)
- log( "Reseting the converter " + ex.toString() );
- reset();
- throw ex;
- }
+ cb.setLimit(cb.getStart() + cnt);
+ cb.append( result, 0, cnt );
+ limit = limit - (l - bb.getLength());
+ }
+ } catch( IOException ex) {
+ if( debug>0)
+ log( "Reseting the converter " + ex.toString() );
+ reset();
+ throw ex;
+ }
}
public void reset()
Modified: trunk/webapps/docs/changelog.xml
===================================================================
--- trunk/webapps/docs/changelog.xml 2008-03-25 15:51:30 UTC (rev 545)
+++ trunk/webapps/docs/changelog.xml 2008-03-26 01:38:36 UTC (rev 546)
@@ -57,6 +57,9 @@
<update>
Add support for specifying defaults for properties (format is
${property:default}). (remm)
</update>
+ <fix>
+ <bug>44494</bug>: Fix incorrect reads with multibyte charsets.
(remm)
+ </fix>
</changelog>
</subsection>
</section>
Show replies by date