forked from Silverfish/proton-bridge
GODT-2142: Also permit split by comma in References header
This commit is contained in:
@ -163,8 +163,7 @@ func sendWithKey( //nolint:funlen
|
||||
authAddrID string,
|
||||
addrMode vault.AddressMode,
|
||||
settings liteapi.MailSettings,
|
||||
userKR *crypto.KeyRing,
|
||||
addrKR *crypto.KeyRing,
|
||||
userKR, addrKR *crypto.KeyRing,
|
||||
emails []string,
|
||||
from string,
|
||||
to []string,
|
||||
@ -177,7 +176,8 @@ func sendWithKey( //nolint:funlen
|
||||
|
||||
var decBody string
|
||||
|
||||
switch message.MIMEType { //nolint:exhaustive
|
||||
// nolint:exhaustive
|
||||
switch message.MIMEType {
|
||||
case rfc822.TextHTML:
|
||||
decBody = string(message.RichBody)
|
||||
|
||||
|
||||
@ -30,7 +30,6 @@ import (
|
||||
"github.com/ProtonMail/go-rfc5322"
|
||||
"github.com/ProtonMail/proton-bridge/v2/pkg/message/parser"
|
||||
pmmime "github.com/ProtonMail/proton-bridge/v2/pkg/mime"
|
||||
"github.com/bradenaw/juniper/xslices"
|
||||
"github.com/emersion/go-message"
|
||||
"github.com/jaytaylor/html2text"
|
||||
"github.com/pkg/errors"
|
||||
@ -497,9 +496,11 @@ func parseMessageHeader(h message.Header) (Message, error) { //nolint:funlen
|
||||
m.InReplyTo = regexp.MustCompile("<(.*)>").ReplaceAllString(fields.Value(), "$1")
|
||||
|
||||
case "references":
|
||||
m.References = append(m.References, xslices.Map(strings.Fields(fields.Value()), func(ref string) string {
|
||||
return strings.Trim(ref, "<>")
|
||||
})...)
|
||||
for _, ref := range strings.Fields(fields.Value()) {
|
||||
for _, ref := range strings.Split(ref, ",") {
|
||||
m.References = append(m.References, strings.Trim(ref, "<>"))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -587,7 +587,22 @@ func TestParseMessageReferences(t *testing.T) {
|
||||
m, err := Parse(f)
|
||||
require.NoError(t, err)
|
||||
|
||||
assert.Len(t, m.References, 2)
|
||||
assert.ElementsMatch(t, m.References, []string{
|
||||
`PMZV4VZMRM@something.com`,
|
||||
`OEUOEUEOUOUOU770B9QNZWFVGM@protonmail.ch`,
|
||||
})
|
||||
}
|
||||
|
||||
func TestParseMessageReferencesComma(t *testing.T) {
|
||||
f := getFileReader("references-comma.eml")
|
||||
|
||||
m, err := Parse(f)
|
||||
require.NoError(t, err)
|
||||
|
||||
assert.ElementsMatch(t, m.References, []string{
|
||||
`PMZV4VZMRM@something.com`,
|
||||
`OEUOEUEOUOUOU770B9QNZWFVGM@protonmail.ch`,
|
||||
})
|
||||
}
|
||||
|
||||
func TestParsePanic(t *testing.T) {
|
||||
|
||||
27
pkg/message/testdata/references-comma.eml
vendored
Normal file
27
pkg/message/testdata/references-comma.eml
vendored
Normal file
@ -0,0 +1,27 @@
|
||||
Content-Type: multipart/mixed;
|
||||
boundary=987c7102dcaf02d01860ce777b465f86d39ec16a3b4e12605eb6b0eb200a
|
||||
X-Original-To: someone@protonmail.com
|
||||
Delivered-To: someone@protonmail.com
|
||||
Date: Sun, 04 Aug 2019 13:03:26 +0000
|
||||
From: ProtonVPN <support@protonvpn.something.com>
|
||||
Reply-To: ProtonVPN <support+id493949@protonvpn.something.com>
|
||||
To: someone <someone@protonmail.com>
|
||||
Message-Id: <OEUOEUOUOU_5d46d79df036f_1d78b3fd8f42bcf2014719e_sprut@something.com>
|
||||
In-Reply-To: <OEUOEUEOUOUOU770B9QNZWFVGM@protonmail.ch>
|
||||
References: <PMZV4VZMRM@something.com>,<OEUOEUEOUOUOU770B9QNZWFVGM@protonmail.ch>
|
||||
Subject: Some test subject
|
||||
Mime-Version: 1.0
|
||||
|
||||
--987c7102dcaf02d01860ce777b465f86d39ec16a3b4e12605eb6b0eb200a
|
||||
Content-Transfer-Encoding: quoted-printable
|
||||
Content-Type: text/html; charset=utf-8
|
||||
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.=
|
||||
w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html>
|
||||
<body>
|
||||
test test test
|
||||
</body>
|
||||
</html>
|
||||
|
||||
--987c7102dcaf02d01860ce777b465f86d39ec16a3b4e12605eb6b0eb200a--
|
||||
Reference in New Issue
Block a user