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 "Detelin Yordanov (JIRA)" <mi...@james.apache.org> on 2015/05/08 15:29:00 UTC

[jira] [Commented] (MIME4J-244) Cannot decode "quoted printable" encoded message which have space before equal sign("=") in strict mode

    [ https://issues.apache.org/jira/browse/MIME4J-244?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14534548#comment-14534548 ] 

Detelin Yordanov commented on MIME4J-244:
-----------------------------------------

I examined the source code of the QuotedPrintableInputStream and though I'm not quite familiar with the implementation, there is one thing that struck me - the "lastWasCR" flag is local to the read method and this means that in some cases, the information about the last CR byte will be lost. This can happen when the input is read in chunks and the last byte of the chunk happens to be a CR byte - in this case the flag will be set, but since the read method will terminate, the value will not be transferred for the next invocation of the read method - if that happens to start with a LF, the "Found LF without CR" error will be thrown.
It looks like this can be fixed by moving the "lastWasCR" as a member variable in the class so that its value is preserved through read method calls. I'm not sure how good this solution is, but it seems to fix the exception when testing the parsing of the sample string above in strict mode.

> Cannot decode "quoted printable" encoded message which have space before equal sign("=") in strict mode
> -------------------------------------------------------------------------------------------------------
>
>                 Key: MIME4J-244
>                 URL: https://issues.apache.org/jira/browse/MIME4J-244
>             Project: James Mime4j
>          Issue Type: Bug
>          Components: parser (core)
>    Affects Versions: 0.7.2
>            Reporter: Detelin Hadzhiev
>             Fix For: 0.7.3, 0.8.0
>
>
> Lets assume that we a message encoded using "quoted printable" encoding  like this:
> "text before eq sign =\r\n text after LF"
> When you try to decode it using QuotedPrintableInputStream in Strict Mode you will get  following exception:
> java.io.IOException: Found LF without CR
> 	at org.apache.james.mime4j.codec.QuotedPrintableInputStream.read0(QuotedPrintableInputStream.java:195)
> 	at org.apache.james.mime4j.codec.QuotedPrintableInputStream.read(QuotedPrintableInputStream.java:317)
> 	at org.apache.james.mime4j.codec.QuotedPrintableInputStream.read(QuotedPrintableInputStream.java:302)
> 	at org.apache.james.mime4j.codec.QuotedPrintableInputStreamTest.read(QuotedPrintableInputStreamTest.java:199)
> The same is fine using SILENT mode.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)