Author: niklas Date: Sun Mar 25 23:42:02 2007 New Revision: 522438 URL: http://svn.apache.org/viewvc?view=rev&rev=522438 Log: The encoded word '=?ISO-8859-1?Q?' caused an IndexOutOfBoundsException to be logged and then the empty string was returned. DecoderUtil will now deal with this encoded word and an exception won't be logged.
Modified: james/mime4j/trunk/src/main/java/org/mime4j/decoder/DecoderUtil.java james/mime4j/trunk/src/test/java/org/mime4j/decoder/DecoderUtilTest.java Modified: james/mime4j/trunk/src/main/java/org/mime4j/decoder/DecoderUtil.java URL: http://svn.apache.org/viewvc/james/mime4j/trunk/src/main/java/org/mime4j/decoder/DecoderUtil.java?view=diff&rev=522438&r1=522437&r2=522438 ============================================================================== --- james/mime4j/trunk/src/main/java/org/mime4j/decoder/DecoderUtil.java (original) +++ james/mime4j/trunk/src/main/java/org/mime4j/decoder/DecoderUtil.java Sun Mar 25 23:42:02 2007 @@ -197,9 +197,9 @@ */ p2 = t2 != -1 ? body.indexOf("?=", t2 + 1) : -1; if (p2 == -1) { - if (t2 != -1 && body.charAt(t2 + 1) == '=') { + if (t2 != -1 && (body.length() - 1 == t2 || body.charAt(t2 + 1) == '=')) { /* - * The text "=?charset?enc?=" appears to be valid for + * Treat "=?charset?enc?" and "=?charset?enc?=" as * empty strings. */ p2 = t2; Modified: james/mime4j/trunk/src/test/java/org/mime4j/decoder/DecoderUtilTest.java URL: http://svn.apache.org/viewvc/james/mime4j/trunk/src/test/java/org/mime4j/decoder/DecoderUtilTest.java?view=diff&rev=522438&r1=522437&r2=522438 ============================================================================== --- james/mime4j/trunk/src/test/java/org/mime4j/decoder/DecoderUtilTest.java (original) +++ james/mime4j/trunk/src/test/java/org/mime4j/decoder/DecoderUtilTest.java Sun Mar 25 23:42:02 2007 @@ -78,6 +78,7 @@ DecoderUtil.decodeEncodedWords("=?US-ASCII?b?QSBzaG9ydCB0ZXh0IGFnYWluIQ==?=")); assertEquals("", DecoderUtil.decodeEncodedWords("=?iso8859-1?Q?=")); assertEquals("", DecoderUtil.decodeEncodedWords("=?iso8859-1?b?=")); + assertEquals("", DecoderUtil.decodeEncodedWords("=?ISO-8859-1?Q?")); /* * Bug detected on June 7, 2005. Decoding the following string caused --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]