From 9a08a17a489ecdd8f0bf0e08aea77904515d8c2a Mon Sep 17 00:00:00 2001 From: DenBond7 Date: Wed, 13 Oct 2021 18:28:40 +0300 Subject: [PATCH 1/3] Added a better errro handling in PgpSignature.extractClearText().| #1474 --- .../com/flowcrypt/email/security/pgp/PgpMsg.kt | 14 +++++++++++--- .../flowcrypt/email/security/pgp/PgpSignature.kt | 12 +++++++----- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/FlowCrypt/src/main/java/com/flowcrypt/email/security/pgp/PgpMsg.kt b/FlowCrypt/src/main/java/com/flowcrypt/email/security/pgp/PgpMsg.kt index e92911d56b..d4ca634f3d 100644 --- a/FlowCrypt/src/main/java/com/flowcrypt/email/security/pgp/PgpMsg.kt +++ b/FlowCrypt/src/main/java/com/flowcrypt/email/security/pgp/PgpMsg.kt @@ -824,7 +824,11 @@ object PgpMsg { } block.type.isContentBlockType() || MimeUtils.isPlainImgAtt(block) -> { - contentBlocks.add(block) + if (block.error != null) { + resultBlocks.add(block) + } else { + contentBlocks.add(block) + } } block.type != MsgBlock.Type.PLAIN_ATT -> { @@ -1012,8 +1016,12 @@ object PgpMsg { } msgBlock.type == MsgBlock.Type.SIGNED_MSG -> { - val cleartext = PgpSignature.extractClearText(msgBlock.content) - return msgBlock.copy(content = cleartext) + return try { + val cleartext = PgpSignature.extractClearText(msgBlock.content, false) + msgBlock.copy(content = cleartext) + } catch (e: Exception) { + msgBlock.copy(error = MsgBlockError("[" + e.javaClass.simpleName + "]: " + e.message)) + } } else -> null diff --git a/FlowCrypt/src/main/java/com/flowcrypt/email/security/pgp/PgpSignature.kt b/FlowCrypt/src/main/java/com/flowcrypt/email/security/pgp/PgpSignature.kt index 7c8a1d9811..af146f30bf 100644 --- a/FlowCrypt/src/main/java/com/flowcrypt/email/security/pgp/PgpSignature.kt +++ b/FlowCrypt/src/main/java/com/flowcrypt/email/security/pgp/PgpSignature.kt @@ -18,12 +18,12 @@ import java.io.InputStream * E-mail: DenBond7@gmail.com */ object PgpSignature { - fun extractClearText(source: String?): String? { - return extractClearText(ByteArrayInputStream(source?.toByteArray())) + fun extractClearText(source: String?, isSilent: Boolean = true): String? { + return extractClearText(ByteArrayInputStream(source?.toByteArray()), isSilent) } @Suppress("MemberVisibilityCanBePrivate") - fun extractClearText(srcInputStream: InputStream): String? { + fun extractClearText(srcInputStream: InputStream, isSilent: Boolean = true): String? { srcInputStream.use { srcStream -> return try { val multiPassStrategy = MultiPassStrategy.keepMessageInMemory() @@ -33,8 +33,10 @@ object PgpSignature { ) String(multiPassStrategy.bytes) } catch (e: Exception) { - e.printStackTrace() - null + if (isSilent) { + e.printStackTrace() + null + } else throw e } } } From 826752d0783825db2b304248f6dc99be31182d13 Mon Sep 17 00:00:00 2001 From: DenBond7 Date: Wed, 13 Oct 2021 18:31:55 +0300 Subject: [PATCH 2/3] Updated docker-mailserver to 0.0.12.| #1474 --- docker-mailserver/docker-compose.yml | 2 +- .../default/dovecot.list.index.log | Bin 40 -> 72 bytes .../INBOX/dbox-Mails/dovecot.index.cache | Bin 15620 -> 17144 bytes .../INBOX/dbox-Mails/dovecot.index.log | Bin 9944 -> 10480 bytes .../default/mailboxes/INBOX/dbox-Mails/u.27 | 44 +++++++++++++++++ .../default/mailboxes/INBOX/dbox-Mails/u.28 | 45 ++++++++++++++++++ .../denbond7/dovecot.list.index.log | Bin 3260 -> 4376 bytes .../Drafts/dbox-Mails/dovecot.index.log | Bin 352 -> 368 bytes .../INBOX/dbox-Mails/dovecot.index.cache | Bin 2272 -> 2272 bytes .../INBOX/dbox-Mails/dovecot.index.log | Bin 1064 -> 1080 bytes .../Junk/dbox-Mails/dovecot.index.log | Bin 352 -> 368 bytes .../Sent/dbox-Mails/dovecot.index.cache | Bin 14872 -> 16380 bytes .../Sent/dbox-Mails/dovecot.index.log | Bin 7364 -> 7860 bytes .../denbond7/mailboxes/Sent/dbox-Mails/u.25 | 35 ++++++++++++++ .../denbond7/mailboxes/Sent/dbox-Mails/u.26 | 36 ++++++++++++++ .../Trash/dbox-Mails/dovecot.index.log | Bin 2584 -> 2600 bytes 16 files changed, 161 insertions(+), 1 deletion(-) create mode 100644 docker-mailserver/maildata_source/flowcrypt.test/default/mailboxes/INBOX/dbox-Mails/u.27 create mode 100644 docker-mailserver/maildata_source/flowcrypt.test/default/mailboxes/INBOX/dbox-Mails/u.28 create mode 100644 docker-mailserver/maildata_source/flowcrypt.test/denbond7/mailboxes/Sent/dbox-Mails/u.25 create mode 100644 docker-mailserver/maildata_source/flowcrypt.test/denbond7/mailboxes/Sent/dbox-Mails/u.26 diff --git a/docker-mailserver/docker-compose.yml b/docker-mailserver/docker-compose.yml index cba6d4c63d..96cfd6eb82 100644 --- a/docker-mailserver/docker-compose.yml +++ b/docker-mailserver/docker-compose.yml @@ -1,7 +1,7 @@ version: '2' services: mail: - image: flowcrypt/flowcrypt-email-server:0.0.11 + image: flowcrypt/flowcrypt-email-server:0.0.12 hostname: ${HOSTNAME} domainname: ${DOMAINNAME} container_name: ${CONTAINER_NAME} diff --git a/docker-mailserver/maildata_source/flowcrypt.test/default/dovecot.list.index.log b/docker-mailserver/maildata_source/flowcrypt.test/default/dovecot.list.index.log index b42552513a6d929c93f8661db6bdfcf894c9c97e..a44fd67cd32990a4a77aab3f294562e7f1ff7cf4 100644 GIT binary patch delta 37 jcmdP!n4qE1(9qDLz`!8j!@$Du9|&N42O!^rfq?-4<68=e delta 4 Lcmea!n4kdw0^|WH diff --git a/docker-mailserver/maildata_source/flowcrypt.test/default/mailboxes/INBOX/dbox-Mails/dovecot.index.cache b/docker-mailserver/maildata_source/flowcrypt.test/default/mailboxes/INBOX/dbox-Mails/dovecot.index.cache index 042d8c08010afec569b727d06a2d9dfc21a3cac2..842492b77033f35ef6a1293ee945c9c0e8200aac 100644 GIT binary patch delta 672 zcmZpv`q9cL#>m0QAaJ!S!4HTTfIu9Ge>iOvW3#qy`<0f6j+KF82~dnKhs2+3Z!J1G zz?x-pfpsQ76DrvJ!dixr7i8BTCI$vpAZR+S87dfBSQ(jG8BU(4CN}v4v&Q5COP0wMW=>Kj@y2H6mPV$= z=E#Pan<#NjeqpS@C^C5?r?liRpd&$mml;AYV}#J#Co5X1b8zzWb!NR5J?=tU}`vVzAZ2a+$0U+4S_*uU}$cLqTSqJ@_9>Di0?H&Lw(N%_5Dkz ze}6-15aj{HQj-tzi3|EbMI)dz&*Vf!M>b;<69q$~$qUU*#Bo_DFDoi=2PsgRfPn%4 DGVrA2 delta 117 zcmey-%GgpR#>m0QAaJ!S!4HTTfIt+8S!_3ou~}Ou#HS=C0WmTi59GrzNE{mm>X{sF P-Nes`3O2v6mSF?{NOdA8 diff --git a/docker-mailserver/maildata_source/flowcrypt.test/default/mailboxes/INBOX/dbox-Mails/dovecot.index.log b/docker-mailserver/maildata_source/flowcrypt.test/default/mailboxes/INBOX/dbox-Mails/dovecot.index.log index c6d3ba6d393e69b2182ce69d1abd79b3248d7e6c..db194cc81d0d78632d99f62f714dadc5a336e577 100644 GIT binary patch delta 258 zcmccN`yp_{4K;y=hK3de1_pru1{MbCUulVx10+Qlr6)782v2^ZDm-~UJ1d(s0|Nt# z?c_QkHB%7tC<_AvP*)E~R|ta&LxW;kB1l{ciY0+G3ZDE?(wsM9?+2hb0|Q8<*yKcZ zaYh*wOJqQj4j@a|Kujjq$$czlwvmS*x{ +Delivered-To: default@flowcrypt.test +Received: from mail.flowcrypt.test + by mail.flowcrypt.test with LMTP + id y3fSEmD6ZmG+BAAAc/RpdQ + (envelope-from ) + for ; Wed, 13 Oct 2021 15:25:20 +0000 +Received: from localhost (localhost [127.0.0.1]) + by mail.flowcrypt.test (Postfix) with ESMTP id 49C011C2101 + for ; Wed, 13 Oct 2021 15:25:20 +0000 (UTC) +Date: Wed, 13 Oct 2021 18:25:17 +0300 (GMT+03:00) +From: denbond7@flowcrypt.test +To: default@flowcrypt.test +Message-ID: <231862942.5.1634138717382@flowcrypt.test> +Subject: SIGNED_MESSAGE. --clearsign. Broken +Mime-Version: 1.0 +Content-Type: multipart/mixed; + boundary="----=_Part_4_36792537.1634138717374" + +------=_Part_4_36792537.1634138717374 +Content-Type: text/plain; charset=us-ascii +Content-Transfer-Encoding: 7bit + +-----BEGIN PGP SIGNED MESSAGE----- +Hash: SHA512 + +Some important text that is signed +-----BEGIN PGP SIGNATURE----- +Version: PGPainless + +iHUEARYKAAYFAmFm9GEAIQkQwyCJzWr41s4WIQTBZCjWAcs5N4nPYdTDIInNavjW +VMWbrRaCiEghT5b3tpYn6jzVDenjxwg= +=vdIK +-----END PGP SIGNATURE----- + +------=_Part_4_36792537.1634138717374-- + + +R6166fa60 +V4c4 +Ge19be41260fa6661be04000073f46975 + diff --git a/docker-mailserver/maildata_source/flowcrypt.test/default/mailboxes/INBOX/dbox-Mails/u.28 b/docker-mailserver/maildata_source/flowcrypt.test/default/mailboxes/INBOX/dbox-Mails/u.28 new file mode 100644 index 0000000000..500c55dfcf --- /dev/null +++ b/docker-mailserver/maildata_source/flowcrypt.test/default/mailboxes/INBOX/dbox-Mails/u.28 @@ -0,0 +1,45 @@ +2 M1e C6166fa82 +N 00000000000004DC +Return-Path: +Delivered-To: default@flowcrypt.test +Received: from mail.flowcrypt.test + by mail.flowcrypt.test with LMTP + id sM02GYL6ZmG+BAAAc/RpdQ + (envelope-from ) + for ; Wed, 13 Oct 2021 15:25:54 +0000 +Received: from localhost (localhost [127.0.0.1]) + by mail.flowcrypt.test (Postfix) with ESMTP id 6625D1C2104 + for ; Wed, 13 Oct 2021 15:25:54 +0000 (UTC) +Date: Wed, 13 Oct 2021 18:25:51 +0300 (GMT+03:00) +From: denbond7@flowcrypt.test +To: default@flowcrypt.test +Message-ID: <116269160.1.1634138751584@flowcrypt.test> +Subject: SIGNED_MESSAGE. --clearsign +Mime-Version: 1.0 +Content-Type: multipart/mixed; + boundary="----=_Part_0_129401711.1634138751570" + +------=_Part_0_129401711.1634138751570 +Content-Type: text/plain; charset=us-ascii +Content-Transfer-Encoding: 7bit + +-----BEGIN PGP SIGNED MESSAGE----- +Hash: SHA512 + +Some important text that is signed +-----BEGIN PGP SIGNATURE----- +Version: PGPainless + +iHUEARYKAAYFAmFm9GEAIQkQwyCJzWr41s4WIQTBZCjWAcs5N4nPYdTDIInNavjW +zr6UAQCd8RYlxeawHRJui2T6tl+uKe2jeaQ08rfFaMzPQoumWgD/Q3KqJhL+6IkC +VMWbrRaCiEghT5b3tpYn6jzVDenjxwg= +=vdIK +-----END PGP SIGNATURE----- + +------=_Part_0_129401711.1634138751570-- + + +R6166fa82 +V501 +Ga1763e1982fa6661be04000073f46975 + diff --git a/docker-mailserver/maildata_source/flowcrypt.test/denbond7/dovecot.list.index.log b/docker-mailserver/maildata_source/flowcrypt.test/denbond7/dovecot.list.index.log index e306307afbb3e3a82c8eef3d55aed21fa634424b..b63f7fd172baf42fca5ab9795f04d7c146343f26 100644 GIT binary patch delta 394 zcmdlZIYVi~9-heum`r$u86bcWNJ&j*WY%U>nEa4YdvXE`i&%v$14F{Ew8Vynh86_| z1_1{K7KQ@e$yF>yQmjDb1wcLM(tE(t6DP2UX>ei6a_|8)n~7o57{WLCAFJ5p39Jgd zd>tRaZjuC&!jm7e>xg1;#|@BrGr03X8l)y0GHZ+7!J;^ZfAT&iGhPv}u?!3#zexQ^V3aC{CY|j)d8m53WAnXBICk;|8u?34_2|)%104*X| ABLDyZ delta 7 OcmbQCv`2Eo9v%P;p92U0 diff --git a/docker-mailserver/maildata_source/flowcrypt.test/denbond7/mailboxes/Drafts/dbox-Mails/dovecot.index.log b/docker-mailserver/maildata_source/flowcrypt.test/denbond7/mailboxes/Drafts/dbox-Mails/dovecot.index.log index fa3cae8ab49807af5770a22b33b0e68156281784..eee970fa61af90abbe14552b0535d939703490ba 100644 GIT binary patch delta 24 fcmaFB^nqzZ0;51fLqm%K1A{;S0}DgKue3w}XNd=& delta 7 Ocmeys^nhtY0wVwo+ydqR diff --git a/docker-mailserver/maildata_source/flowcrypt.test/denbond7/mailboxes/INBOX/dbox-Mails/dovecot.index.cache b/docker-mailserver/maildata_source/flowcrypt.test/denbond7/mailboxes/INBOX/dbox-Mails/dovecot.index.cache index 57a6e8c919d48326b9a3b2fd17bf662a72ed5b42..7f698cefe0204c0c5de4944650e3061580d1da5a 100644 GIT binary patch delta 16 YcmaDL_&{*O3RdRaUum0Hvzjsk06#hgs{jB1 delta 16 YcmaDL_&{*O3RdRYWwD!Avzjsk06jPcUH||9 diff --git a/docker-mailserver/maildata_source/flowcrypt.test/denbond7/mailboxes/INBOX/dbox-Mails/dovecot.index.log b/docker-mailserver/maildata_source/flowcrypt.test/denbond7/mailboxes/INBOX/dbox-Mails/dovecot.index.log index c920bef45979f28d8f455262f6768e829a4504e7..6d5aef2ed307e319763d1cd641a5b79ea21b72fb 100644 GIT binary patch delta 24 fcmZ3%v4dlS28%#LLqm%K1A{;S0}F%lue3w}S(^sQ delta 7 OcmdnNv4UfR1`7ZS3j$35 diff --git a/docker-mailserver/maildata_source/flowcrypt.test/denbond7/mailboxes/Junk/dbox-Mails/dovecot.index.log b/docker-mailserver/maildata_source/flowcrypt.test/denbond7/mailboxes/Junk/dbox-Mails/dovecot.index.log index 9f4b0957fd87049cfa1165dcf7db1aeaf41d84dc..5137c84d7f0f0924443cf44fecd73b418db80f6f 100644 GIT binary patch delta 24 fcmaFB^nqzZ0;51fLqm%K1A{;S0}DgKue3w}XNd=& delta 7 Ocmeys^nhtY0wVwo+ydqR diff --git a/docker-mailserver/maildata_source/flowcrypt.test/denbond7/mailboxes/Sent/dbox-Mails/dovecot.index.cache b/docker-mailserver/maildata_source/flowcrypt.test/denbond7/mailboxes/Sent/dbox-Mails/dovecot.index.cache index 869f8a9a0186073ffd70a66d8847084f73bb8b64..a15b38bc9f546b5a0e367da31d3568d684a53580 100644 GIT binary patch delta 586 zcmbPH@~2*mk%N&zZ*F(O4j>j_U|dc@Mg~TP3WgR|My6JV=9B$}tR#($4K2)!EKQ8`O!W-Sj7@d zL6ip&Pnf(=MO=^@Dk=u0xhGHLb7VA{{9f5y0+&UT`^3dW1(-pWFfgzKaV#)|Kj_U|?q diff --git a/docker-mailserver/maildata_source/flowcrypt.test/denbond7/mailboxes/Sent/dbox-Mails/dovecot.index.log b/docker-mailserver/maildata_source/flowcrypt.test/denbond7/mailboxes/Sent/dbox-Mails/dovecot.index.log index efccf21e17c3f636faf62c3d7736171a42ece938..c98968565b896de30cc0bcee062acff72128299e 100644 GIT binary patch delta 230 zcmX?Nxy5$F5gCDohK3de1_pru1{Q{dUulVxABc)DN>08gt<5IMz`!73HTfNjnkk5> z!_2?{RNVto9m1f((4d%>2v!18h7C_{6f@W3>-YeaV_*QO6b53T31IsSfc8lt@g0Et yJF=7OSj8Bnz_x=Vd2B(pvx1nJlN0&O4a&M9rh!C6kaUAglSbl$Oxq&IzyJU`F)Jhh delta 7 OcmdmDd&F|X5g7mu%>#b` diff --git a/docker-mailserver/maildata_source/flowcrypt.test/denbond7/mailboxes/Sent/dbox-Mails/u.25 b/docker-mailserver/maildata_source/flowcrypt.test/denbond7/mailboxes/Sent/dbox-Mails/u.25 new file mode 100644 index 0000000000..54fcf765a2 --- /dev/null +++ b/docker-mailserver/maildata_source/flowcrypt.test/denbond7/mailboxes/Sent/dbox-Mails/u.25 @@ -0,0 +1,35 @@ +2 M1e C6166fa60 +N 0000000000000310 +Date: Wed, 13 Oct 2021 18:25:17 +0300 (GMT+03:00) +From: denbond7@flowcrypt.test +To: default@flowcrypt.test +Message-ID: <231862942.5.1634138717382@flowcrypt.test> +Subject: SIGNED_MESSAGE. --clearsign. Broken +MIME-Version: 1.0 +Content-Type: multipart/mixed; + boundary="----=_Part_4_36792537.1634138717374" +User-Agent: FlowCrypt_Android_1.2.3_dev_123__2021_10_13 + +------=_Part_4_36792537.1634138717374 +Content-Type: text/plain; charset=us-ascii +Content-Transfer-Encoding: 7bit + +-----BEGIN PGP SIGNED MESSAGE----- +Hash: SHA512 + +Some important text that is signed +-----BEGIN PGP SIGNATURE----- +Version: PGPainless + +iHUEARYKAAYFAmFm9GEAIQkQwyCJzWr41s4WIQTBZCjWAcs5N4nPYdTDIInNavjW +VMWbrRaCiEghT5b3tpYn6jzVDenjxwg= +=vdIK +-----END PGP SIGNATURE----- + +------=_Part_4_36792537.1634138717374-- + + +R6166fa5d +V32b +Ge8e60c1060fa6661a804000073f46975 + diff --git a/docker-mailserver/maildata_source/flowcrypt.test/denbond7/mailboxes/Sent/dbox-Mails/u.26 b/docker-mailserver/maildata_source/flowcrypt.test/denbond7/mailboxes/Sent/dbox-Mails/u.26 new file mode 100644 index 0000000000..2fdebcf0f3 --- /dev/null +++ b/docker-mailserver/maildata_source/flowcrypt.test/denbond7/mailboxes/Sent/dbox-Mails/u.26 @@ -0,0 +1,36 @@ +2 M1e C6166fa82 +N 000000000000034C +Date: Wed, 13 Oct 2021 18:25:51 +0300 (GMT+03:00) +From: denbond7@flowcrypt.test +To: default@flowcrypt.test +Message-ID: <116269160.1.1634138751584@flowcrypt.test> +Subject: SIGNED_MESSAGE. --clearsign +MIME-Version: 1.0 +Content-Type: multipart/mixed; + boundary="----=_Part_0_129401711.1634138751570" +User-Agent: FlowCrypt_Android_1.2.3_dev_123__2021_10_13 + +------=_Part_0_129401711.1634138751570 +Content-Type: text/plain; charset=us-ascii +Content-Transfer-Encoding: 7bit + +-----BEGIN PGP SIGNED MESSAGE----- +Hash: SHA512 + +Some important text that is signed +-----BEGIN PGP SIGNATURE----- +Version: PGPainless + +iHUEARYKAAYFAmFm9GEAIQkQwyCJzWr41s4WIQTBZCjWAcs5N4nPYdTDIInNavjW +zr6UAQCd8RYlxeawHRJui2T6tl+uKe2jeaQ08rfFaMzPQoumWgD/Q3KqJhL+6IkC +VMWbrRaCiEghT5b3tpYn6jzVDenjxwg= +=vdIK +-----END PGP SIGNATURE----- + +------=_Part_0_129401711.1634138751570-- + + +R6166fa7f +V368 +G6000971782fa66615805000073f46975 + diff --git a/docker-mailserver/maildata_source/flowcrypt.test/denbond7/mailboxes/Trash/dbox-Mails/dovecot.index.log b/docker-mailserver/maildata_source/flowcrypt.test/denbond7/mailboxes/Trash/dbox-Mails/dovecot.index.log index 13a59ba1b6f8146bfc5c10fe2e2a5e7f31f38005..c5147d3cc8468faa08381d05f65feb7acf9fdea2 100644 GIT binary patch delta 24 fcmbOsvO;8o1eZWVLqm%K1A{;S0}DgKue3w}So;R_ delta 7 OcmZ1>GDBp81Q!4bsRBCy From b84cc2ac215b7325d63b63807fe3bc6008d7bd44 Mon Sep 17 00:00:00 2001 From: DenBond7 Date: Wed, 13 Oct 2021 18:46:42 +0300 Subject: [PATCH 3/3] Added tests.| #1474 --- .../messages/info/signed_msg_clearsign.json | 46 ++++++++++++++++ .../info/signed_msg_clearsign_broken.json | 55 +++++++++++++++++++ .../messages/mime/signed_msg_clearsign.txt | 37 +++++++++++++ .../mime/signed_msg_clearsign_broken.txt | 36 ++++++++++++ .../ui/activity/MessageDetailsActivityTest.kt | 35 ++++++++++++ 5 files changed, 209 insertions(+) create mode 100644 FlowCrypt/src/androidTest/assets/messages/info/signed_msg_clearsign.json create mode 100644 FlowCrypt/src/androidTest/assets/messages/info/signed_msg_clearsign_broken.json create mode 100644 FlowCrypt/src/androidTest/assets/messages/mime/signed_msg_clearsign.txt create mode 100644 FlowCrypt/src/androidTest/assets/messages/mime/signed_msg_clearsign_broken.txt diff --git a/FlowCrypt/src/androidTest/assets/messages/info/signed_msg_clearsign.json b/FlowCrypt/src/androidTest/assets/messages/info/signed_msg_clearsign.json new file mode 100644 index 0000000000..0a8b754efa --- /dev/null +++ b/FlowCrypt/src/androidTest/assets/messages/info/signed_msg_clearsign.json @@ -0,0 +1,46 @@ +{ + "encryptionType": "STANDARD", + "msgBlocks": [ + { + "complete": true, + "content": " \u003c!DOCTYPE html\u003e\n \u003chtml\u003e\n \u003chead\u003e\n \u003cmeta name\u003d\"viewport\" content\u003d\"width\u003ddevice-width\"/\u003e\n \u003cstyle\u003e\n body { word-wrap: break-word; word-break: break-word; hyphens: auto; margin-left: 0px; padding-left: 0px; }\n body img { display: inline !important; height: auto !important; max-width: 95% !important; }\n body pre { white-space: pre-wrap !important; }\n body \u003e div.MsgBlock \u003e table { zoom: 75% } /* table layouts tend to overflow - eg emails from fb */\n \u003c/style\u003e\n \u003c/head\u003e\n \u003cbody\u003e\u003cdiv class\u003d\"MsgBlock GRAY\" style\u003d\"background: white;padding-left: 8px;min-height: 50px;padding-top: 4px;padding-bottom: 4px;width: 100%;border: 1px solid #f0f0f0;border-left: 8px solid #989898;border-right: none;\"\u003e\u003chtml\u003e\u003chead\u003e\u003c/head\u003e\u003cbody\u003eSome important text that is signed\u003c/body\u003e\u003c/html\u003e\u003c/div\u003e\u003c!-- next MsgBlock --\u003e\n\u003c/body\u003e\n \u003c/html\u003e", + "type": "plainHtml" + } + ], + "msgEntity": { + "cc": [], + "email": "default@flowcrypt.test", + "flags": "\\SEEN", + "folder": "INBOX", + "from": [ + { + "address": "denbond7@flowcrypt.test" + } + ], + "fromAddress": "denbond7@flowcrypt.test", + "hasAttachments": false, + "id": 327, + "isEncrypted": false, + "isNew": false, + "isSeen": true, + "msgState": "NONE", + "receivedDate": 1634138754000, + "replyTo": "denbond7@flowcrypt.test", + "replyToAddress": [ + { + "address": "denbond7@flowcrypt.test" + } + ], + "sentDate": 1634138751000, + "subject": "SIGNED_MESSAGE. --clearsign", + "to": [ + { + "address": "default@flowcrypt.test" + } + ], + "toAddress": "default@flowcrypt.test", + "uid": 28, + "uidAsHEX": "1c" + }, + "text": "Some important text that is signed" +} diff --git a/FlowCrypt/src/androidTest/assets/messages/info/signed_msg_clearsign_broken.json b/FlowCrypt/src/androidTest/assets/messages/info/signed_msg_clearsign_broken.json new file mode 100644 index 0000000000..337c9d46c0 --- /dev/null +++ b/FlowCrypt/src/androidTest/assets/messages/info/signed_msg_clearsign_broken.json @@ -0,0 +1,55 @@ +{ + "encryptionType": "STANDARD", + "msgBlocks": [ + { + "complete": true, + "content": "\u003c!DOCTYPE html\u003e\n\u003chtml\u003e\n\u003chead\u003e\n \u003cmeta name\u003d\"viewport\" content\u003d\"width\u003ddevice-width\"/\u003e\n \u003cstyle\u003e\n body { word-wrap: break-word; word-break: break-word; hyphens: auto; margin-left: 0px; padding-left: 0px; }\n body img { display: inline !important; height: auto !important; max-width: 95% !important; }\n body pre { white-space: pre-wrap !important; }\n body \u003e div.MsgBlock \u003e table { zoom: 75% } /* table layouts tend to overflow - eg emails from fb */\n \u003c/style\u003e\n\u003c/head\u003e\n\u003cbody\u003e\u003c/body\u003e\n\u003c/html\u003e", + "type": "plainHtml" + }, + { + "complete": true, + "content": "-----BEGIN PGP SIGNED MESSAGE-----\r\nHash: SHA512\r\n\r\nSome important text that is signed\r\n-----BEGIN PGP SIGNATURE-----\r\nVersion: PGPainless\r\n\r\niHUEARYKAAYFAmFm9GEAIQkQwyCJzWr41s4WIQTBZCjWAcs5N4nPYdTDIInNavjW\r\nVMWbrRaCiEghT5b3tpYn6jzVDenjxwg\u003d\r\n\u003dvdIK\r\n-----END PGP SIGNATURE-----", + "error": { + "errorMsg": "[IOException]: crc check failed in armored message." + }, + "signedType": "SIGNED_MSG", + "type": "signedMsg" + } + ], + "msgEntity": { + "cc": [], + "email": "default@flowcrypt.test", + "flags": "\\SEEN", + "folder": "INBOX", + "from": [ + { + "address": "denbond7@flowcrypt.test" + } + ], + "fromAddress": "denbond7@flowcrypt.test", + "hasAttachments": false, + "id": 326, + "isEncrypted": false, + "isNew": false, + "isSeen": true, + "msgState": "NONE", + "receivedDate": 1634138720000, + "replyTo": "denbond7@flowcrypt.test", + "replyToAddress": [ + { + "address": "denbond7@flowcrypt.test" + } + ], + "sentDate": 1634138717000, + "subject": "SIGNED_MESSAGE. --clearsign. Broken", + "to": [ + { + "address": "default@flowcrypt.test" + } + ], + "toAddress": "default@flowcrypt.test", + "uid": 27, + "uidAsHEX": "1b" + }, + "text": "" +} diff --git a/FlowCrypt/src/androidTest/assets/messages/mime/signed_msg_clearsign.txt b/FlowCrypt/src/androidTest/assets/messages/mime/signed_msg_clearsign.txt new file mode 100644 index 0000000000..9e6c1d5f45 --- /dev/null +++ b/FlowCrypt/src/androidTest/assets/messages/mime/signed_msg_clearsign.txt @@ -0,0 +1,37 @@ +Return-Path: +Delivered-To: default@flowcrypt.test +Received: from mail.flowcrypt.test + by mail.flowcrypt.test with LMTP + id sM02GYL6ZmG+BAAAc/RpdQ + (envelope-from ) + for ; Wed, 13 Oct 2021 15:25:54 +0000 +Received: from localhost (localhost [127.0.0.1]) + by mail.flowcrypt.test (Postfix) with ESMTP id 6625D1C2104 + for ; Wed, 13 Oct 2021 15:25:54 +0000 (UTC) +Date: Wed, 13 Oct 2021 18:25:51 +0300 (GMT+03:00) +From: denbond7@flowcrypt.test +To: default@flowcrypt.test +Message-ID: <116269160.1.1634138751584@flowcrypt.test> +Subject: SIGNED_MESSAGE. --clearsign +Mime-Version: 1.0 +Content-Type: multipart/mixed; + boundary="----=_Part_0_129401711.1634138751570" + +------=_Part_0_129401711.1634138751570 +Content-Type: text/plain; charset=us-ascii +Content-Transfer-Encoding: 7bit + +-----BEGIN PGP SIGNED MESSAGE----- +Hash: SHA512 + +Some important text that is signed +-----BEGIN PGP SIGNATURE----- +Version: PGPainless + +iHUEARYKAAYFAmFm9GEAIQkQwyCJzWr41s4WIQTBZCjWAcs5N4nPYdTDIInNavjW +zr6UAQCd8RYlxeawHRJui2T6tl+uKe2jeaQ08rfFaMzPQoumWgD/Q3KqJhL+6IkC +VMWbrRaCiEghT5b3tpYn6jzVDenjxwg= +=vdIK +-----END PGP SIGNATURE----- + +------=_Part_0_129401711.1634138751570-- diff --git a/FlowCrypt/src/androidTest/assets/messages/mime/signed_msg_clearsign_broken.txt b/FlowCrypt/src/androidTest/assets/messages/mime/signed_msg_clearsign_broken.txt new file mode 100644 index 0000000000..5d3f4adfb2 --- /dev/null +++ b/FlowCrypt/src/androidTest/assets/messages/mime/signed_msg_clearsign_broken.txt @@ -0,0 +1,36 @@ +Return-Path: +Delivered-To: default@flowcrypt.test +Received: from mail.flowcrypt.test + by mail.flowcrypt.test with LMTP + id y3fSEmD6ZmG+BAAAc/RpdQ + (envelope-from ) + for ; Wed, 13 Oct 2021 15:25:20 +0000 +Received: from localhost (localhost [127.0.0.1]) + by mail.flowcrypt.test (Postfix) with ESMTP id 49C011C2101 + for ; Wed, 13 Oct 2021 15:25:20 +0000 (UTC) +Date: Wed, 13 Oct 2021 18:25:17 +0300 (GMT+03:00) +From: denbond7@flowcrypt.test +To: default@flowcrypt.test +Message-ID: <231862942.5.1634138717382@flowcrypt.test> +Subject: SIGNED_MESSAGE. --clearsign. Broken +Mime-Version: 1.0 +Content-Type: multipart/mixed; + boundary="----=_Part_4_36792537.1634138717374" + +------=_Part_4_36792537.1634138717374 +Content-Type: text/plain; charset=us-ascii +Content-Transfer-Encoding: 7bit + +-----BEGIN PGP SIGNED MESSAGE----- +Hash: SHA512 + +Some important text that is signed +-----BEGIN PGP SIGNATURE----- +Version: PGPainless + +iHUEARYKAAYFAmFm9GEAIQkQwyCJzWr41s4WIQTBZCjWAcs5N4nPYdTDIInNavjW +VMWbrRaCiEghT5b3tpYn6jzVDenjxwg= +=vdIK +-----END PGP SIGNATURE----- + +------=_Part_4_36792537.1634138717374-- diff --git a/FlowCrypt/src/androidTest/java/com/flowcrypt/email/ui/activity/MessageDetailsActivityTest.kt b/FlowCrypt/src/androidTest/java/com/flowcrypt/email/ui/activity/MessageDetailsActivityTest.kt index f8c3aa6fb3..983b0e5810 100644 --- a/FlowCrypt/src/androidTest/java/com/flowcrypt/email/ui/activity/MessageDetailsActivityTest.kt +++ b/FlowCrypt/src/androidTest/java/com/flowcrypt/email/ui/activity/MessageDetailsActivityTest.kt @@ -36,6 +36,7 @@ import com.flowcrypt.email.api.email.EmailUtil import com.flowcrypt.email.api.email.model.AttachmentInfo import com.flowcrypt.email.api.email.model.IncomingMessageInfo import com.flowcrypt.email.api.retrofit.response.model.DecryptErrorMsgBlock +import com.flowcrypt.email.api.retrofit.response.model.GenericMsgBlock import com.flowcrypt.email.api.retrofit.response.model.PublicKeyMsgBlock import com.flowcrypt.email.database.entity.MessageEntity import com.flowcrypt.email.junit.annotations.NotReadyForCI @@ -578,6 +579,40 @@ class MessageDetailsActivityTest : BaseMessageDetailsActivityTest() { baseCheck(msgInfo) } + @Test + fun testSignedMsgClearSign() { + val msgInfo = getMsgInfo( + "messages/info/signed_msg_clearsign.json", + "messages/mime/signed_msg_clearsign.txt" + ) + baseCheck(msgInfo) + } + + @Test + fun testSignedMsgClearSignBroken() { + val msgInfo = getMsgInfo( + "messages/info/signed_msg_clearsign_broken.json", + "messages/mime/signed_msg_clearsign_broken.txt" + ) ?: throw NullPointerException() + + assertThat(msgInfo, notNullValue()) + + val details = msgInfo.msgEntity + + launchActivity(details) + matchHeader(msgInfo) + + val block = msgInfo.msgBlocks?.get(1) as GenericMsgBlock + val errorMsg = getResString( + R.string.msg_contains_not_valid_block, + block.type.toString(), + requireNotNull(block.error?.errorMsg) + ) + onView(withId(R.id.textViewErrorMessage)) + .check(matches(withText(errorMsg))) + matchReplyButtons(details) + } + private fun testMissingKey(incomingMsgInfo: IncomingMessageInfo?) { assertThat(incomingMsgInfo, notNullValue())