aboutsummaryrefslogtreecommitdiff
path: root/src/mime
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2018-06-26 17:14:43 -0700
committerIan Lance Taylor <iant@golang.org>2018-06-27 17:00:08 +0000
commit228b4416b7bb21158028714347dac07f06da789a (patch)
treed97acf9bbee72e87e81763a3f1337bdd21e776a9 /src/mime
parentb749845067a2f59d3ffa215b83286272d38398ca (diff)
downloadgo-228b4416b7bb21158028714347dac07f06da789a.tar.gz
go-228b4416b7bb21158028714347dac07f06da789a.zip
mime/quotedprintable: accept bytes >= 0x80
RFC 2045 doesn't permit non-ASCII bytes, but some systems send them anyhow. With this change, we accept them. This does make it harder to validate quotedprintable data, but on balance this seems like the best approach given the existence of systems that generate invalid data. Fixes #22597 Change-Id: I9f80f90a60b76ada2b5dea658b8dc8aace56cdbd Reviewed-on: https://go-review.googlesource.com/121095 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Diffstat (limited to 'src/mime')
-rw-r--r--src/mime/quotedprintable/reader.go4
-rw-r--r--src/mime/quotedprintable/reader_test.go4
2 files changed, 7 insertions, 1 deletions
diff --git a/src/mime/quotedprintable/reader.go b/src/mime/quotedprintable/reader.go
index b142240343..4239625402 100644
--- a/src/mime/quotedprintable/reader.go
+++ b/src/mime/quotedprintable/reader.go
@@ -123,6 +123,10 @@ func (r *Reader) Read(p []byte) (n int, err error) {
r.line = r.line[2:] // 2 of the 3; other 1 is done below
case b == '\t' || b == '\r' || b == '\n':
break
+ case b >= 0x80:
+ // As an extension to RFC 2045, we accept
+ // values >= 0x80 without complaint. Issue 22597.
+ break
case b < ' ' || b > '~':
return n, fmt.Errorf("quotedprintable: invalid unescaped byte 0x%02x in body", b)
}
diff --git a/src/mime/quotedprintable/reader_test.go b/src/mime/quotedprintable/reader_test.go
index ca016f969a..f870bdaa8d 100644
--- a/src/mime/quotedprintable/reader_test.go
+++ b/src/mime/quotedprintable/reader_test.go
@@ -37,7 +37,7 @@ func TestReader(t *testing.T) {
{in: " A B =\n C ", want: " A B C"}, // lax. treating LF as CRLF
{in: "foo=\nbar", want: "foobar"},
{in: "foo\x00bar", want: "foo", err: "quotedprintable: invalid unescaped byte 0x00 in body"},
- {in: "foo bar\xff", want: "foo bar", err: "quotedprintable: invalid unescaped byte 0xff in body"},
+ {in: "foo bar\xff", want: "foo bar\xff"},
// Equal sign.
{in: "=3D30\n", want: "=30\n"},
@@ -65,6 +65,8 @@ func TestReader(t *testing.T) {
// Example from RFC 2045:
{in: "Now's the time =\n" + "for all folk to come=\n" + " to the aid of their country.",
want: "Now's the time for all folk to come to the aid of their country."},
+ {in: "accept UTF-8 right quotation mark: ’",
+ want: "accept UTF-8 right quotation mark: ’"},
}
for _, tt := range tests {
var buf bytes.Buffer