mirror of
https://github.com/ProtonMail/proton-bridge.git
synced 2025-12-10 04:36:43 +00:00
fix(GODT-2576): Correctly handle Forwarded messages from Thunderbird
Thunderbird uses `In-Reply-To` with `X-Forwarded-Message-Id` to signal to the SMTP server that it is forwarding a message.
This commit is contained in:
@ -60,6 +60,7 @@ type Message struct {
|
||||
References []string
|
||||
ExternalID string
|
||||
InReplyTo string
|
||||
XForward string
|
||||
}
|
||||
|
||||
type Attachment struct {
|
||||
@ -520,6 +521,9 @@ func parseMessageHeader(h message.Header, allowInvalidAddressLists bool) (Messag
|
||||
case "in-reply-to":
|
||||
m.InReplyTo = regexp.MustCompile("<(.*)>").ReplaceAllString(fields.Value(), "$1")
|
||||
|
||||
case "x-forwarded-message-id":
|
||||
m.XForward = regexp.MustCompile("<(.*)>").ReplaceAllString(fields.Value(), "$1")
|
||||
|
||||
case "references":
|
||||
for _, ref := range strings.Fields(fields.Value()) {
|
||||
for _, ref := range strings.Split(ref, ",") {
|
||||
|
||||
@ -786,6 +786,16 @@ func TestParseTextPlainWithDocxAttachmentCyrillic(t *testing.T) {
|
||||
assert.Equal(t, "АБВГДЃЕЖЗЅИЈКЛЉМНЊОПРСТЌУФХЧЏЗШ.docx", m.Attachments[0].Name)
|
||||
}
|
||||
|
||||
func TestParseInReplyToAndXForward(t *testing.T) {
|
||||
f := getFileReader("text_plain_utf8_reply_to_and_x_forward.eml")
|
||||
|
||||
m, err := Parse(f)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Equal(t, "00000@protonmail.com", m.XForward)
|
||||
require.Equal(t, "00000@protonmail.com", m.InReplyTo)
|
||||
}
|
||||
|
||||
func TestPatchNewLineWithHtmlBreaks(t *testing.T) {
|
||||
{
|
||||
input := []byte("\nfoo\nbar\n\n\nzz\nddd")
|
||||
|
||||
7
pkg/message/testdata/text_plain_utf8_reply_to_and_x_forward.eml
vendored
Normal file
7
pkg/message/testdata/text_plain_utf8_reply_to_and_x_forward.eml
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
From: Sender <sender@pm.me>
|
||||
To: Receiver <receiver@pm.me>
|
||||
Content-Type: text/plain; charset=utf-8
|
||||
X-Forwarded-Message-Id: <00000@protonmail.com>
|
||||
In-Reply-To: <00000@protonmail.com>
|
||||
|
||||
body
|
||||
Reference in New Issue
Block a user