Author: markt Date: Wed Sep 11 20:05:13 2013 New Revision: 1522016 URL: http://svn.apache.org/r1522016 Log: If both the input and output buffers are exhausted at the same time, return UNDERFLOW as more input data would be required to trigger OVERFLOW.
Modified: tomcat/trunk/java/org/apache/tomcat/util/buf/Utf8Encoder.java Modified: tomcat/trunk/java/org/apache/tomcat/util/buf/Utf8Encoder.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/buf/Utf8Encoder.java?rev=1522016&r1=1522015&r2=1522016&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/tomcat/util/buf/Utf8Encoder.java (original) +++ tomcat/trunk/java/org/apache/tomcat/util/buf/Utf8Encoder.java Wed Sep 11 20:05:13 2013 @@ -23,7 +23,8 @@ import java.nio.charset.CoderResult; import java.nio.charset.StandardCharsets; /** - * Encodes characters as bytes using UTF-8. Extracted from Apache Harmony. + * Encodes characters as bytes using UTF-8. Extracted from Apache Harmony with + * some minor bug fixes applied. */ public class Utf8Encoder extends CharsetEncoder { @@ -132,7 +133,12 @@ public class Utf8Encoder extends Charset if (outRemaining == 0) { in.position(x + 1); out.position(outPos); - return CoderResult.OVERFLOW; + // If both input and output are exhausted, return UNDERFLOW + if (x + 1 == limit) { + return CoderResult.UNDERFLOW; + } else { + return CoderResult.OVERFLOW; + } } } @@ -226,5 +232,4 @@ public class Utf8Encoder extends Charset } return CoderResult.UNDERFLOW; } - } \ No newline at end of file --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org