Skip to content

Commit

Permalink
兼容有些邮箱客户端没有按照RFC2045规定分割Base64 编码的输出
Browse files Browse the repository at this point in the history
  • Loading branch information
huangshaokun committed Jan 15, 2025
1 parent 15961ba commit bea028d
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 4 deletions.
4 changes: 2 additions & 2 deletions encode.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import (
"encoding/base64"
"io"
"mime"
"mime/quotedprintable"
"net/textproto"
"sort"
"strings"
"time"

"github.com/huangshaokun/mimequotedprintable"
"github.com/jhillyerd/enmime/v2/internal/coding"
"github.com/jhillyerd/enmime/v2/internal/stringutil"
)
Expand Down Expand Up @@ -243,7 +243,7 @@ func (p *Part) encodeContent(b *bufio.Writer, cte transferEncoding) (err error)
text = text[lineLen:]
}
case teQuoted:
qp := quotedprintable.NewWriter(b)
qp := mimequotedprintable.NewWriter(b)
if _, err = qp.Write(p.Content); err != nil {
return err
}
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ require (
github.com/cention-sany/utf7 v0.0.0-20170124080048-26cad61bd60a
github.com/go-test/deep v1.1.1
github.com/gogs/chardet v0.0.0-20211120154057-b7413eaefb8f
github.com/huangshaokun/mimequotedprintable v0.0.0-20230626102010-a5b2166f9691
github.com/jaytaylor/html2text v0.0.0-20230321000545-74c2419ad056
github.com/pkg/errors v0.9.1
github.com/stretchr/testify v1.9.0
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ github.com/go-test/deep v1.1.1 h1:0r/53hagsehfO4bzD2Pgr/+RgHqhmf+k1Bpse2cTu1U=
github.com/go-test/deep v1.1.1/go.mod h1:5C2ZWiW0ErCdrYzpqxLbTX7MG14M9iiw8DgHncVwcsE=
github.com/gogs/chardet v0.0.0-20211120154057-b7413eaefb8f h1:3BSP1Tbs2djlpprl7wCLuiqMaUh5SJkkzI2gDs+FgLs=
github.com/gogs/chardet v0.0.0-20211120154057-b7413eaefb8f/go.mod h1:Pcatq5tYkCW2Q6yrR2VRHlbHpZ/R4/7qyL1TCF7vl14=
github.com/huangshaokun/mimequotedprintable v0.0.0-20230626102010-a5b2166f9691 h1:cMH8l7waIU0+24EihDQBtCfpwdHsvYNaNgOOg2iyAPE=
github.com/huangshaokun/mimequotedprintable v0.0.0-20230626102010-a5b2166f9691/go.mod h1:gDBKZcuLIpRM4uX1/Dv2jLAF+9Fqf5zy0Rg2XzPh+Iw=
github.com/jaytaylor/html2text v0.0.0-20230321000545-74c2419ad056 h1:iCHtR9CQyktQ5+f3dMVZfwD2KWJUgm7M0gdL9NGr8KA=
github.com/jaytaylor/html2text v0.0.0-20230321000545-74c2419ad056/go.mod h1:CVKlgaMiht+LXvHG173ujK6JUhZXKb2u/BQtjPDIvyk=
github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
Expand Down
4 changes: 2 additions & 2 deletions part.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ import (
"encoding/base64"
"io"
"math/rand"
"mime/quotedprintable"
"net/textproto"
"strconv"
"strings"
"time"

"github.com/gogs/chardet"
"github.com/huangshaokun/mimequotedprintable"
"github.com/jhillyerd/enmime/v2/internal/coding"
inttp "github.com/jhillyerd/enmime/v2/internal/textproto"
"github.com/jhillyerd/enmime/v2/mediatype"
Expand Down Expand Up @@ -290,7 +290,7 @@ func (p *Part) decodeContent(r io.Reader, readPartErrorPolicy ReadPartErrorPolic
switch strings.ToLower(encoding) {
case cteQuotedPrintable:
contentReader = coding.NewQPCleaner(contentReader)
contentReader = quotedprintable.NewReader(contentReader)
contentReader = mimequotedprintable.NewReader(contentReader)
case cteBase64:
b64cleaner = coding.NewBase64Cleaner(contentReader)
contentReader = base64.NewDecoder(base64.RawStdEncoding, b64cleaner)
Expand Down

0 comments on commit bea028d

Please sign in to comment.