mirror of
https://github.com/ProtonMail/proton-bridge.git
synced 2025-12-10 04:36:43 +00:00
fix(GODT-2638): Validate messages before import.
Ensure messages have required header fields and adhere to the rfc5322 spec before import.
This commit is contained in:
@ -9,6 +9,8 @@ Feature: IMAP Draft messages
|
||||
And IMAP client "1" selects "Drafts"
|
||||
When IMAP client "1" appends the following message to "Drafts":
|
||||
"""
|
||||
From: foo@bar.com
|
||||
Date: 01 Jan 1980 00:00:00 +0000
|
||||
|
||||
This is a dra
|
||||
"""
|
||||
@ -25,6 +27,8 @@ Feature: IMAP Draft messages
|
||||
And it succeeds
|
||||
And IMAP client "1" appends the following message to "Drafts":
|
||||
"""
|
||||
From: foo@bar.com
|
||||
Date: 01 Jan 1980 00:00:00 +0000
|
||||
Subject: Basic Draft
|
||||
Content-Type: text/plain
|
||||
To: someone@example.com
|
||||
|
||||
@ -12,6 +12,7 @@ Feature: IMAP import messages
|
||||
When IMAP client "1" appends the following message to "INBOX":
|
||||
"""
|
||||
From: Bridge Test <bridgetest@pm.test>
|
||||
Date: 01 Jan 1980 00:00:00 +0000
|
||||
To: Internal Bridge <bridgetest@example.com>
|
||||
Received: by 2002:0:0:0:0:0:0:0 with SMTP id 0123456789abcdef; Wed, 30 Dec 2020 01:23:45 0000
|
||||
Subject: Basic text/plain message
|
||||
@ -28,6 +29,7 @@ Feature: IMAP import messages
|
||||
When IMAP client "1" appends the following message to "INBOX":
|
||||
"""
|
||||
From: Bridge Test <bridgetest@pm.test>
|
||||
Date: 01 Jan 1980 00:00:00 +0000
|
||||
To: Internal Bridge <bridgetest@example.com>
|
||||
Subject: Message with double charset in content type
|
||||
Content-Type: text/plain; charset=utf-8; charset=utf-8
|
||||
@ -46,6 +48,7 @@ Feature: IMAP import messages
|
||||
When IMAP client "1" appends the following message to "INBOX":
|
||||
"""
|
||||
From: Bridge Test <bridgetest@pm.test>
|
||||
Date: 01 Jan 1980 00:00:00 +0000
|
||||
To: Internal Bridge <bridgetest@protonmail.com>
|
||||
Subject: Message with attachment name encoded by RFC 2047 without quoting
|
||||
Content-type: multipart/mixed; boundary="boundary"
|
||||
@ -96,6 +99,7 @@ Feature: IMAP import messages
|
||||
When IMAP client "1" appends the following message to "Sent":
|
||||
"""
|
||||
From: Foo <foo@example.com>
|
||||
Date: 01 Jan 1980 00:00:00 +0000
|
||||
To: Bridge Test <bridgetest@pm.test>
|
||||
Subject: Hello
|
||||
Received: by 2002:0:0:0:0:0:0:0 with SMTP id 0123456789abcdef; Wed, 30 Dec 2020 01:23:45 0000
|
||||
@ -112,6 +116,7 @@ Feature: IMAP import messages
|
||||
When IMAP client "1" appends the following message to "Inbox":
|
||||
"""
|
||||
From: Foo <foo@example.com>
|
||||
Date: 01 Jan 1980 00:00:00 +0000
|
||||
To: Bridge Test <bridgetest@pm.test>
|
||||
Subject: Hello
|
||||
|
||||
@ -127,6 +132,7 @@ Feature: IMAP import messages
|
||||
When IMAP client "1" appends the following message to "Sent":
|
||||
"""
|
||||
From: Foo <foo@example.com>
|
||||
Date: 01 Jan 1980 00:00:00 +0000
|
||||
To: Bridge Test <bridgetest@pm.test>
|
||||
Subject: Hello
|
||||
|
||||
@ -141,6 +147,8 @@ Feature: IMAP import messages
|
||||
Scenario Outline: Import message without sender to <mailbox>
|
||||
When IMAP client "1" appends the following message to "<mailbox>":
|
||||
"""
|
||||
From: Somebody@somewhere.org
|
||||
Date: 01 Jan 1980 00:00:00 +0000
|
||||
To: Lionel Richie <lionel@richie.com>
|
||||
Subject: RE: Hello, is it me you looking for?
|
||||
|
||||
@ -161,6 +169,7 @@ Feature: IMAP import messages
|
||||
When IMAP client "1" appends the following message to "INBOX":
|
||||
"""
|
||||
From: Foo <foo@example.com>
|
||||
Date: 01 Jan 1980 00:00:00 +0000
|
||||
To: Bridge Test <bridgetest@pm.test>
|
||||
Subject: Embedded message
|
||||
Content-Type: multipart/mixed; boundary="boundary"
|
||||
|
||||
@ -17,6 +17,7 @@ Feature: IMAP move messages by append and delete (without MOVE support, e.g., Ou
|
||||
"""
|
||||
Received: by 2002:0:0:0:0:0:0:0 with SMTP id 0123456789abcdef; Wed, 30 Dec 2020 01:23:45 0000
|
||||
From: sndr1@[domain]
|
||||
Date: 01 Jan 1980 00:00:00 +0000
|
||||
To: rcvr1@[domain]
|
||||
Subject: subj1
|
||||
|
||||
@ -27,6 +28,7 @@ Feature: IMAP move messages by append and delete (without MOVE support, e.g., Ou
|
||||
"""
|
||||
Received: by 2002:0:0:0:0:0:0:0 with SMTP id 0123456789abcdef; Wed, 30 Dec 2020 01:23:45 0000
|
||||
From: sndr2@[domain]
|
||||
Date: 01 Jan 1980 00:00:00 +0000
|
||||
To: rcvr2@[domain]
|
||||
Subject: subj2
|
||||
|
||||
|
||||
@ -13,7 +13,9 @@ Feature: SMTP sending with APPENDing to Sent
|
||||
# First do sending.
|
||||
When SMTP client "1" sends the following message from "[user:user]@[domain]" to "[user:to]@[domain]":
|
||||
"""
|
||||
From: [user:user]@[domain]
|
||||
To: Internal Bridge <[user:to]@[domain]>
|
||||
Date: 01 Jan 1980 00:00:00 +0000
|
||||
Subject: Manual send and append
|
||||
Message-ID: bridgemessage42
|
||||
|
||||
@ -37,7 +39,9 @@ Feature: SMTP sending with APPENDing to Sent
|
||||
# Then simulate manual append to Sent mailbox - message should be detected as a duplicate.
|
||||
When IMAP client "1" appends the following message to "Sent":
|
||||
"""
|
||||
From: [user:user]@[domain]
|
||||
To: Internal Bridge <[user:to]@[domain]>
|
||||
Date: 01 Jan 1980 00:00:00 +0000
|
||||
Subject: Manual send and append
|
||||
Message-ID: bridgemessage42
|
||||
|
||||
|
||||
@ -446,6 +446,13 @@ func (s *scenario) imapClientAppendsTheFollowingMessagesToMailbox(clientID strin
|
||||
return err
|
||||
}
|
||||
|
||||
for idx, message := range messages {
|
||||
if len(message.Date) == 0 {
|
||||
logrus.Warnf("Appended message has no date, adding default one so it does not fail test")
|
||||
}
|
||||
messages[idx].Date = "23 Feb 80 00:00 GMT"
|
||||
}
|
||||
|
||||
for _, message := range messages {
|
||||
if err := clientAppend(client, mailbox, string(message.Build())); err != nil {
|
||||
s.t.pushError(err)
|
||||
|
||||
1
tests/testdata/text_plain_latin1.eml
vendored
1
tests/testdata/text_plain_latin1.eml
vendored
@ -1,4 +1,5 @@
|
||||
From: Sender <sender@pm.me>
|
||||
Date: 01 Jan 1980 00:00:00 +0000
|
||||
To: Receiver <receiver@pm.me>
|
||||
Received: by 2002:0:0:0:0:0:0:0 with SMTP id 0123456789abcdef; Wed, 30 Dec 2020 01:23:45 0000
|
||||
Content-Type: text/plain; charset=ISO-8859-1
|
||||
|
||||
1
tests/testdata/text_plain_unknown_latin1.eml
vendored
1
tests/testdata/text_plain_unknown_latin1.eml
vendored
@ -1,4 +1,5 @@
|
||||
From: Sender <sender@pm.me>
|
||||
Date: 01 Jan 1980 00:00:00 +0000
|
||||
To: Receiver <receiver@pm.me>
|
||||
Received: by 2002:0:0:0:0:0:0:0 with SMTP id 0123456789abcdef; Wed, 30 Dec 2020 01:23:45 0000
|
||||
Content-Type: text/plain
|
||||
|
||||
1
tests/testdata/text_plain_wrong_latin1.eml
vendored
1
tests/testdata/text_plain_wrong_latin1.eml
vendored
@ -1,4 +1,5 @@
|
||||
From: Sender <sender@pm.me>
|
||||
Date: 01 Jan 1980 00:00:00 +0000
|
||||
To: Receiver <receiver@pm.me>
|
||||
Received: by 2002:0:0:0:0:0:0:0 with SMTP id 0123456789abcdef; Wed, 30 Dec 2020 01:23:45 0000
|
||||
Content-Type: text/plain; charset=KOI8R
|
||||
|
||||
Reference in New Issue
Block a user