mirror of
https://github.com/ProtonMail/proton-bridge.git
synced 2025-12-10 04:36:43 +00:00
fix(GODT-2966): Add more test regarding quoted/unquoted filename in attachment.
This commit is contained in:
@ -67,58 +67,46 @@ Feature: IMAP import messages
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
Scenario: Import message with attachment name encoded by RFC 2047 without quoting
|
Scenario Outline: Import multipart message with attachment <message>
|
||||||
When IMAP client "1" appends the following message to "INBOX":
|
When IMAP client "1" appends <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"
|
|
||||||
Received: by 2002:0:0:0:0:0:0:0 with SMTP id 0123456789abcdef; Wed, 30 Dec 2020 01:23:45 0000
|
|
||||||
|
|
||||||
--boundary
|
|
||||||
Content-Type: text/plain
|
|
||||||
|
|
||||||
Hello
|
|
||||||
|
|
||||||
--boundary
|
|
||||||
Content-Type: application/pdf; name==?US-ASCII?Q?filename?=
|
|
||||||
Content-Disposition: attachment; filename==?US-ASCII?Q?filename?=
|
|
||||||
|
|
||||||
somebytes
|
|
||||||
|
|
||||||
--boundary--
|
|
||||||
|
|
||||||
"""
|
|
||||||
Then it succeeds
|
Then it succeeds
|
||||||
# And IMAP client "1" eventually sees the following message in "INBOX" with this structure:
|
And IMAP client "1" eventually sees the following message in "INBOX" with this structure:
|
||||||
# """
|
"""
|
||||||
# {
|
{
|
||||||
# "from": "Bridge Test <bridgetest@pm.test>",
|
"from": "Bridge Test <bridgetest@pm.test>",
|
||||||
# "date": "01 Jan 80 00:00 +0000",
|
"date": "01 Jan 80 00:00 +0000",
|
||||||
# "to": "Internal Bridge <bridgetest@protonmail.com>",
|
"to": "Internal Bridge <bridgetest@protonmail.com>",
|
||||||
# "subject": "Message with attachment name encoded by RFC 2047 without quoting",
|
"subject": "Message with attachment name",
|
||||||
# "body-contains": "Hello",
|
"body-contains": "Hello",
|
||||||
# "content": {
|
"content": {
|
||||||
# "content-type": "multipart/mixed; boundary=\"boundary\"",
|
"content-type": "multipart/mixed",
|
||||||
# "sections":[
|
"sections":[
|
||||||
# {
|
{
|
||||||
# "content-type": "text/plain",
|
"content-type": "text/plain",
|
||||||
# "body-is": "Hello"
|
"body-is": "Hello"
|
||||||
# },
|
},
|
||||||
# {
|
{
|
||||||
# "content-type": "application/pdf",
|
"content-type": "text/html",
|
||||||
# "content-type-name": "=?US-ASCII?Q?filename?=",
|
"content-type-charset": "utf-8",
|
||||||
# "content-disposition": "attachment",
|
"transfer-encoding": "7bit",
|
||||||
# "content-disposition-filename": "=?US-ASCII?Q?filename?=",
|
"body-contains": "HELLO"
|
||||||
# "body-is": "somebytes"
|
},
|
||||||
# }
|
{
|
||||||
# ]
|
"content-type": "application/pdf",
|
||||||
# }
|
"content-type-name": <filename>,
|
||||||
# }
|
"content-disposition": "attachment",
|
||||||
# """
|
"content-disposition-filename": <filename>,
|
||||||
|
"body-is": "somebytes"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
Examples:
|
||||||
|
| message | filename |
|
||||||
|
| "multipart/mixed_with_attachment_encoded.eml" | "=?US-ASCII?Q?filename?=" |
|
||||||
|
# | "multipart/mixed_with_attachment_encoded_no_quote.eml" | =?US-ASCII?Q?filename?= | @todo GODT-2966
|
||||||
|
# | "multipart/mixed_with_attachment_no_quote.eml" | "filename" | @todo GODT-2966
|
||||||
|
|
||||||
# The message is imported as UTF-8 and the content type is determined at build time.
|
# The message is imported as UTF-8 and the content type is determined at build time.
|
||||||
Scenario: Import message as latin1 without content type
|
Scenario: Import message as latin1 without content type
|
||||||
@ -322,8 +310,6 @@ Feature: IMAP import messages
|
|||||||
Content-Type: multipart/mixed; boundary="boundary"
|
Content-Type: multipart/mixed; boundary="boundary"
|
||||||
Received: by 2002:0:0:0:0:0:0:0 with SMTP id 0123456789abcdef; Wed, 30 Dec 2020 01:23:45 0000
|
Received: by 2002:0:0:0:0:0:0:0 with SMTP id 0123456789abcdef; Wed, 30 Dec 2020 01:23:45 0000
|
||||||
|
|
||||||
--boundary
|
|
||||||
|
|
||||||
This is a multi-part message in MIME format.
|
This is a multi-part message in MIME format.
|
||||||
|
|
||||||
--boundary
|
--boundary
|
||||||
@ -366,9 +352,6 @@ Feature: IMAP import messages
|
|||||||
"content": {
|
"content": {
|
||||||
"content-type": "multipart/mixed",
|
"content-type": "multipart/mixed",
|
||||||
"sections":[
|
"sections":[
|
||||||
{
|
|
||||||
"body-is": "This is a multi-part message in MIME format."
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"content-type": "text/plain",
|
"content-type": "text/plain",
|
||||||
"content-type-charset": "utf-8",
|
"content-type-charset": "utf-8",
|
||||||
|
|||||||
@ -140,4 +140,82 @@ Feature: SMTP sending with attachment
|
|||||||
"Disposition": "attachment"
|
"Disposition": "attachment"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
Scenario Outline: Send message with attachment <UseCase>
|
||||||
|
When SMTP client "1" sends the following message from "[user:user1]@[domain]" to "[user:user2]@[domain]":
|
||||||
|
"""
|
||||||
|
Subject: Message with attachment name
|
||||||
|
Content-type: multipart/mixed; boundary="boundary"
|
||||||
|
Received: by 2002:0:0:0:0:0:0:0 with SMTP id 0123456789abcdef; Wed, 30 Dec 2020 01:23:45 0000
|
||||||
|
|
||||||
|
This is a multi-part message in MIME format.
|
||||||
|
|
||||||
|
--boundary
|
||||||
|
Content-Type: text/plain
|
||||||
|
|
||||||
|
Hello
|
||||||
|
|
||||||
|
--boundary
|
||||||
|
Content-Type: application/pdf; name=<filename>
|
||||||
|
Content-Disposition: attachment; filename=<filename>
|
||||||
|
|
||||||
|
somebytes
|
||||||
|
|
||||||
|
--boundary--
|
||||||
|
"""
|
||||||
|
Then it succeeds
|
||||||
|
And IMAP client "1" eventually sees the following message in "Sent" with this structure:
|
||||||
|
"""
|
||||||
|
{
|
||||||
|
"subject": "Message with attachment name",
|
||||||
|
"body-contains": "Hello",
|
||||||
|
"content": {
|
||||||
|
"content-type": "multipart/mixed",
|
||||||
|
"sections":[
|
||||||
|
{
|
||||||
|
"content-type": "text/plain",
|
||||||
|
"body-is": "Hello"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"content-type": "application/pdf",
|
||||||
|
"content-type-name": "filename",
|
||||||
|
"content-disposition": "attachment",
|
||||||
|
"content-disposition-filename": "filename",
|
||||||
|
"transfer-encoding":"base64",
|
||||||
|
"body-is": "c29tZWJ5dGVzDQo="
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
Examples:
|
||||||
|
| UseCase | filename |
|
||||||
|
| encoded quoted | "=?US-ASCII?Q?filename?=" |
|
||||||
|
# | non quoted | filename | @todo GODT-2974
|
||||||
|
|
||||||
|
Scenario: Send message with attachment with name unquoted containing special character
|
||||||
|
When SMTP client "1" sends the following message from "[user:user1]@[domain]" to "[user:user2]@[domain]":
|
||||||
|
"""
|
||||||
|
Subject: Message with attachment name
|
||||||
|
Content-type: multipart/mixed; boundary="boundary"
|
||||||
|
Received: by 2002:0:0:0:0:0:0:0 with SMTP id 0123456789abcdef; Wed, 30 Dec 2020 01:23:45 0000
|
||||||
|
|
||||||
|
This is a multi-part message in MIME format.
|
||||||
|
|
||||||
|
--boundary
|
||||||
|
Content-Type: text/plain
|
||||||
|
|
||||||
|
Hello
|
||||||
|
|
||||||
|
--boundary
|
||||||
|
Content-Type: application/pdf; name==?US-ASCII?Q?filename?=
|
||||||
|
Content-Disposition: attachment; filename==?US-ASCII?Q?filename?=
|
||||||
|
|
||||||
|
somebytes
|
||||||
|
|
||||||
|
--boundary--
|
||||||
|
"""
|
||||||
|
Then it fails
|
||||||
|
And bridge reports a message with "failed to collect attachments: mime: invalid media parameter"
|
||||||
27
tests/testdata/multipart/mixed_with_attachment_encoded.eml
vendored
Normal file
27
tests/testdata/multipart/mixed_with_attachment_encoded.eml
vendored
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
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
|
||||||
|
Content-type: multipart/mixed; boundary="boundary"
|
||||||
|
Received: by 2002:0:0:0:0:0:0:0 with SMTP id 0123456789abcdef; Wed, 30 Dec 2020 01:23:45 0000
|
||||||
|
|
||||||
|
This is a multi-part message in MIME format.
|
||||||
|
|
||||||
|
--boundary
|
||||||
|
Content-Type: text/plain
|
||||||
|
|
||||||
|
Hello
|
||||||
|
|
||||||
|
--boundary
|
||||||
|
Content-Type: text/html; charset=utf-8
|
||||||
|
Content-Transfer-Encoding: 7bit
|
||||||
|
|
||||||
|
<h1> HELLO </h1>
|
||||||
|
|
||||||
|
--boundary
|
||||||
|
Content-Type: application/pdf; name="=?US-ASCII?Q?filename?="
|
||||||
|
Content-Disposition: attachment; filename="=?US-ASCII?Q?filename?="
|
||||||
|
|
||||||
|
somebytes
|
||||||
|
|
||||||
|
--boundary--
|
||||||
27
tests/testdata/multipart/mixed_with_attachment_encoded_no_quote.eml
vendored
Normal file
27
tests/testdata/multipart/mixed_with_attachment_encoded_no_quote.eml
vendored
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
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
|
||||||
|
Content-type: multipart/mixed; boundary="boundary"
|
||||||
|
Received: by 2002:0:0:0:0:0:0:0 with SMTP id 0123456789abcdef; Wed, 30 Dec 2020 01:23:45 0000
|
||||||
|
|
||||||
|
This is a multi-part message in MIME format.
|
||||||
|
|
||||||
|
--boundary
|
||||||
|
Content-Type: text/plain
|
||||||
|
|
||||||
|
Hello
|
||||||
|
|
||||||
|
--boundary
|
||||||
|
Content-Type: text/html; charset=utf-8
|
||||||
|
Content-Transfer-Encoding: 7bit
|
||||||
|
|
||||||
|
<h1> HELLO </h1>
|
||||||
|
|
||||||
|
--boundary
|
||||||
|
Content-Type: application/pdf; name==?US-ASCII?Q?filename?=
|
||||||
|
Content-Disposition: attachment; filename==?US-ASCII?Q?filename?=
|
||||||
|
|
||||||
|
somebytes
|
||||||
|
|
||||||
|
--boundary--
|
||||||
27
tests/testdata/multipart/mixed_with_attachment_no_quote.eml
vendored
Normal file
27
tests/testdata/multipart/mixed_with_attachment_no_quote.eml
vendored
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
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
|
||||||
|
Content-type: multipart/mixed; boundary="boundary"
|
||||||
|
Received: by 2002:0:0:0:0:0:0:0 with SMTP id 0123456789abcdef; Wed, 30 Dec 2020 01:23:45 0000
|
||||||
|
|
||||||
|
This is a multi-part message in MIME format.
|
||||||
|
|
||||||
|
--boundary
|
||||||
|
Content-Type: text/plain
|
||||||
|
|
||||||
|
Hello
|
||||||
|
|
||||||
|
--boundary
|
||||||
|
Content-Type: text/html; charset=utf-8
|
||||||
|
Content-Transfer-Encoding: 7bit
|
||||||
|
|
||||||
|
<h1> HELLO </h1>
|
||||||
|
|
||||||
|
--boundary
|
||||||
|
Content-Type: application/pdf; name=filename
|
||||||
|
Content-Disposition: attachment; filename=filename
|
||||||
|
|
||||||
|
somebytes
|
||||||
|
|
||||||
|
--boundary--
|
||||||
Reference in New Issue
Block a user