Open kirikak2 opened 6 years ago
Hi, I can confirm the bug and the proposed solution works for me.
https://www.ietf.org/rfc/rfc2821.txt
SMTP commands and, unless altered by a service extension, message
data, are transmitted in "lines". Lines consist of zero or more data
characters terminated by the sequence ASCII character "CR" (hex value
0D) followed immediately by ASCII character "LF" (hex value 0A).
This termination sequence is denoted as <CRLF> in this document.
Conforming implementations MUST NOT recognize or generate any other
character or character sequence as a line terminator. Limits MAY be
imposed on line lengths by servers (see section 4.5.3).
In addition, the appearance of "bare" "CR" or "LF" characters in text
(i.e., either without the other) has a long history of causing
problems in mail implementations and applications that use the mail
system as a tool. SMTP client implementations MUST NOT transmit
these characters except when they are intended as line terminators
and then MUST, as indicated above, transmit them only as a <CRLF>
sequence.
@mikel do you have time to review?
I prepared a pull request and fixed some issues https://github.com/mikel/mail/pull/1246
but 2 issues still remain: 1/ all lines should always contain only \<CRLF> separators 2/ max line length should be always <= 76 or separated by a soft line break "=" (I don't have a real problem reading it, but it violates RFC now)
I tried to fix them, but it breaks binary attachments again. Any idea?
I'm also having this issue @mikel
I found this issue when I encode mail with binary file attachment in Quoted-Printable.
This is sample case.
This is difference between original.eml and after.eml.
This problem cause from ruby Array#pack("M") behavior. Ruby's Array#pack("M") doesn't support Quoted-Printable with binary, so ruby does not encode "\n".
and Mail library converts "\n" to "\r\n" in to_crlf. so break binary file. I found similar issue in #1010
I asked to ruby community. (https://bugs.ruby-lang.org/issues/14352 sorry this discussion in Japanese.) and I got a answer which this behavior should not be change.
so I propose to change implementation in Mail gem's Quoted-Printable encoder as follow.
This change has breaking change, breaks test case. For example.
This change is compatibility will be lost, but more safety than before. any idea?
Thanks.