Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mime/quotedprintable: move quoted printable reader/writer to dedicated package #4943

Closed
eaigner opened this issue Feb 28, 2013 · 25 comments
Closed
Milestone

Comments

@eaigner
Copy link
Contributor

eaigner commented Feb 28, 2013

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.
@bradfitz
Copy link
Contributor

Comment 1:

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.

@eaigner
Copy link
Contributor Author

eaigner commented Feb 28, 2013

Comment 2:

I see. A dedicated package for quoted-printable would be nice nevertheless (possibly
with an option for the "Q" format of RFC 2047)

@eaigner
Copy link
Contributor Author

eaigner commented Mar 1, 2013

Comment 3:

Also, when using the Get method on a mail.Header, it just uses textproto.MIMEHeader's
Get() internally. If that header field was also Q encoded (e.g. "Subject"), it is not
decoded, which it probably should, in mail.Header.Get().

@bradfitz
Copy link
Contributor

bradfitz commented Mar 6, 2013

Comment 4:

Labels changed: added priority-later, removed priority-triage, go1.1maybe.

Status changed to Accepted.

@ianlancetaylor
Copy link
Contributor

Comment 5:

Labels changed: added go1.2maybe.

@rsc
Copy link
Contributor

rsc commented Jul 30, 2013

Comment 6:

Labels changed: added feature.

@robpike
Copy link
Contributor

robpike commented Aug 21, 2013

Comment 7:

Not for Go 1.2.

Labels changed: removed go1.2maybe.

@rsc
Copy link
Contributor

rsc commented Nov 27, 2013

Comment 8:

Labels changed: added go1.3maybe.

@rsc
Copy link
Contributor

rsc commented Nov 27, 2013

Comment 9:

Labels changed: removed feature.

@rsc
Copy link
Contributor

rsc commented Dec 4, 2013

Comment 10:

Labels changed: added release-none, removed go1.3maybe.

@rsc
Copy link
Contributor

rsc commented Dec 4, 2013

Comment 11:

Labels changed: added repo-main.

@lukescott
Copy link

Comment 12:

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.

@alexcesaro
Copy link
Contributor

Comment 13:

I made a CL concerning this issue: https://golang.org/cl/101330049

@gopherbot
Copy link

Comment 14:

CL https://golang.org/cl/101330049 mentions this issue.

@gopherbot
Copy link

Comment 15 by joodngbo1976:

i also need the qp encoder to encoding, dose it exist in any golang packages?
such as encoding/qp?

@alexcesaro
Copy link
Contributor

Comment 16:

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

@gopherbot
Copy link

Comment 17 by joodngbo1976:

Thanks a lot, i plan to rewrite a quoted-printable encoder/decoder package based on the
C implementations

@gopherbot
Copy link

Comment 19:

CL https://golang.org/cl/132680044 mentions this issue.

@chowey
Copy link

chowey commented Dec 7, 2014

Comment 20:

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"?

@alexcesaro
Copy link
Contributor

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.

@mohamedattahri
Copy link
Contributor

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.

@bradfitz
Copy link
Contributor

@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).

@bradfitz bradfitz added this to the Go1.5 milestone Dec 18, 2014
@alexcesaro
Copy link
Contributor

Thanks, I just submitted the change: https://go-review.googlesource.com/#/c/1810/

@alexcesaro
Copy link
Contributor

@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.

bradfitz pushed a commit that referenced this issue Dec 23, 2014
The code concerning quoted-printable encoding (RFC 2045) and its
variant for MIME headers (RFC 2047) is currently spread in
mime/multipart and net/mail. It is also not exported.

This commit is the first step to fix that issue. It moves the
quoted-printable decoding code from mime/multipart to
mime/internal/quotedprintable. The exposed API is unchanged.

Concerns #4943.

Change-Id: I11352afbb2edb4d6ef62870b9bc5c87c639eff12
Reviewed-on: https://go-review.googlesource.com/1810
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
bradfitz pushed a commit that referenced this issue Feb 23, 2015
The code concerning quoted-printable encoding (RFC 2045) and its
variant for MIME headers (RFC 2047) is currently spread in
mime/multipart and net/mail. It is also not exported.

This commit is the second step to fix that issue. It moves the
RFC 2047 encoding and decoding functions from net/mail to
internal/mime. The exported API is unchanged.

Updates #4943

Change-Id: I5f58aa58e74bbe4ec91b2e9b8c81921338053b00
Reviewed-on: https://go-review.googlesource.com/2101
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
bradfitz pushed a commit that referenced this issue Feb 26, 2015
This commit creates the mime/quotedprintable package. It moves and
exports the QP reader of mime/internal/quotedprintable.

The code is almost unchanged to preserve the commit history.

Updates #4943

Change-Id: I4b7b5a2a40a4c84346d42e4cdd2c11a91b28f9e3
Reviewed-on: https://go-review.googlesource.com/5940
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
nigeltao pushed a commit that referenced this issue Mar 20, 2015
Updates #4943

Change-Id: I082b97ccd787cf91245d39b8d93783732db6f42c
Reviewed-on: https://go-review.googlesource.com/6171
Reviewed-by: Nigel Tao <nigeltao@golang.org>
@rsc rsc removed accepted labels Apr 14, 2015
@gopherbot
Copy link

CL https://golang.org/cl/7890 mentions this issue.

@golang golang locked and limited conversation to collaborators Jun 24, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

10 participants