Fix: remove extra whitespace from IMAP BODY responses

This commit is contained in:
mdecimus 2023-11-02 14:47:36 +01:00
parent 6a7d79acb6
commit 0881309819
15 changed files with 71 additions and 71 deletions

View file

@ -334,10 +334,7 @@ impl<'x> BodyPart<'x> {
body_parameters,
extension,
} => {
for (pos, part) in body_parts.iter().enumerate() {
if pos > 0 {
buf.push(b' ');
}
for part in body_parts.iter() {
part.serialize(buf, is_extended);
}
buf.push(b' ');
@ -1173,7 +1170,7 @@ mod tests {
},
concat!(
"BODY ((\"text\" \"PLAIN\" (\"CHARSET\" \"US-ASCII\") ",
"NIL NIL \"7BIT\" 1152 23) ",
"NIL NIL \"7BIT\" 1152 23)",
"(\"text\" \"PLAIN\" (\"CHARSET\" \"US-ASCII\" \"NAME\" \"cc.diff\") ",
"\"<960723163407.20117h@cac.washington.edu>\" \"Compiler diff\" ",
"\"BASE64\" 4554 73) \"MIXED\")",
@ -1283,14 +1280,14 @@ mod tests {
concat!(
"BODYSTRUCTURE (((\"text\" \"PLAIN\" (\"CHARSET\" \"UTF-8\") ",
"\"<111@domain.com>\" \"Text part\" \"7BIT\" 1152 23 \"8o3456\" ",
"(\"inline\" ()) \"en-US\" \"right here\") ",
"(\"inline\" ()) \"en-US\" \"right here\")",
"(\"text\" \"HTML\" (\"CHARSET\" \"UTF-8\") ",
"\"<54535@domain.com>\" \"HTML part\" \"8BIT\" 45345 994 \"53454\" ",
"(\"attachment\" (\"filename\" \"myfile.txt\")) ",
"(\"en-US\" \"de-DE\") ",
"\"right there\") \"ALTERNATIVE\" (\"x-param\" ",
"\"a very special parameter\") ",
"NIL \"en-US\" \"unknown\") ",
"NIL \"en-US\" \"unknown\")",
"(\"APPLICATION\" \"MSWORD\" (\"NAME\" \"chimichangas.docx\") ",
"\"<4444@chimi.changa>\" \"Chimichangas recipe\" \"base64\"",
" 84723 \"1234\" ",

View file

@ -9,6 +9,9 @@ max-size = 52428800
max-failures = 3
allow-plain-text = false
[imap.folders]
all-messages = true
[imap.folders.name]
shared = "Shared Folders"
all = "All Mail"

View file

@ -3,25 +3,25 @@ BODY (
"text" "plain" (
"charset" "us-ascii"
) NIL NIL "7bit" 262 7
) (
)(
"text" "plain" (
"charset" "US-ASCII"
) NIL NIL "7bit" 111 3
) (
)(
(
"text" "basic" (
"charset" "us-ascii"
) NIL NIL "base64" 85 2
) (
)(
"text" "jpeg" (
"charset" "us-ascii"
) NIL NIL "base64" 44 1
) "parallel"
) (
)(
"text" "enriched" (
"charset" "us-ascii"
) NIL NIL "7bit" 140 5
) (
)(
"message" "rfc822" NIL NIL NIL NIL 223 (
NIL "(subject in US-ASCII)" NIL NIL NIL NIL NIL NIL NIL NIL
) (
@ -37,27 +37,27 @@ BODYSTRUCTURE (
"text" "plain" (
"charset" "us-ascii"
) NIL NIL "7bit" 262 7 "1ba9f4410aca245ffe18870d1767eaf1" NIL NIL NIL
) (
)(
"text" "plain" (
"charset" "US-ASCII"
) NIL NIL "7bit" 111 3 "457a84e4830817334703ecead7a71bdf" NIL NIL NIL
) (
)(
(
"text" "basic" (
"charset" "us-ascii"
) NIL NIL "base64" 85 2 "c6e3404e683fdeb88e96dfed0abbddad" NIL NIL NIL
) (
)(
"text" "jpeg" (
"charset" "us-ascii"
) NIL NIL "base64" 44 1 "88217c7613d6252c87ba0cd279f1e93c" NIL NIL NIL
) "parallel" (
"boundary" "unique-boundary-2"
) NIL NIL NIL
) (
)(
"text" "enriched" (
"charset" "us-ascii"
) NIL NIL "7bit" 140 5 "4a5cd280a875e791bd6d767dcf60c43d" NIL NIL NIL
) (
)(
"message" "rfc822" NIL NIL NIL NIL 223 (
NIL "(subject in US-ASCII)" NIL NIL NIL NIL NIL NIL NIL NIL
) (

View file

@ -3,11 +3,11 @@ BODY (
"message" "external-body" (
"name" "BodyFormats.ps" "site" "thumper.bellcore.com" "mode" "image" "access-type" "ANON-FTP" "directory" "pub" "expiration" "Fri, 14 Jun 1991 19:13:14 -0400 (EDT)"
) NIL NIL NIL 79
) (
)(
"message" "external-body" (
"access-type" "local-file" "name" "/u/nsb/writing/rfcs/RFC-MIME.ps" "site" "thumper.bellcore.com" "expiration" "Fri, 14 Jun 1991 19:13:14 -0400 (EDT)"
) NIL NIL NIL 79
) (
)(
"message" "external-body" (
"access-type" "mail-server" "server" "listserv@bogus.bitnet" "expiration" "Fri, 14 Jun 1991 19:13:14 -0400 (EDT)"
) NIL NIL NIL 97
@ -19,11 +19,11 @@ BODYSTRUCTURE (
"message" "external-body" (
"name" "BodyFormats.ps" "site" "thumper.bellcore.com" "mode" "image" "access-type" "ANON-FTP" "directory" "pub" "expiration" "Fri, 14 Jun 1991 19:13:14 -0400 (EDT)"
) NIL NIL NIL 79 "13a120642a010037cbc238c999349116" NIL NIL NIL
) (
)(
"message" "external-body" (
"access-type" "local-file" "name" "/u/nsb/writing/rfcs/RFC-MIME.ps" "site" "thumper.bellcore.com" "expiration" "Fri, 14 Jun 1991 19:13:14 -0400 (EDT)"
) NIL NIL NIL 79 "13a120642a010037cbc238c999349116" NIL NIL NIL
) (
)(
"message" "external-body" (
"access-type" "mail-server" "server" "listserv@bogus.bitnet" "expiration" "Fri, 14 Jun 1991 19:13:14 -0400 (EDT)"
) NIL NIL NIL 97 "6f6c2486f2516ed45542404973c1cebb" NIL NIL NIL

View file

@ -3,7 +3,7 @@ BODY (
"text" "plain" (
"charset" "us-ascii"
) NIL NIL "7bit" 61 5
) (
)(
"message" "rfc822" NIL NIL NIL "7bit" 1979 (
"Thu, 13 Aug 1998 17:42:41 +1000" "Map of Argentina with Description" (
(
@ -27,7 +27,7 @@ BODY (
"text" "plain" (
"charset" "us-ascii"
) NIL NIL "7bit" 355 12
) (
)(
"image" "gif" (
"name" "map_of_Argentina.gif"
) NIL NIL "base64" 389
@ -41,7 +41,7 @@ BODYSTRUCTURE (
"text" "plain" (
"charset" "us-ascii"
) NIL NIL "7bit" 61 5 "63aa55d7eacd3e7d4af551d3d7f8fe46" NIL NIL NIL
) (
)(
"message" "rfc822" NIL NIL NIL "7bit" 1979 (
"Thu, 13 Aug 1998 17:42:41 +1000" "Map of Argentina with Description" (
(
@ -65,7 +65,7 @@ BODYSTRUCTURE (
"text" "plain" (
"charset" "us-ascii"
) NIL NIL "7bit" 355 12 "47027313db254547987c7eb4be377593" NIL NIL NIL
) (
)(
"image" "gif" (
"name" "map_of_Argentina.gif"
) NIL NIL "base64" 389 "5359a63540c1a8eae06a27e8760e1501" (

View file

@ -3,11 +3,11 @@ BODY (
"text" "plain" (
"charset" "us-ascii"
) NIL NIL "7bit" 48 1
) (
)(
"text" "enriched" (
"charset" "us-ascii"
) NIL NIL "7bit" 69 2
) (
)(
"application" "x-whatever" NIL NIL NIL NIL 51
) "alternative"
)
@ -17,11 +17,11 @@ BODYSTRUCTURE (
"text" "plain" (
"charset" "us-ascii"
) NIL NIL "7bit" 48 1 "2229d79e5de40eae37c43fe934adbd24" NIL NIL NIL
) (
)(
"text" "enriched" (
"charset" "us-ascii"
) NIL NIL "7bit" 69 2 "1aba0fd91c6544b8626008f78b83c3f9" NIL NIL NIL
) (
)(
"application" "x-whatever" NIL NIL NIL NIL 51 "7f7ef645554f637854b8acdd853aa612" NIL NIL NIL
) "alternative" (
"boundary" "boundary42"

View file

@ -3,7 +3,7 @@ BODY (
"text" "plain" (
"charset" "us-ascii"
) NIL NIL "7bit" 45 1
) (
)(
(
"message" NIL NIL NIL NIL NIL 100 (
"Fri, 26 Mar 1993 11:13:32 +0200" "my opinion" NIL NIL NIL NIL NIL NIL NIL NIL
@ -12,7 +12,7 @@ BODY (
"charset" "us-ascii"
) NIL NIL "7bit" 22 1
) 0
) (
)(
"message" NIL NIL NIL NIL NIL 125 (
"Fri, 26 Mar 1993 10:07:13 -0500" "my different opinion" NIL NIL NIL NIL NIL NIL NIL NIL
) (
@ -29,7 +29,7 @@ BODYSTRUCTURE (
"text" "plain" (
"charset" "us-ascii"
) NIL NIL "7bit" 45 1 "f7f7e917e54763330bc648984459b38e" NIL NIL NIL
) (
)(
(
"message" NIL NIL NIL NIL NIL 100 (
"Fri, 26 Mar 1993 11:13:32 +0200" "my opinion" NIL NIL NIL NIL NIL NIL NIL NIL
@ -38,7 +38,7 @@ BODYSTRUCTURE (
"charset" "us-ascii"
) NIL NIL "7bit" 22 1 "1ec4e1f0175dc661a12854b33879ce9b" NIL NIL NIL
) 0 "ef1527984c599523c90fb184a8fdfd61" NIL NIL NIL
) (
)(
"message" NIL NIL NIL NIL NIL 125 (
"Fri, 26 Mar 1993 10:07:13 -0500" "my different opinion" NIL NIL NIL NIL NIL NIL NIL NIL
) (

View file

@ -3,7 +3,7 @@ BODY (
"text" "plain" (
"charset" "us-ascii"
) NIL NIL "7bit" 79 1
) (
)(
"text" "plain" (
"charset" "us-ascii"
) NIL NIL "7bit" 76 2
@ -15,7 +15,7 @@ BODYSTRUCTURE (
"text" "plain" (
"charset" "us-ascii"
) NIL NIL "7bit" 79 1 "b35878dedb7cd0aa6934f90df9d517b0" NIL NIL NIL
) (
)(
"text" "plain" (
"charset" "us-ascii"
) NIL NIL "7bit" 76 2 "d3905bfd2a53ad0a4438d01bf271677a" NIL NIL NIL

View file

@ -3,7 +3,7 @@ BODY (
"text" "plain" (
"charset" "utf-8"
) NIL NIL "quoted-printable" 87 2
) (
)(
"text" "html" (
"charset" "utf-8"
) NIL NIL "quoted-printable" 93 2
@ -19,7 +19,7 @@ BODYSTRUCTURE (
)
) NIL NIL
) (
)(
"text" "html" (
"charset" "utf-8"
) NIL NIL "quoted-printable" 93 2 "bb2724458c0a6183195d922d711523c0" (

View file

@ -3,34 +3,34 @@ BODY (
"text" "plain" (
"charset" "us-ascii"
) NIL NIL "7bit" 1 0
) (
)(
(
(
(
"text" "plain" (
"charset" "us-ascii"
) NIL NIL "7bit" 1 0
) (
)(
"image" "jpeg" NIL NIL NIL NIL 1
) (
)(
"text" "plain" (
"charset" "us-ascii"
) NIL NIL "7bit" 1 0
) "mixed"
) (
)(
(
"text" "html" (
"charset" "us-ascii"
) NIL NIL "7bit" 14 0
) (
)(
"image" "jpeg" NIL NIL NIL NIL 1
) "related"
) "alternative"
) (
)(
"image" "jpeg" NIL NIL NIL NIL 1
) (
)(
"application" "x-excel" NIL NIL NIL NIL 1
) (
)(
"message" "rfc822" NIL NIL NIL NIL 13 (
NIL "J" NIL NIL NIL NIL NIL NIL NIL NIL
) (
@ -39,7 +39,7 @@ BODY (
) NIL NIL "7bit" 1 0
) 0
) "mixed"
) (
)(
"text" "plain" (
"charset" "us-ascii"
) NIL NIL "7bit" 1 0
@ -55,7 +55,7 @@ BODYSTRUCTURE (
)
) NIL NIL
) (
)(
(
(
(
@ -66,13 +66,13 @@ BODYSTRUCTURE (
)
) NIL NIL
) (
)(
"image" "jpeg" NIL NIL NIL NIL 1 "0d61f8370cad1d412f80b84d143e1257" (
"inline" (
)
) NIL NIL
) (
)(
"text" "plain" (
"charset" "us-ascii"
) NIL NIL "7bit" 1 0 "f623e75af30e62bbd73d6df5b50bb7b5" (
@ -83,12 +83,12 @@ BODYSTRUCTURE (
) "mixed" (
"boundary" "4"
) NIL NIL NIL
) (
)(
(
"text" "html" (
"charset" "us-ascii"
) NIL NIL "7bit" 14 0 "ece7293a99c7e12f8d044b683e5c2f33" NIL NIL NIL
) (
)(
"image" "jpeg" NIL NIL NIL NIL 1 "800618943025315f869e4e1f09471012" NIL NIL NIL
) "related" (
"boundary" "5"
@ -96,15 +96,15 @@ BODYSTRUCTURE (
) "alternative" (
"boundary" "3"
) NIL NIL NIL
) (
)(
"image" "jpeg" NIL NIL NIL NIL 1 "dfcf28d0734569a6a693bc8194de62bf" (
"attachment" (
)
) NIL NIL
) (
)(
"application" "x-excel" NIL NIL NIL NIL 1 "c1d9f50f86825a1a2302ec2449c17196" NIL NIL NIL
) (
)(
"message" "rfc822" NIL NIL NIL NIL 13 (
NIL "J" NIL NIL NIL NIL NIL NIL NIL NIL
) (
@ -115,7 +115,7 @@ BODYSTRUCTURE (
) "mixed" (
"boundary" "2"
) NIL NIL NIL
) (
)(
"text" "plain" (
"charset" "us-ascii"
) NIL NIL "7bit" 1 0 "a5f3c6a11b03839d46af9fb43c97c188" (

View file

@ -3,7 +3,7 @@ BODY (
"text" "plain" (
"charset" "utf-8"
) NIL NIL "7bit" 54 0
) (
)(
"message" "rfc822" NIL NIL NIL "base64" 1179 (
"Tue, 14 Dec 2021 11:48:25 +0100" "HTML test" (
(
@ -27,7 +27,7 @@ BODY (
"text" "plain" (
"charset" "utf-8" "format" "flowed"
) NIL NIL "7bit" 30 0
) (
)(
"text" "html" (
"charset" "utf-8"
) NIL NIL "7bit" 173 8
@ -41,7 +41,7 @@ BODYSTRUCTURE (
"text" "plain" (
"charset" "utf-8"
) NIL NIL "7bit" 54 0 "e377afc895a2c4c0d17b378f355de59e" NIL NIL NIL
) (
)(
"message" "rfc822" NIL NIL NIL "base64" 1179 (
"Tue, 14 Dec 2021 11:48:25 +0100" "HTML test" (
(
@ -65,7 +65,7 @@ BODYSTRUCTURE (
"text" "plain" (
"charset" "utf-8" "format" "flowed"
) NIL NIL "7bit" 30 0 "6891396510cbadf4e2cfe31aee5bd25f" NIL NIL NIL
) (
)(
"text" "html" (
"charset" "utf-8"
) NIL NIL "7bit" 173 8 "1a04bd2ec90f44a42792eacdc14fe8ea" NIL NIL NIL

View file

@ -3,7 +3,7 @@ BODY (
"text" "html" (
"charset" "us-ascii"
) NIL NIL "base64" 239 3
) (
)(
"message" "rfc822" NIL NIL NIL NIL 723 (
NIL "Exporting my book about coffee tables" (
(
@ -23,7 +23,7 @@ BODY (
"text" "plain" (
"charset" "utf-16"
) NIL NIL "quoted-printable" 228 3
) (
)(
"image" "gif" (
"name" "Book about ☕ tables.gif"
) NIL NIL "Base64" 56
@ -37,7 +37,7 @@ BODYSTRUCTURE (
"text" "html" (
"charset" "us-ascii"
) NIL NIL "base64" 239 3 "07aab44e51c5f1833a5d19f2e1804c4b" NIL NIL NIL
) (
)(
"message" "rfc822" NIL NIL NIL NIL 723 (
NIL "Exporting my book about coffee tables" (
(
@ -57,7 +57,7 @@ BODYSTRUCTURE (
"text" "plain" (
"charset" "utf-16"
) NIL NIL "quoted-printable" 228 3 "3a942a99cdd8a099ae107d3867ec20fb" NIL NIL NIL
) (
)(
"image" "gif" (
"name" "Book about ☕ tables.gif"
) NIL NIL "Base64" 56 "d40fa7f401e9dc2df56cbb740d65ff52" (

View file

@ -34,7 +34,7 @@ BODY (
"charset" "us-ascii"
) NIL NIL "7bit" 8 1
) 0
) (
)(
"message" NIL NIL NIL NIL NIL 42 (
NIL "m2" (
(
@ -94,7 +94,7 @@ BODYSTRUCTURE (
"charset" "us-ascii"
) NIL NIL "7bit" 8 1 "8dc313ad8cf1d82dbe8d46f5f0d3d79c" NIL NIL NIL
) 0 "702907ad1c165219425153a8f0a5f578" NIL NIL NIL
) (
)(
"message" NIL NIL NIL NIL NIL 42 (
NIL "m2" (
(

View file

@ -3,7 +3,7 @@ BODY (
"text" "x-myown" (
"charset" "us-ascii"
) NIL NIL "7bit" 6 1
) (
)(
"message" "rfc822" NIL NIL NIL NIL 280 (
"Sun, 12 Aug 2012 12:34:56 +0300" "submsg" (
(
@ -23,7 +23,7 @@ BODY (
"text" "html" (
"charset" "us-ascii"
) NIL NIL "7bit" 19 1
) (
)(
"text" "plain" (
"charset" "us-ascii"
) NIL NIL "7bit" 20 1
@ -37,7 +37,7 @@ BODYSTRUCTURE (
"text" "x-myown" (
"charset" "us-ascii"
) NIL NIL "7bit" 6 1 "b1946ac92492d2347c6235b4d2611184" NIL NIL NIL
) (
)(
"message" "rfc822" NIL NIL NIL NIL 280 (
"Sun, 12 Aug 2012 12:34:56 +0300" "submsg" (
(
@ -57,7 +57,7 @@ BODYSTRUCTURE (
"text" "html" (
"charset" "us-ascii"
) NIL NIL "7bit" 19 1 "35c5b687e359e8ce7be1f1ecafd9b475" NIL NIL NIL
) (
)(
"text" "plain" (
"charset" "us-ascii"
) NIL NIL "7bit" 20 1 "deeff770fadb17c664d431b97bcd05c5" NIL NIL NIL

View file

@ -63,7 +63,7 @@ pub async fn test(imap: &mut ImapConnection, _imap_check: &mut ImapConnection) {
))
.assert_contains(concat!(
"BODYSTRUCTURE ((\"text\" \"html\" (\"charset\" \"us-ascii\") NIL NIL ",
"\"base64\" 239 3 \"07aab44e51c5f1833a5d19f2e1804c4b\" NIL NIL NIL) ",
"\"base64\" 239 3 \"07aab44e51c5f1833a5d19f2e1804c4b\" NIL NIL NIL)",
"(\"message\" \"rfc822\" NIL NIL NIL NIL 723 ",
"(NIL \"Exporting my book about coffee tables\" ",
"((\"Cosmo Kramer\" NIL \"kramer\" \"kramerica.com\")) ",
@ -71,7 +71,7 @@ pub async fn test(imap: &mut ImapConnection, _imap_check: &mut ImapConnection) {
"((\"Cosmo Kramer\" NIL \"kramer\" \"kramerica.com\")) ",
"NIL NIL NIL NIL NIL) ",
"((\"text\" \"plain\" (\"charset\" \"utf-16\") NIL NIL ",
"\"quoted-printable\" 228 3 \"3a942a99cdd8a099ae107d3867ec20fb\" NIL NIL NIL) ",
"\"quoted-printable\" 228 3 \"3a942a99cdd8a099ae107d3867ec20fb\" NIL NIL NIL)",
"(\"image\" \"gif\" (\"name\" \"Book about ☕ tables.gif\") ",
"NIL NIL \"Base64\" 56 \"d40fa7f401e9dc2df56cbb740d65ff52\" ",
"(\"attachment\" ()) NIL NIL) \"mixed\" (\"boundary\" \"giddyup\") NIL NIL NIL)",