james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Robert Burrell Donkin (JIRA)" <server-...@james.apache.org>
Subject [jira] Commented: (MIME4J-37) Wrong implementation of TempFileBinaryBody.writeTo
Date Sun, 25 May 2008 13:57:55 GMT

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

Robert Burrell Donkin commented on MIME4J-37:
---------------------------------------------

I think I understand the problem. When the temporary file is created, each part is decoded
thus:

        public void body(BodyDescriptor bd, InputStream is) throws IOException {
            expect(Entity.class);
            
            String enc = bd.getTransferEncoding();
            if (MimeUtil.ENC_BASE64.equals(enc)) {
                is = new Base64InputStream(is);
            } else if (MimeUtil.ENC_QUOTED_PRINTABLE.equals(enc)) {
                is = new QuotedPrintableInputStream(is);
            }
            
            Body body = null;
            if (bd.getMimeType().startsWith("text/")) {
                body = new TempFileTextBody(is, bd.getCharset());
            } else {
                body = new TempFileBinaryBody(is);
            }
            
            ((Entity) stack.peek()).setBody(body);
        }
        
writeTo therefore needs to honour the transfer encoding on the round trip

> Wrong implementation of TempFileBinaryBody.writeTo
> --------------------------------------------------
>
>                 Key: MIME4J-37
>                 URL: https://issues.apache.org/jira/browse/MIME4J-37
>             Project: Mime4j
>          Issue Type: Bug
>    Affects Versions: 0.3, 0.4
>            Reporter: Aljoscha Rittner
>            Assignee: Robert Burrell Donkin
>
> Message delegates writeTo to all Message-Entites.
> With this design it's impossible to write a message in a valid rfc822 format. 
> With binary content, the Multipart.writeTo writes a preamble in ascii, writes the boundary
in ascii and the epilogue in ascii, but the binary content is complete decoded.
>         writer.write(getPreamble() + "\r\n");
>         for (int i = 0; i < bodyParts.size(); i++) {
>             writer.write(boundary + "\r\n");
>             ((BodyPart) bodyParts.get(i)).writeTo(out);
>         }
>         writer.write(getEpilogue() + "\r\n");
>         writer.write(boundary + "--" + "\r\n");
> bodyPart delegates the writeTo to TempFileBinaryBody.writeTo:
>         IOUtils.copy(getInputStream(),out);
> with this implementation I get mixed ascii/binary code in one outputstream. It's impossible
to read the message.
> So I can't see any usecase to delegate the writeTo from Message to all his parts, or(?)
the writeTo - Method in TempFileBinaryBody is wrong.
> The Documentation from Body.writeTo is:
> "Writes this body to the given stream in MIME message format."
> And in TempFileBinaryBody.writeTo:
> @see org.apache.james.mime4j.message.Body#writeTo(java.io.OutputStream)
> But TempFileBinaryBody.writeTo does not write the content in  MIME message format.
> best regards,
>   josh.

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


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


Mime
View raw message