james-mime4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stefano Bagnara <apa...@bago.org>
Subject Re: Shouldn't Reader convert \r\n to \n?
Date Thu, 24 Dec 2009 16:16:31 GMT
2009/12/24 Florent Georges <lists@fgeorges.org>:
>  Hi,
>
>  I am using a MimeTokenStream to parse a multipart message.  For
> bodies with textual content (for instance text/plain), I get a
> Reader object from MimeTokenStream.getReader().  Unfortunately,
> it seems to not convert \r\n (correct end of line in messages on
> the wire) to \n (correct end of line in Java strings).

Why do you think \n is the correct end of line in Java strings ? This
is platform dependant and there is no such thing as the "correct end
of line in java strings". System.getProperty( "line.separator" ) is a
method to know your system line separator.

BTW the mime4j behaviour is not related to what the line separator for
your system is.

"\r\n" (CRLF) is the correct (canonical, in rfc terms) end of line in
mime specification. So, whenever mime4j creates a mime stream from
scratch it will try to use CRLF. However, in order to be permissive
with most mime streams out there mime4j will also treat a single "\n"
(LF) as a line termination when reading a message and, for performance
purposes, it won't translate this "\n" (LF) to "\r\n" (CRLF).

>  Is this a bug or did I miss something?

Hope you got it,

Stefano

Mime
View raw message