From 5a5f1de5fce8b60459c1a280b8ba33c1b6b2c3b0 Mon Sep 17 00:00:00 2001 From: markt Date: Sun, 30 Mar 2008 21:13:36 +0000 Subject: [PATCH] Apply Remy's patch for 44494 for multi-byte character data. git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@642819 13f79535-47bb-0310-9956-ffa450edef68 --- java/org/apache/tomcat/util/buf/B2CConverter.java | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/java/org/apache/tomcat/util/buf/B2CConverter.java b/java/org/apache/tomcat/util/buf/B2CConverter.java index cb67cfe32..7a1209879 100644 --- a/java/org/apache/tomcat/util/buf/B2CConverter.java +++ b/java/org/apache/tomcat/util/buf/B2CConverter.java @@ -77,34 +77,28 @@ public class B2CConverter { convert(bb, cb, cb.getBuffer().length - cb.getEnd()); } + 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 bbLengthBeforeRead = 0; while( limit > 0 ) { // conv.ready() ) { int size = limit < BUFFER_SIZE ? limit : BUFFER_SIZE; + bbLengthBeforeRead = 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; + limit = limit - (bbLengthBeforeRead - bb.getLength()); } } catch( IOException ex) { if( debug>0) @@ -114,6 +108,7 @@ public class B2CConverter { } } + public void reset() throws IOException { -- 2.11.0