mime/quotedprintable: move quoted printable reader/writer to dedicated package
eaigner opened this issue · comments
Quoted-printable encoding and decoding is found in the mail and multipart packages. It would be more useful if the quoted printable implementations would be moved to a dedicated package like e.g. encoding/qp.
They look different. In net/mail, it's used for headers and references RFC 2047, which says: 4.2. The "Q" encoding The "Q" encoding is similar to the "Quoted-Printable" content- transfer-encoding defined in RFC 2045. It is designed to allow text containing mostly ASCII characters to be decipherable on an ASCII terminal without decoding. The one in mime/multipart is only a decoder (of RFC 2045, not 2047) and doesn't have an encoder.
I would prefer that textproto did not transparently decode quoted-printable for me. I would prefer to have an encoding package and do it myself. Reason being that I'm reading an email template where the Content-Transfer-Encoding header is used to specify what to encode the body to, and the body it unencoded because it contains variables.
I made a CL concerning this issue: https://golang.org/cl/101330049
CL https://golang.org/cl/101330049 mentions this issue.
There is nothing in the standard library yet. For the time being, you can use my package here: http://godoc.org/github.com/alexcesaro/mail/quotedprintable
CL https://golang.org/cl/132680044 mentions this issue.
The implementation of quotedprintable.go at https://golang.org/cl/132680044 seems to violate RFC2045. It allows lines greater than 76 characters. Shouldn't these get split with "=\n"?
That is right. However the 76-characters limit also applies to messages using base64 encoding.
That is why I don't think this limit should be enforced in the quoted-printable encoding functions. It should be in a new writer like mime.BodyWriter
or be implemented by the user.
The 76 characters limit is an integral part of the quoted-printable standard, whereas it's only imposed on base64 within a MIME message. So basically, it's a violation for one, and a contextual adaptation for the other.
RFC2045:
The Quoted-Printable encoding REQUIRES that encoded lines be no more than 76 characters long.
@alexcesaro, et al, the tree is now open for changes. See https://groups.google.com/forum/#!topic/golang-dev/otCULnOjs7I for details. Let's work on MIME early in this dev cycle, instead of at the very end like last time, where we missed it (largely my fault due to holiday schedules).
Thanks, I just submitted the change: https://go-review.googlesource.com/#/c/1810/
@mohamedattahri You are right. Also I had a look at Gomail where I implemented the limit for both base64 and quoted-printable encoding: I used two different writers because the code was too different to be reusable.
So I will update my commit to enforce the limit.
CL https://golang.org/cl/7890 mentions this issue.