mirror of https://github.com/golang/go.git
mime/multipart: check for quoted-printable case insensitively
Fixes #28674 Change-Id: Id88e0a4b86b50eb45f0d968d7e4bbe66b7f37f82 Reviewed-on: https://go-review.googlesource.com/c/148579 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
parent
8ebc9fbc34
commit
ef2c486598
|
|
@ -21,6 +21,7 @@ import (
|
|||
"mime"
|
||||
"mime/quotedprintable"
|
||||
"net/textproto"
|
||||
"strings"
|
||||
)
|
||||
|
||||
var emptyParams = make(map[string]string)
|
||||
|
|
@ -135,7 +136,7 @@ func newPart(mr *Reader) (*Part, error) {
|
|||
}
|
||||
bp.r = partReader{bp}
|
||||
const cte = "Content-Transfer-Encoding"
|
||||
if bp.Header.Get(cte) == "quoted-printable" {
|
||||
if strings.EqualFold(bp.Header.Get(cte), "quoted-printable") {
|
||||
bp.Header.Del(cte)
|
||||
bp.r = quotedprintable.NewReader(bp.r)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -419,8 +419,16 @@ func TestLineContinuation(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestQuotedPrintableEncoding(t *testing.T) {
|
||||
for _, cte := range []string{"quoted-printable", "Quoted-PRINTABLE"} {
|
||||
t.Run(cte, func(t *testing.T) {
|
||||
testQuotedPrintableEncoding(t, cte)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func testQuotedPrintableEncoding(t *testing.T, cte string) {
|
||||
// From https://golang.org/issue/4411
|
||||
body := "--0016e68ee29c5d515f04cedf6733\r\nContent-Type: text/plain; charset=ISO-8859-1\r\nContent-Disposition: form-data; name=text\r\nContent-Transfer-Encoding: quoted-printable\r\n\r\nwords words words words words words words words words words words words wor=\r\nds words words words words words words words words words words words words =\r\nwords words words words words words words words words words words words wor=\r\nds words words words words words words words words words words words words =\r\nwords words words words words words words words words\r\n--0016e68ee29c5d515f04cedf6733\r\nContent-Type: text/plain; charset=ISO-8859-1\r\nContent-Disposition: form-data; name=submit\r\n\r\nSubmit\r\n--0016e68ee29c5d515f04cedf6733--"
|
||||
body := "--0016e68ee29c5d515f04cedf6733\r\nContent-Type: text/plain; charset=ISO-8859-1\r\nContent-Disposition: form-data; name=text\r\nContent-Transfer-Encoding: " + cte + "\r\n\r\nwords words words words words words words words words words words words wor=\r\nds words words words words words words words words words words words words =\r\nwords words words words words words words words words words words words wor=\r\nds words words words words words words words words words words words words =\r\nwords words words words words words words words words\r\n--0016e68ee29c5d515f04cedf6733\r\nContent-Type: text/plain; charset=ISO-8859-1\r\nContent-Disposition: form-data; name=submit\r\n\r\nSubmit\r\n--0016e68ee29c5d515f04cedf6733--"
|
||||
r := NewReader(strings.NewReader(body), "0016e68ee29c5d515f04cedf6733")
|
||||
part, err := r.NextPart()
|
||||
if err != nil {
|
||||
|
|
|
|||
Loading…
Reference in New Issue