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 "Stefano Bagnara (JIRA)" <mi...@james.apache.org> on 2010/03/27 15:18:27 UTC

[jira] Commented: (MIME4J-176) Wrong CRLF usage in multipart.writeTo

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

Stefano Bagnara commented on MIME4J-176:
----------------------------------------

The problem is in preamble handling.

Currenlty the parser calls the T_PREAMBLE event for every message, even if they don't have a preamble.
So, there's currently no way to distinguish a message with no preamble from a message with an empty preamble. Given this "impossibility" it is by result impossible to correctly roundtrip both of them.

So the fix involve a few behavioural changes for the parser and for the dom:
1) The parser should not invoke T_PREAMBLE for messages having no preamble, instead it should start the following event (T_START_BODYPART)
2) The Multipart object should support "nulls" for preamble and epilogue, so to discern between no preamble and empty preamble.

This alters (*fixes*) the contract between mime4j parser/dom and the user, but the old behaviour is clearly wrong, so I don't see an alternative.

> Wrong CRLF usage in multipart.writeTo
> -------------------------------------
>
>                 Key: MIME4J-176
>                 URL: https://issues.apache.org/jira/browse/MIME4J-176
>             Project: JAMES Mime4j
>          Issue Type: Bug
>          Components: dom
>    Affects Versions: 0.6
>            Reporter: Stefano Bagnara
>            Assignee: Stefano Bagnara
>             Fix For: 0.7
>
>
> MessageWriter currently has this code:
>         writeBytes(preamble, out);
>         out.write(CRLF);
> and 
>         out.write(CRLF);
>         writeBytes(epilogue, out);
> This is correct only when epilogue and preamble exists in the original message, otherwise it introduces a one empty line epilogue/preamble that was not present in the original message.
> RFC clearly states that the CRLF after the preamble can be added only when a preamble exists (the same for the CRLF before the epilogue) 
>      multipart-body := [preamble CRLF]
>                        dash-boundary transport-padding CRLF
>                        body-part *encapsulation
>                        close-delimiter transport-padding
>                        [CRLF epilogue]
> So, roundtripping doesn't currently work for messages with no preamble or no epilogue, introducing a new empty line in the output stream.
> As an example this make it impossible to DKIM sign and validate messages with empty epilogue/prologue and it breaks DKIM signatures for such messages (this is true with the "simple" canonicalization method).

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.