summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2017-08-10 17:39:23 -0600
committerChristian Mollekopf <chrigi_1@fastmail.fm>2017-08-10 21:38:37 -0600
commite354603dcb42c54ab11c0c393d5a1607ed6343d7 (patch)
tree9b23b428f983687fb9ac3475a114695ed5166f9a
parentbd6c52e3d3a4fbbe3381540cb844ee2b94691285 (diff)
downloadkube-e354603dcb42c54ab11c0c393d5a1607ed6343d7.tar.gz
kube-e354603dcb42c54ab11c0c393d5a1607ed6343d7.zip
Don't quote attachments in the reply
-rw-r--r--framework/src/domain/mime/mimetreeparser/objecttreeparser.cpp3
-rw-r--r--framework/src/domain/mime/testdata/plaintextattachment.mbox56
-rw-r--r--framework/src/domain/mime/tests/mailtemplatetest.cpp13
3 files changed, 72 insertions, 0 deletions
diff --git a/framework/src/domain/mime/mimetreeparser/objecttreeparser.cpp b/framework/src/domain/mime/mimetreeparser/objecttreeparser.cpp
index 1b834b47..9714ca19 100644
--- a/framework/src/domain/mime/mimetreeparser/objecttreeparser.cpp
+++ b/framework/src/domain/mime/mimetreeparser/objecttreeparser.cpp
@@ -132,6 +132,9 @@ QString ObjectTreeParser::plainTextContent()
132 return true; 132 return true;
133 }, 133 },
134 [] (const MessagePartPtr &part) { 134 [] (const MessagePartPtr &part) {
135 if (part->isAttachment()) {
136 return false;
137 }
135 if (dynamic_cast<MimeTreeParser::TextMessagePart*>(part.data())) { 138 if (dynamic_cast<MimeTreeParser::TextMessagePart*>(part.data())) {
136 return true; 139 return true;
137 } 140 }
diff --git a/framework/src/domain/mime/testdata/plaintextattachment.mbox b/framework/src/domain/mime/testdata/plaintextattachment.mbox
new file mode 100644
index 00000000..5e530e8d
--- /dev/null
+++ b/framework/src/domain/mime/testdata/plaintextattachment.mbox
@@ -0,0 +1,56 @@
1Return-Path: <christian@example.ch>
2Received: from imapb010.mykolab.com ([unix socket])
3 by imapb010.mykolab.com (Cyrus 2.5.10-49-g2e214b4-Kolab-2.5.10-8.1.el7.kolab_14) with LMTPA;
4 Wed, 09 Aug 2017 18:37:01 +0200
5X-Sieve: CMU Sieve 2.4
6Received: from int-mx002.mykolab.com (unknown [10.9.13.2])
7 by imapb010.mykolab.com (Postfix) with ESMTPS id 0A93910A25047
8 for <christian@example.ch>; Wed, 9 Aug 2017 18:37:01 +0200 (CEST)
9Received: from int-subm002.mykolab.com (unknown [10.9.37.2])
10 by int-mx002.mykolab.com (Postfix) with ESMTPS id EC06AF6E
11 for <christian@example.ch>; Wed, 9 Aug 2017 18:37:00 +0200 (CEST)
12MIME-Version: 1.0
13Content-Type: multipart/mixed;
14 boundary="=_291b8e96564265636432c6d494e02322"
15Date: Wed, 09 Aug 2017 10:37:00 -0600
16From: "Mollekopf, Christian" <christian@example.ch>
17To: christian@example.ch
18Subject: sdflkjsdf
19Message-ID: <46892ac54a8ffb690d491243ec01dfb2@example.ch>
20X-Sender: christian@example.ch
21
22--=_291b8e96564265636432c6d494e02322
23Content-Type: multipart/alternative;
24 boundary="=_ceff0fd19756f45ed1295ee2069ff8e0"
25
26--=_ceff0fd19756f45ed1295ee2069ff8e0
27Content-Transfer-Encoding: 7bit
28Content-Type: text/plain; charset=US-ASCII
29
30sdlkjsdjf
31--=_ceff0fd19756f45ed1295ee2069ff8e0
32Content-Transfer-Encoding: quoted-printable
33Content-Type: text/html; charset=UTF-8
34
35<html><head><meta http-equiv=3D"Content-Type" content=3D"text/html; charset=
36=3DUTF-8" /></head><body style=3D'font-size: 10pt; font-family: Verdana,Gen=
37eva,sans-serif'>
38<p>sdlkjsdjf</p>
39
40</body></html>
41
42--=_ceff0fd19756f45ed1295ee2069ff8e0--
43
44--=_291b8e96564265636432c6d494e02322
45Content-Transfer-Encoding: base64
46Content-Type: text/plain;
47 name=xorg.conf
48Content-Disposition: attachment;
49 filename=xorg.conf;
50 size=211
51
52U2VjdGlvbiAiRGV2aWNlIgogICAgSWRlbnRpZmllciAgICAgIkRldmljZTAiCiAgICBEcml2ZXIg
53ICAgICAgICAibnZpZGlhIgogICAgVmVuZG9yTmFtZSAgICAgIk5WSURJQSBDb3Jwb3JhdGlvbiIK
54ICAgIEJvYXJkTmFtZSAgICAgICJOVlMgNDIwME0iCiAgICBPcHRpb24gIk5vTG9nbyIgInRydWUi
55CiAgICBPcHRpb24gIlVzZUVESUQiICJ0cnVlIgpFbmRTZWN0aW9uCg==
56--=_291b8e96564265636432c6d494e02322--
diff --git a/framework/src/domain/mime/tests/mailtemplatetest.cpp b/framework/src/domain/mime/tests/mailtemplatetest.cpp
index 9ec7cf18..0e8eb2c3 100644
--- a/framework/src/domain/mime/tests/mailtemplatetest.cpp
+++ b/framework/src/domain/mime/tests/mailtemplatetest.cpp
@@ -151,6 +151,19 @@ private slots:
151 QCOMPARE(unquote(content), QLatin1String("If you can see this text it means that your email client couldn't display our newsletter properly.\nPlease visit this link to view the newsletter on our website: http://www.gog.com/newsletter/\n")); 151 QCOMPARE(unquote(content), QLatin1String("If you can see this text it means that your email client couldn't display our newsletter properly.\nPlease visit this link to view the newsletter on our website: http://www.gog.com/newsletter/\n"));
152 } 152 }
153 153
154 void testAttachmentReply()
155 {
156 auto msg = readMail("plaintextattachment.mbox");
157 KMime::Message::Ptr result;
158 MailTemplates::reply(msg, [&] (const KMime::Message::Ptr &r) {
159 result = r;
160 });
161 QTRY_VERIFY(result);
162 auto content = removeFirstLine(result->body());
163 QVERIFY(!content.isEmpty());
164 QCOMPARE(unquote(content), QLatin1String("sdlkjsdjf"));
165 }
166
154 void testCreatePlainMail() 167 void testCreatePlainMail()
155 { 168 {
156 QStringList to = {{"to@example.org"}}; 169 QStringList to = {{"to@example.org"}};