65 lines
2.4 KiB
Diff
65 lines
2.4 KiB
Diff
|
From ec2c5ffde7a1ca63219d47831725599e7de76f7f Mon Sep 17 00:00:00 2001
|
||
|
From: Timo Sirainen <timo.sirainen@open-xchange.com>
|
||
|
Date: Wed, 18 Nov 2020 20:48:11 +0200
|
||
|
Subject: [PATCH] lib-imap: Fix writing BODYSTRUCTURE for truncated multipart/
|
||
|
part
|
||
|
|
||
|
If the max nesting limit is reached, write the last part out as
|
||
|
application/octet-stream. The original content-type could be confusing
|
||
|
IMAP clients when they don't see any child parts.
|
||
|
---
|
||
|
src/lib-imap/imap-bodystructure.c | 6 ++++++
|
||
|
src/lib-imap/test-imap-bodystructure.c | 15 +++++++++++++++
|
||
|
2 files changed, 21 insertions(+)
|
||
|
|
||
|
diff --git a/src/lib-imap/imap-bodystructure.c b/src/lib-imap/imap-bodystructure.c
|
||
|
index ab422c00d2..bfb6e64197 100644
|
||
|
--- a/src/lib-imap/imap-bodystructure.c
|
||
|
+++ b/src/lib-imap/imap-bodystructure.c
|
||
|
@@ -147,6 +147,7 @@ static bool part_is_truncated(const struct message_part *part)
|
||
|
const struct message_part_data *data = part->data;
|
||
|
|
||
|
i_assert((part->flags & MESSAGE_PART_FLAG_MESSAGE_RFC822) == 0);
|
||
|
+ i_assert((part->flags & MESSAGE_PART_FLAG_MULTIPART) == 0);
|
||
|
|
||
|
if (data->content_type != NULL) {
|
||
|
if (strcasecmp(data->content_type, "message") == 0 &&
|
||
|
@@ -155,6 +156,11 @@ static bool part_is_truncated(const struct message_part *part)
|
||
|
MESSAGE_PART_FLAG_MESSAGE_RFC822. */
|
||
|
return TRUE;
|
||
|
}
|
||
|
+ if (strcasecmp(data->content_type, "multipart") == 0) {
|
||
|
+ /* It's multipart/, but without
|
||
|
+ MESSAGE_PART_FLAG_MULTIPART. */
|
||
|
+ return TRUE;
|
||
|
+ }
|
||
|
}
|
||
|
return FALSE;
|
||
|
}
|
||
|
diff --git a/src/lib-imap/test-imap-bodystructure.c b/src/lib-imap/test-imap-bodystructure.c
|
||
|
index 6cb699e126..2118907e78 100644
|
||
|
--- a/src/lib-imap/test-imap-bodystructure.c
|
||
|
+++ b/src/lib-imap/test-imap-bodystructure.c
|
||
|
@@ -556,6 +556,21 @@ static const struct {
|
||
|
.bodystructure = "\"message\" \"rfc822\" NIL NIL NIL \"7bit\" 159 (NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL) (\"application\" \"octet-stream\" NIL NIL NIL \"7bit\" 110 NIL NIL NIL NIL) 11 NIL NIL NIL NIL",
|
||
|
.max_depth = 2,
|
||
|
},
|
||
|
+ {
|
||
|
+ .input = "Content-Type: multipart/mixed; boundary=1\n"
|
||
|
+ "\n"
|
||
|
+ "--1\n"
|
||
|
+ "Content-Type: multipart/mixed; boundary=2\n"
|
||
|
+ "\n"
|
||
|
+ "--2\n"
|
||
|
+ "Content-Type: multipart/mixed; boundary=3\n"
|
||
|
+ "\n"
|
||
|
+ "--3\n"
|
||
|
+ "\n"
|
||
|
+ "body\n",
|
||
|
+ .bodystructure = "(\"application\" \"octet-stream\" (\"boundary\" \"2\") NIL NIL \"7bit\" 63 NIL NIL NIL NIL) \"mixed\" (\"boundary\" \"1\") NIL NIL NIL",
|
||
|
+ .max_depth = 2,
|
||
|
+ },
|
||
|
};
|
||
|
|
||
|
static void test_imap_bodystructure_truncation(void)
|