freebsd-ports/mail/dbmail/files/patch-0031-boundaries-fixups-ordering-of-parts-do-not-add-newline-on-
Muhammad Moinur Rahman 9eff14e488 mail/dbmail: adopt latest fixes from git:
- login_disabled option before starttls for pop3
- fix compiler warnings for GCC5
- Fix IMAP mailbox maintanence
- prevent assertion in p_string_erase
- improve crypt authentication, also don't segfault when spasswd is empty
- simplify log_query_time duration logic
- Disconnect IMAP clients if only few free FDs left
- Add primary key constraint to dbmail_authlog
- Rework temporary connection failures
- Give sensible default for retry 120s
- Add retries for binding and searching
- Bump search timeout to 60s
- Increase ldap timeout to 600s 10 mins
- Refactor deprecated functions
- Get timeout from config
- Remove redundant event_assign
- Remove deprecated non functioning g_mem_profile
- Add definition for authldap_free
- Revert inadvertent event_assign removal
- Reduce failed LDAP connection for search to error
- Update LDAP to non deprecated search
- Clear the ldap connection
- Update ldap deprecated unbind
- Fix typo
- Update to ldap_unbind_ext_s and remove redundant sigaction
- Rebalance commit rollback
- Ensure mailbox2dbmail is using Python 2
- Tidy mailbox2dbmail man page
- Update description of pid file location in server man page
- Boundaries fixups ordering of parts do not add newline on
- Prepend headers during delivery
- Allow for systems that don't use proc

PR:		210274
Submitted by:	fluffy
2017-02-24 21:15:52 +00:00

180 lines
6 KiB
Text

From 3fd6782988f01c2f56af19012e470ea16e800f51 Mon Sep 17 00:00:00 2001
From: Michele Comitini <michele.comitini@gmail.com>
Date: Tue, 1 Nov 2016 21:20:16 +0100
Subject: [PATCH 31/33] boundaries fixups: ordering of parts, do not add
newline on boundary if there's no part after previous header (#34)
* Fix IMAP mailbox maintanence
Update message's mailbox id in a separate explicit transaction to prevent
SQLException: ORA-01453 error on the next db_begin_transaction() call
(see db_mailbox_seq_update() next to 'UPDATE dbmail_messages SET mailbox_idnr'
query).
* add newline only if is_message
* better fix for rfc822 multipart messages with boundary after header
* fixed some race condition when closing boundaries, since key does not change. Needed ordering parts on depth DESC when key does not vary.
* fixes ordering in insertion
---
src/dm_message.c | 12 ++++---
test/check_dbmail.h | 78 ++++++++++++++++++++++++++++++++++++++++++++-
test/check_dbmail_message.c | 8 +++++
3 files changed, 93 insertions(+), 5 deletions(-)
diff --git src/dm_message.c src/dm_message.c
index 9d30d52..784c091 100644
--- src/dm_message.c
+++ src/dm_message.c
@@ -387,7 +387,7 @@ static DbmailMessage * _mime_retrieve(DbmailMessage *self)
"FROM %smimeparts p "
"JOIN %spartlists l ON p.id = l.part_id "
"JOIN %sphysmessage ph ON ph.id = l.physmessage_id "
- "WHERE l.physmessage_id = ? ORDER BY l.part_key,l.part_order ASC",
+ "WHERE l.physmessage_id = ? ORDER BY l.part_key, l.part_order ASC, l.part_depth DESC",
frag, p_string_str(n), DBPFX, DBPFX, DBPFX);
db_stmt_set_u64(stmt, 1, self->id);
r = db_stmt_query(stmt);
@@ -454,10 +454,14 @@ static DbmailMessage * _mime_retrieve(DbmailMessage *self)
if ((depth > 0) && (blist[depth-1][0]))
strncpy(boundary, blist[depth-1], MAX_MIME_BLEN-1);
- if (is_header && (!prev_header || prev_boundary || (prev_header && depth>0 && !prev_is_message))) {
+ if (is_header)
+ if (prev_header && depth>0 && !prev_is_message) {
+ dprint("--%s\n", boundary);
+ p_string_append_printf(m, "--%s\n", boundary);
+ } else if (!prev_header || prev_boundary) {
dprint("\n--%s\n", boundary);
p_string_append_printf(m, "\n--%s\n", boundary);
- }
+ }
p_string_append_printf(m, "%s", str);
dprint("<part is_header=\"%d\" depth=\"%d\" key=\"%d\" order=\"%d\">\n%s\n</part>\n",
@@ -558,7 +562,7 @@ static gboolean store_mime_multipart(GMimeObject *object, DbmailMessage *m, cons
if (boundary) {
n++;
m->part_depth--;
- m->part_order=n;
+ m->part_order++;
}
if (g_mime_content_type_is_type(GMIME_CONTENT_TYPE(content_type), "multipart", "*") &&
diff --git test/check_dbmail.h test/check_dbmail.h
index 09c9958..439c8a1 100644
--- test/check_dbmail.h
+++ test/check_dbmail.h
@@ -1561,7 +1561,7 @@ char *multipart_message8 = "From: nobody@example.org\n"
"bmdzLnhtbFBLAQItABQABgAIAAAAIQDv0+Pp+gEAAPsDAAAQAAAAAAAAAAAAAAAAALREAABkb2NQ\n"
"cm9wcy9hcHAueG1sUEsFBgAAAAAPAA8A3AMAAORHAAAAAA==\n"
"\n"
- "--_004_AAD42BB12C540843AB5C952ADD4D978901830A1Bswi52mbx1orfloc_--\";\n";
+ "--_004_AAD42BB12C540843AB5C952ADD4D978901830A1Bswi52mbx1orfloc_--\n";
char *multipart_message9 = "From: a\n"
"To: b\n"
@@ -28440,3 +28440,79 @@ char *multipart_message_big = "From: \"Gennadiy Poryev\" <vecanoi@gmail.com>\n"
"/g8HAAAAAwANNP0/pQ4DAA80/T+lDvA8\n"
"\n"
"------=_NextPart_000_0000_01CDFBC6.932A1F00--\n";
+
+char *multipart_message_submessage = "Content-Type: multipart/mixed; boundary=\"===============9147350442359610775==\"\n"
+"MIME-Version: 1.0\n"
+"To: test@test.it\n"
+"From: test@test.it\n"
+"\n"
+"--===============9147350442359610775==\n"
+"Content-Type: message/rfc822\n"
+"MIME-Version: 1.0\n"
+"\n"
+"Content-Type: multipart/alternative;\n"
+" boundary=\"===============1150329730008994878==\"\n"
+"MIME-Version: 1.0\n"
+"Subject: Link\n"
+"From: my@email.com\n"
+"To: your@email.com\n"
+"\n"
+"--===============1150329730008994878==\n"
+"Content-Type: text/plain; charset=\"us-ascii\"\n"
+"MIME-Version: 1.0\n"
+"Content-Transfer-Encoding: 7bit\n"
+"\n"
+"Hi!\n"
+"How are you?\n"
+"Here is the link you wanted:\n"
+"https://www.python.org\n"
+"--===============1150329730008994878==\n"
+"Content-Type: text/html; charset=\"us-ascii\"\n"
+"MIME-Version: 1.0\n"
+"Content-Transfer-Encoding: 7bit\n"
+"\n"
+"<html>\n"
+" <head></head>\n"
+" <body>\n"
+" <p>Hi!<br>\n"
+" How are you?<br>\n"
+" Here is the <a href=\"https://www.python.org\">link</a> you wanted.\n"
+" </p>\n"
+" </body>\n"
+"</html>\n"
+"\n"
+"--===============1150329730008994878==\n"
+"Content-Type: multipart/mixed; boundary=\"===============0782181963306111896==\"\n"
+"MIME-Version: 1.0\n"
+"\n"
+"--===============0782181963306111896==\n"
+"Content-Type: text/plain; charset=\"us-ascii\"\n"
+"MIME-Version: 1.0\n"
+"Content-Transfer-Encoding: 7bit\n"
+"\n"
+"Text part3_1.\n"
+"--===============0782181963306111896==\n"
+"Content-Type: text/plain; charset=\"us-ascii\"\n"
+"MIME-Version: 1.0\n"
+"Content-Transfer-Encoding: 7bit\n"
+"\n"
+"Text part3_2.\n"
+"--===============0782181963306111896==--\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"--===============1150329730008994878==--\n"
+"\n"
+"--===============9147350442359610775==\n"
+"Content-Type: text/plain; charset=\"us-ascii\"\n"
+"MIME-Version: 1.0\n"
+"Content-Transfer-Encoding: 7bit\n"
+"\n"
+"This is a simple text attachment.\n"
+"with some newlines at the end.\n"
+"\n"
+"\n"
+"\n"
+"--===============9147350442359610775==--\n"
+"\n";
diff --git test/check_dbmail_message.c test/check_dbmail_message.c
index e36a2ea..f070257 100644
--- test/check_dbmail_message.c
+++ test/check_dbmail_message.c
@@ -431,6 +431,14 @@ START_TEST(test_dbmail_message_store)
COMPARE(e,t);
g_free(e);
g_free(t);
+ //-----------------------------------------
+ m = message_init(multipart_message_submessage);
+ e = dbmail_message_to_string(m);
+ t = store_and_retrieve(m);
+ COMPARE(e,t);
+ COMPARE(multipart_message_submessage, t);
+ g_free(e);
+ g_free(t);
}
END_TEST
--
2.10.1 (Apple Git-78)