aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlexandre Cesaro <alexandre.cesaro@gmail.com>2014-12-18 21:33:34 +0100
committerBrad Fitzpatrick <bradfitz@golang.org>2014-12-23 19:30:02 +0000
commit0d4ea0c70d2c8fbdf1f9263f919c79c33b4ce8e0 (patch)
tree600bb4512ed39a7c1af75907adcd17e982343d70 /src
parent10be797578925708afb140ceb771c8e2d6346332 (diff)
downloadgo-0d4ea0c70d2c8fbdf1f9263f919c79c33b4ce8e0.tar.xz
mime/multipart: moved some code to mime/internal/quotedprintable
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>
Diffstat (limited to 'src')
-rw-r--r--src/go/build/deps_test.go2
-rw-r--r--src/mime/internal/quotedprintable/quotedprintable.go (renamed from src/mime/multipart/quotedprintable.go)4
-rw-r--r--src/mime/internal/quotedprintable/quotedprintable_test.go (renamed from src/mime/multipart/quotedprintable_test.go)6
-rw-r--r--src/mime/multipart/multipart.go3
4 files changed, 8 insertions, 7 deletions
diff --git a/src/go/build/deps_test.go b/src/go/build/deps_test.go
index b74595ea83..b3c1105156 100644
--- a/src/go/build/deps_test.go
+++ b/src/go/build/deps_test.go
@@ -311,7 +311,7 @@ var pkgDeps = map[string][]string{
"crypto/x509/pkix": {"L4", "CRYPTO-MATH"},
// Simple net+crypto-aware packages.
- "mime/multipart": {"L4", "OS", "mime", "crypto/rand", "net/textproto"},
+ "mime/multipart": {"L4", "OS", "mime", "crypto/rand", "net/textproto", "mime/internal/quotedprintable"},
"net/smtp": {"L4", "CRYPTO", "NET", "crypto/tls"},
// HTTP, kingpin of dependencies.
diff --git a/src/mime/multipart/quotedprintable.go b/src/mime/internal/quotedprintable/quotedprintable.go
index 9ff4ee703e..2417bf2148 100644
--- a/src/mime/multipart/quotedprintable.go
+++ b/src/mime/internal/quotedprintable/quotedprintable.go
@@ -8,7 +8,7 @@
// 2. it will pass through a '\r' or '\n' not preceded by '=', consistent
// with other broken QP encoders & decoders.
-package multipart
+package quotedprintable
import (
"bufio"
@@ -23,7 +23,7 @@ type qpReader struct {
line []byte // to be consumed before more of br
}
-func newQuotedPrintableReader(r io.Reader) io.Reader {
+func NewReader(r io.Reader) io.Reader {
return &qpReader{
br: bufio.NewReader(r),
}
diff --git a/src/mime/multipart/quotedprintable_test.go b/src/mime/internal/quotedprintable/quotedprintable_test.go
index c4de3eb756..0c7760f4b9 100644
--- a/src/mime/multipart/quotedprintable_test.go
+++ b/src/mime/internal/quotedprintable/quotedprintable_test.go
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-package multipart
+package quotedprintable
import (
"bufio"
@@ -65,7 +65,7 @@ func TestQuotedPrintable(t *testing.T) {
}
for _, tt := range tests {
var buf bytes.Buffer
- _, err := io.Copy(&buf, newQuotedPrintableReader(strings.NewReader(tt.in)))
+ _, err := io.Copy(&buf, NewReader(strings.NewReader(tt.in)))
if got := buf.String(); got != tt.want {
t.Errorf("for %q, got %q; want %q", tt.in, got, tt.want)
}
@@ -116,7 +116,7 @@ func TestQPExhaustive(t *testing.T) {
return
}
buf.Reset()
- _, err := io.Copy(&buf, newQuotedPrintableReader(strings.NewReader(s)))
+ _, err := io.Copy(&buf, NewReader(strings.NewReader(s)))
if err != nil {
errStr := err.Error()
if strings.Contains(errStr, "invalid bytes after =:") {
diff --git a/src/mime/multipart/multipart.go b/src/mime/multipart/multipart.go
index 01a667d930..3f06c07dc8 100644
--- a/src/mime/multipart/multipart.go
+++ b/src/mime/multipart/multipart.go
@@ -19,6 +19,7 @@ import (
"io"
"io/ioutil"
"mime"
+ "mime/internal/quotedprintable"
"net/textproto"
)
@@ -111,7 +112,7 @@ func newPart(mr *Reader) (*Part, error) {
const cte = "Content-Transfer-Encoding"
if bp.Header.Get(cte) == "quoted-printable" {
bp.Header.Del(cte)
- bp.r = newQuotedPrintableReader(bp.r)
+ bp.r = quotedprintable.NewReader(bp.r)
}
return bp, nil
}