Skip to content

Commit bea028d

Browse files
committed
兼容有些邮箱客户端没有按照RFC2045规定分割Base64 编码的输出
1 parent 15961ba commit bea028d

File tree

4 files changed

+7
-4
lines changed

4 files changed

+7
-4
lines changed

encode.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ import (
55
"encoding/base64"
66
"io"
77
"mime"
8-
"mime/quotedprintable"
98
"net/textproto"
109
"sort"
1110
"strings"
1211
"time"
1312

13+
"github.com/huangshaokun/mimequotedprintable"
1414
"github.com/jhillyerd/enmime/v2/internal/coding"
1515
"github.com/jhillyerd/enmime/v2/internal/stringutil"
1616
)
@@ -243,7 +243,7 @@ func (p *Part) encodeContent(b *bufio.Writer, cte transferEncoding) (err error)
243243
text = text[lineLen:]
244244
}
245245
case teQuoted:
246-
qp := quotedprintable.NewWriter(b)
246+
qp := mimequotedprintable.NewWriter(b)
247247
if _, err = qp.Write(p.Content); err != nil {
248248
return err
249249
}

go.mod

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ require (
66
github.com/cention-sany/utf7 v0.0.0-20170124080048-26cad61bd60a
77
github.com/go-test/deep v1.1.1
88
github.com/gogs/chardet v0.0.0-20211120154057-b7413eaefb8f
9+
github.com/huangshaokun/mimequotedprintable v0.0.0-20230626102010-a5b2166f9691
910
github.com/jaytaylor/html2text v0.0.0-20230321000545-74c2419ad056
1011
github.com/pkg/errors v0.9.1
1112
github.com/stretchr/testify v1.9.0

go.sum

+2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ github.com/go-test/deep v1.1.1 h1:0r/53hagsehfO4bzD2Pgr/+RgHqhmf+k1Bpse2cTu1U=
66
github.com/go-test/deep v1.1.1/go.mod h1:5C2ZWiW0ErCdrYzpqxLbTX7MG14M9iiw8DgHncVwcsE=
77
github.com/gogs/chardet v0.0.0-20211120154057-b7413eaefb8f h1:3BSP1Tbs2djlpprl7wCLuiqMaUh5SJkkzI2gDs+FgLs=
88
github.com/gogs/chardet v0.0.0-20211120154057-b7413eaefb8f/go.mod h1:Pcatq5tYkCW2Q6yrR2VRHlbHpZ/R4/7qyL1TCF7vl14=
9+
github.com/huangshaokun/mimequotedprintable v0.0.0-20230626102010-a5b2166f9691 h1:cMH8l7waIU0+24EihDQBtCfpwdHsvYNaNgOOg2iyAPE=
10+
github.com/huangshaokun/mimequotedprintable v0.0.0-20230626102010-a5b2166f9691/go.mod h1:gDBKZcuLIpRM4uX1/Dv2jLAF+9Fqf5zy0Rg2XzPh+Iw=
911
github.com/jaytaylor/html2text v0.0.0-20230321000545-74c2419ad056 h1:iCHtR9CQyktQ5+f3dMVZfwD2KWJUgm7M0gdL9NGr8KA=
1012
github.com/jaytaylor/html2text v0.0.0-20230321000545-74c2419ad056/go.mod h1:CVKlgaMiht+LXvHG173ujK6JUhZXKb2u/BQtjPDIvyk=
1113
github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=

part.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ import (
66
"encoding/base64"
77
"io"
88
"math/rand"
9-
"mime/quotedprintable"
109
"net/textproto"
1110
"strconv"
1211
"strings"
1312
"time"
1413

1514
"github.com/gogs/chardet"
15+
"github.com/huangshaokun/mimequotedprintable"
1616
"github.com/jhillyerd/enmime/v2/internal/coding"
1717
inttp "github.com/jhillyerd/enmime/v2/internal/textproto"
1818
"github.com/jhillyerd/enmime/v2/mediatype"
@@ -290,7 +290,7 @@ func (p *Part) decodeContent(r io.Reader, readPartErrorPolicy ReadPartErrorPolic
290290
switch strings.ToLower(encoding) {
291291
case cteQuotedPrintable:
292292
contentReader = coding.NewQPCleaner(contentReader)
293-
contentReader = quotedprintable.NewReader(contentReader)
293+
contentReader = mimequotedprintable.NewReader(contentReader)
294294
case cteBase64:
295295
b64cleaner = coding.NewBase64Cleaner(contentReader)
296296
contentReader = base64.NewDecoder(base64.RawStdEncoding, b64cleaner)

0 commit comments

Comments
 (0)