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.

Reply via email to