You are viewing a plain text version of this content. The canonical link for it is here.
Posted to mime4j-dev@james.apache.org by ol...@apache.org on 2015/05/13 11:23:02 UTC

svn commit: r1679163 - in /james/mime4j/branches/apache-mime4j-0.7/core/src: main/java/org/apache/james/mime4j/codec/QuotedPrintableInputStream.java test/java/org/apache/james/mime4j/codec/QuotedPrintableInputStreamTest.java

Author: olegk
Date: Wed May 13 09:23:01 2015
New Revision: 1679163

URL: http://svn.apache.org/r1679163
Log:
MIME4J-244: QP decoder incorrectly throws IOException in strict mode when LF is the first character in content stream
Contributed by Detelin Hadzhiev <detelin.hadzhiev at softwareag.com>

Modified:
    james/mime4j/branches/apache-mime4j-0.7/core/src/main/java/org/apache/james/mime4j/codec/QuotedPrintableInputStream.java
    james/mime4j/branches/apache-mime4j-0.7/core/src/test/java/org/apache/james/mime4j/codec/QuotedPrintableInputStreamTest.java

Modified: james/mime4j/branches/apache-mime4j-0.7/core/src/main/java/org/apache/james/mime4j/codec/QuotedPrintableInputStream.java
URL: http://svn.apache.org/viewvc/james/mime4j/branches/apache-mime4j-0.7/core/src/main/java/org/apache/james/mime4j/codec/QuotedPrintableInputStream.java?rev=1679163&r1=1679162&r2=1679163&view=diff
==============================================================================
--- james/mime4j/branches/apache-mime4j-0.7/core/src/main/java/org/apache/james/mime4j/codec/QuotedPrintableInputStream.java (original)
+++ james/mime4j/branches/apache-mime4j-0.7/core/src/main/java/org/apache/james/mime4j/codec/QuotedPrintableInputStream.java Wed May 13 09:23:01 2015
@@ -45,6 +45,7 @@ public class QuotedPrintableInputStream
     private int pos = 0; // current index into encoded buffer
     private int limit = 0; // current size of encoded buffer
 
+    private boolean lastWasCR = false;
     private boolean closed;
 
     private final DecodeMonitor monitor;
@@ -181,7 +182,6 @@ public class QuotedPrintableInputStream
                 return index == from ? -1 : index - from;
             }
 
-            boolean lastWasCR = false;
             while (pos < limit && index < to) {
                 int b = encoded[pos++] & 0xFF;
 

Modified: james/mime4j/branches/apache-mime4j-0.7/core/src/test/java/org/apache/james/mime4j/codec/QuotedPrintableInputStreamTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/branches/apache-mime4j-0.7/core/src/test/java/org/apache/james/mime4j/codec/QuotedPrintableInputStreamTest.java?rev=1679163&r1=1679162&r2=1679163&view=diff
==============================================================================
--- james/mime4j/branches/apache-mime4j-0.7/core/src/test/java/org/apache/james/mime4j/codec/QuotedPrintableInputStreamTest.java (original)
+++ james/mime4j/branches/apache-mime4j-0.7/core/src/test/java/org/apache/james/mime4j/codec/QuotedPrintableInputStreamTest.java Wed May 13 09:23:01 2015
@@ -95,6 +95,12 @@ public class QuotedPrintableInputStreamT
         assertEquals("Soft line   Hard line\r\n", new String(read(decoder), "ISO8859-1"));
     }
 
+    public void testSpaceBeforeSoftBreakStrictMode() throws IOException, UnsupportedEncodingException {
+        ByteArrayInputStream bis = new ByteArrayInputStream("text before eq sign =\r\n text after LF".getBytes("US-ASCII"));
+        QuotedPrintableInputStream decoder = new QuotedPrintableInputStream(bis,DecodeMonitor.STRICT);
+        assertEquals("text before eq sign  text after LF", new String(read(decoder), "ISO8859-1"));
+    }
+    
     public void testSoftBreakTrailingBalnksDecode() throws IOException, UnsupportedEncodingException {
         ByteArrayInputStream bis = new ByteArrayInputStream("Soft line   = \t \r\nHard line   \r\n".getBytes("US-ASCII"));
         QuotedPrintableInputStream decoder = new QuotedPrintableInputStream(bis);