# HG changeset patch # User Jorg K # Date 1514938415 -3600 # Node ID 96593a2f19eff987b165009a0be750d24a0a9270 # Parent 863d0cd8bb5327ebee696c9c3f5692ef0abf580f Bug 1427645 - add 10 tests for body search for non-ASCII bodies encoded in quoted-printable. r=aceman diff --git a/mailnews/base/test/unit/test_searchBody.js b/mailnews/base/test/unit/test_searchBody.js --- a/mailnews/base/test/unit/test_searchBody.js +++ b/mailnews/base/test/unit/test_searchBody.js @@ -53,17 +53,29 @@ var Files = "../../../data/12-plaintext+attachment.eml", // using ISO-8859-7 (Greek) "../../../data/13-HTML.eml", "../../../data/14-HTML+attachment.eml", "../../../data/15-HTML+embedded-image.eml", "../../../data/16-plaintext+HMTL.eml", // text part is base64 encoded "../../../data/17-plaintext+(HTML+embedded-image).eml", // HTML part is base64 encoded "../../../data/18-plaintext+HTML+attachment.eml", "../../../data/19-(HTML+embedded-image)+attachment.eml", - "../../../data/20-plaintext+(HTML+embedded-image)+attachment.eml" // using windows-1252 + "../../../data/20-plaintext+(HTML+embedded-image)+attachment.eml", // using windows-1252 + + // Bodies with non-ASCII characters in UTF-8 and other charsets, all encoded with quoted printable. + "../../../data/21-plaintext.eml", + "../../../data/22-plaintext+attachment.eml", // using ISO-8859-7 (Greek) + "../../../data/23-HTML.eml", + "../../../data/24-HTML+attachment.eml", + "../../../data/25-HTML+embedded-image.eml", + "../../../data/26-plaintext+HMTL.eml", // text part is base64 encoded + "../../../data/27-plaintext+(HTML+embedded-image).eml", // HTML part is base64 encoded + "../../../data/28-plaintext+HTML+attachment.eml", + "../../../data/29-(HTML+embedded-image)+attachment.eml", + "../../../data/30-plaintext+(HTML+embedded-image)+attachment.eml" // using windows-1252 ] var Tests = [ /* Translate Base64 messages */ // "World!" is contained in three messages, but in bug132340 it's not in a text // part and should not be found. { value: "World!", op: Contains, count: 2 }, /* Don't match the base64 text */ @@ -93,16 +105,24 @@ var Tests = // Messages 11 and 13 to 20 contain "hühü" once. { value: "hühü", op: Contains, count: 9 }, // Message 12 contains Καλησπέρα (good evening in Greek). { value: "Καλησπέρα", op: Contains, count: 1 }, // Messages 16, 17, 18, 20 contain "hïhï" in the plaintext part. { value: "hïhï", op: Contains, count: 4 }, + + // Messages 21 and 23 to 30 contain "höhö" once. + { value: "höhö", op: Contains, count: 9 }, + // Message 22 contains Καλημέρα (good morning in Greek). + { value: "Καλημέρα", op: Contains, count: 1 }, + + // Messages 16, 17, 18, 20 contain "hähä" in the plaintext part. + { value: "hähä", op: Contains, count: 4 }, ]; function fixFile(file) { var fstream = Cc["@mozilla.org/network/file-input-stream;1"] .createInstance(Ci.nsIFileInputStream); fstream.init(file, -1, -1, Ci.nsIFileInputStream.CLOSE_ON_EOF); var sstream = Cc["@mozilla.org/scriptableinputstream;1"] .createInstance(Ci.nsIScriptableInputStream); diff --git a/mailnews/test/data/21-plaintext.eml b/mailnews/test/data/21-plaintext.eml new file mode 100644 --- /dev/null +++ b/mailnews/test/data/21-plaintext.eml @@ -0,0 +1,14 @@ +To: test@example.com +From: test@example.com +Subject: 21 plaintext +Message-ID: <8259dd8e-2293-8765-e720-61dfcd10a6f3@example.com> +Date: Sat, 30 Dec 2017 19:12:38 +0100 +User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:59.0) Gecko/20100101 + Thunderbird/59.0a1 +MIME-Version: 1.0 +Content-Type: text/plain; charset="utf-8"; format=flowed +Content-Transfer-Encoding: quoted-printable +Content-Language: en-GB + +Search for h=C3=B6h=C3=B6 + diff --git a/mailnews/test/data/22-plaintext+attachment.eml b/mailnews/test/data/22-plaintext+attachment.eml new file mode 100644 --- /dev/null +++ b/mailnews/test/data/22-plaintext+attachment.eml @@ -0,0 +1,32 @@ +To: test@example.com +From: test@example.com +Subject: 22 plaintext + attachment +Message-ID: <9ec4f4cb-b14b-aed6-a042-58897d12e4a9@example.com> +Date: Sat, 30 Dec 2017 19:15:38 +0100 +User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:59.0) Gecko/20100101 + Thunderbird/59.0a1 +MIME-Version: 1.0 +Content-Type: multipart/mixed; + boundary="------------BC006DD22051247571F398E0" +Content-Language: en-GB + +This is a multi-part message in MIME format. +--------------BC006DD22051247571F398E0 +Content-Type: text/plain; charset=ISO-8859-7; format=flowed +Content-Transfer-Encoding: quoted-printable + +Search for Greek text =CA=E1=EB=E7=EC=DD=F1=E1 + +--------------BC006DD22051247571F398E0 +Content-Type: image/png; + name="attach.png" +Content-Transfer-Encoding: base64 +Content-Disposition: attachment; + filename="attach.png" + +iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAIAAACQkWg2AAAAAXNSR0IArs4c6QAAAARnQU1B +AACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAASdEVYdFNvZnR3YXJlAEdyZWVuc2hv +dF5VCAUAAABpSURBVDhP3dA7EoAgDEXR7Ew+bgdx/018BEYyiICtb27FcCig3Z7Im6gK3ZxN +/RcQkb6aK8DjtuRMzMEAiNGvlFpgtyOdEjFz14xA10wA1pg5wLRZAthtVgEm5vGtA4DhvILa +O8A+AuYLy0U5xUUpL8kAAAAASUVORK5CYII= +--------------BC006DD22051247571F398E0-- diff --git a/mailnews/test/data/23-HTML.eml b/mailnews/test/data/23-HTML.eml new file mode 100644 --- /dev/null +++ b/mailnews/test/data/23-HTML.eml @@ -0,0 +1,14 @@ +To: test@example.com +From: test@example.com +Subject: 23 HTML +Message-ID: <8259dd8e-2293-8765-e720-61dfcd10a6f3@example.com> +Date: Sat, 30 Dec 2017 19:12:38 +0100 +User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:59.0) Gecko/20100101 + Thunderbird/59.0a1 +MIME-Version: 1.0 +Content-Type: text/html; charset="utf-8"; format=flowed +Content-Transfer-Encoding: quoted-printable +Content-Language: en-GB + +Search for h=C3=B6h=C3=B6 + diff --git a/mailnews/test/data/24-HTML+attachment.eml b/mailnews/test/data/24-HTML+attachment.eml new file mode 100644 --- /dev/null +++ b/mailnews/test/data/24-HTML+attachment.eml @@ -0,0 +1,32 @@ +To: test@example.com +From: test@example.com +Subject: 24 HTML + attachment +Message-ID: <9ec4f4cb-b14b-aed6-a042-58897d12e4a9@example.com> +Date: Sat, 30 Dec 2017 19:15:38 +0100 +User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:59.0) Gecko/20100101 + Thunderbird/59.0a1 +MIME-Version: 1.0 +Content-Type: multipart/mixed; + boundary="------------BC006DD22051247571F398E0" +Content-Language: en-GB + +This is a multi-part message in MIME format. +--------------BC006DD22051247571F398E0 +Content-Type: text/html; charset="utf-8"; format=flowed +Content-Transfer-Encoding: quoted-printable + +Search for h=C3=B6h=C3=B6 + +--------------BC006DD22051247571F398E0 +Content-Type: image/png; + name="attach.png" +Content-Transfer-Encoding: base64 +Content-Disposition: attachment; + filename="attach.png" + +iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAIAAACQkWg2AAAAAXNSR0IArs4c6QAAAARnQU1B +AACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAASdEVYdFNvZnR3YXJlAEdyZWVuc2hv +dF5VCAUAAABpSURBVDhP3dA7EoAgDEXR7Ew+bgdx/018BEYyiICtb27FcCig3Z7Im6gK3ZxN +/RcQkb6aK8DjtuRMzMEAiNGvlFpgtyOdEjFz14xA10wA1pg5wLRZAthtVgEm5vGtA4DhvILa +O8A+AuYLy0U5xUUpL8kAAAAASUVORK5CYII= +--------------BC006DD22051247571F398E0-- diff --git a/mailnews/test/data/25-HTML+embedded-image.eml b/mailnews/test/data/25-HTML+embedded-image.eml new file mode 100644 --- /dev/null +++ b/mailnews/test/data/25-HTML+embedded-image.eml @@ -0,0 +1,42 @@ +To: test@example.com +From: test@example.com +Subject: 25 HTML + embedded image +Message-ID: +Date: Sat, 30 Dec 2017 19:26:23 +0100 +User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:59.0) Gecko/20100101 + Thunderbird/59.0a1 +MIME-Version: 1.0 +Content-Type: multipart/related; + boundary="------------B2BBD36A919AB2B2F84E2469" +Content-Language: en-GB + +This is a multi-part message in MIME format. +--------------B2BBD36A919AB2B2F84E2469 +Content-Type: text/html; charset="utf-8" +Content-Transfer-Encoding: quoted-printable + + + + + + + +

Search for h=C3=B6h=C3=B6

+

+ + + +--------------B2BBD36A919AB2B2F84E2469 +Content-Type: image/png; + name="kigaaldcbanejcbi.png" +Content-Transfer-Encoding: base64 +Content-ID: +Content-Disposition: inline; + filename="kigaaldcbanejcbi.png" + +iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAIAAACQkWg2AAAAAXNSR0IArs4c6QAAAARnQU1B +AACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAASdEVYdFNvZnR3YXJlAEdyZWVuc2hv +dF5VCAUAAABpSURBVDhP3dA7EoAgDEXR7Ew+bgdx/018BEYyiICtb27FcCig3Z7Im6gK3ZxN +/RcQkb6aK8DjtuRMzMEAiNGvlFpgtyOdEjFz14xA10wA1pg5wLRZAthtVgEm5vGtA4DhvILa +O8A+AuYLy0U5xUUpL8kAAAAASUVORK5CYII= +--------------B2BBD36A919AB2B2F84E2469-- diff --git a/mailnews/test/data/26-plaintext+HMTL.eml b/mailnews/test/data/26-plaintext+HMTL.eml new file mode 100644 --- /dev/null +++ b/mailnews/test/data/26-plaintext+HMTL.eml @@ -0,0 +1,27 @@ +To: test@example.com +From: test@example.com +Subject: 26 plaintext + HMTL +Message-ID: +Date: Sat, 30 Dec 2017 19:31:21 +0100 +User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:59.0) Gecko/20100101 + Thunderbird/59.0a1 +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="------------FAB286B8794CC63C0A0FD1BB" +Content-Language: de-DE + +This is a multi-part message in MIME format. +--------------FAB286B8794CC63C0A0FD1BB +Content-Type: text/plain; charset="utf-8"; format=flowed +Content-Transfer-Encoding: quoted-printable + +Search for h=C3=A4h=C3=A4 + + +--------------FAB286B8794CC63C0A0FD1BB +Content-Type: text/html; charset="utf-8" +Content-Transfer-Encoding: quoted-printable + +Search for h=C3=B6h=C3=B6 + +--------------FAB286B8794CC63C0A0FD1BB-- diff --git a/mailnews/test/data/27-plaintext+(HTML+embedded-image).eml b/mailnews/test/data/27-plaintext+(HTML+embedded-image).eml new file mode 100644 --- /dev/null +++ b/mailnews/test/data/27-plaintext+(HTML+embedded-image).eml @@ -0,0 +1,56 @@ +To: test@example.com +From: test@example.com +Subject: 27 plaintext + (HTML + embedded image) +Message-ID: +Date: Sat, 30 Dec 2017 19:36:00 +0100 +User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:59.0) Gecko/20100101 + Thunderbird/59.0a1 +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="------------77E82F0826A0A90EABD21FC3" +Content-Language: en-GB + +This is a multi-part message in MIME format. +--------------77E82F0826A0A90EABD21FC3 +Content-Type: text/plain; charset="utf-8"; format=flowed +Content-Transfer-Encoding: quoted-printable + +Search for h=C3=A4h=C3=A4 + + +--------------77E82F0826A0A90EABD21FC3 +Content-Type: multipart/related; + boundary="------------D719681335F2A7D71D3761B1" + + +--------------D719681335F2A7D71D3761B1 +Content-Type: text/html; charset="utf-8" +Content-Transfer-Encoding: quoted-printable + + + + + + + +

Search for h=C3=B6h=C3=B6

+

+ + + +--------------D719681335F2A7D71D3761B1 +Content-Type: image/png; + name="kigaaldcbanejcbi.png" +Content-Transfer-Encoding: base64 +Content-ID: +Content-Disposition: inline; + filename="kigaaldcbanejcbi.png" + +iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAIAAACQkWg2AAAAAXNSR0IArs4c6QAAAARnQU1B +AACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAASdEVYdFNvZnR3YXJlAEdyZWVuc2hv +dF5VCAUAAABpSURBVDhP3dA7EoAgDEXR7Ew+bgdx/018BEYyiICtb27FcCig3Z7Im6gK3ZxN +/RcQkb6aK8DjtuRMzMEAiNGvlFpgtyOdEjFz14xA10wA1pg5wLRZAthtVgEm5vGtA4DhvILa +O8A+AuYLy0U5xUUpL8kAAAAASUVORK5CYII= +--------------D719681335F2A7D71D3761B1-- + +--------------77E82F0826A0A90EABD21FC3-- diff --git a/mailnews/test/data/28-plaintext+HTML+attachment.eml b/mailnews/test/data/28-plaintext+HTML+attachment.eml new file mode 100644 --- /dev/null +++ b/mailnews/test/data/28-plaintext+HTML+attachment.eml @@ -0,0 +1,46 @@ +To: test@example.com +From: test@example.com +Subject: 28 plaintext + HTML + attachment +Message-ID: +Date: Sat, 30 Dec 2017 19:58:40 +0100 +User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:59.0) Gecko/20100101 + Thunderbird/59.0a1 +MIME-Version: 1.0 +Content-Type: multipart/mixed; + boundary="------------A1EC8071C6B86B871C9CB87F" +Content-Language: en-GB + +This is a multi-part message in MIME format. +--------------A1EC8071C6B86B871C9CB87F +Content-Type: multipart/alternative; + boundary="------------9EC5D7C387C9839604A227BB" + + +--------------9EC5D7C387C9839604A227BB +Content-Type: text/plain; charset="utf-8"; format=flowed +Content-Transfer-Encoding: quoted-printable + +Search for h=C3=A4h=C3=A4 + + +--------------9EC5D7C387C9839604A227BB +Content-Type: text/html; charset="utf-8" +Content-Transfer-Encoding: quoted-printable + +Search for h=C3=B6h=C3=B6 + +--------------9EC5D7C387C9839604A227BB-- + +--------------A1EC8071C6B86B871C9CB87F +Content-Type: image/png; + name="attach.png" +Content-Transfer-Encoding: base64 +Content-Disposition: attachment; + filename="attach.png" + +iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAIAAACQkWg2AAAAAXNSR0IArs4c6QAAAARnQU1B +AACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAASdEVYdFNvZnR3YXJlAEdyZWVuc2hv +dF5VCAUAAABpSURBVDhP3dA7EoAgDEXR7Ew+bgdx/018BEYyiICtb27FcCig3Z7Im6gK3ZxN +/RcQkb6aK8DjtuRMzMEAiNGvlFpgtyOdEjFz14xA10wA1pg5wLRZAthtVgEm5vGtA4DhvILa +O8A+AuYLy0U5xUUpL8kAAAAASUVORK5CYII= +--------------A1EC8071C6B86B871C9CB87F-- diff --git a/mailnews/test/data/29-(HTML+embedded-image)+attachment.eml b/mailnews/test/data/29-(HTML+embedded-image)+attachment.eml new file mode 100644 --- /dev/null +++ b/mailnews/test/data/29-(HTML+embedded-image)+attachment.eml @@ -0,0 +1,59 @@ +To: test@example.com +From: test@example.com +Subject: 29 (HTML + embedded image) + attachment +Message-ID: +Date: Sat, 30 Dec 2017 20:19:46 +0100 +User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:59.0) Gecko/20100101 + Thunderbird/59.0a1 +MIME-Version: 1.0 +Content-Type: multipart/mixed; + boundary="------------F5CEBCED9FC06ACB07B3D485" +Content-Language: en-GB + +This is a multi-part message in MIME format. +--------------F5CEBCED9FC06ACB07B3D485 +Content-Type: multipart/related; + boundary="------------1722706F2C203820A6CAA06F" + + +--------------1722706F2C203820A6CAA06F +Content-Type: text/html; charset="utf-8" +Content-Transfer-Encoding: quoted-printable + + + + + + + +

Search for h=C3=B6h=C3=B6

+

+ + + +--------------1722706F2C203820A6CAA06F +Content-Type: image/png; + name="kigaaldcbanejcbi.png" +Content-Transfer-Encoding: base64 +Content-ID: +Content-Disposition: inline; + filename="kigaaldcbanejcbi.png" + +iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAIAAACQkWg2AAAAAXNSR0IArs4c6QAAAARnQU1B +AACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAASdEVYdFNvZnR3YXJlAEdyZWVuc2hv +dF5VCAUAAABpSURBVDhP3dA7EoAgDEXR7Ew+bgdx/018BEYyiICtb27FcCig3Z7Im6gK3ZxN +/RcQkb6aK8DjtuRMzMEAiNGvlFpgtyOdEjFz14xA10wA1pg5wLRZAthtVgEm5vGtA4DhvILa +O8A+AuYLy0U5xUUpL8kAAAAASUVORK5CYII= +--------------1722706F2C203820A6CAA06F-- + +--------------F5CEBCED9FC06ACB07B3D485 +Content-Type: image/png; + name="attach2.png" +Content-Transfer-Encoding: base64 +Content-Disposition: attachment; + filename="attach2.png" + +iVBORw0KGgoAAAANSUhEUgAAAA4AAAAOCAIAAACQKrqGAAAAAXNSR0IArs4c6QAAAARnQU1B +AACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAASdEVYdFNvZnR3YXJlAEdyZWVuc2hv +dF5VCAUAAAAVSURBVChTY/hPNBhVOqqUaKX//wMA005J0zvV0VsAAAAASUVORK5CYII= +--------------F5CEBCED9FC06ACB07B3D485-- diff --git a/mailnews/test/data/30-plaintext+(HTML+embedded-image)+attachment.eml b/mailnews/test/data/30-plaintext+(HTML+embedded-image)+attachment.eml new file mode 100644 --- /dev/null +++ b/mailnews/test/data/30-plaintext+(HTML+embedded-image)+attachment.eml @@ -0,0 +1,73 @@ +To: test@example.com +From: test@example.com +Subject: 30 plaintext + (HTML + embedded image) + attachment +Message-ID: <1e58c8f2-3a15-96e7-76b7-046cf6e1ce1e@example.com> +Date: Sat, 30 Dec 2017 20:50:01 +0100 +User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:59.0) Gecko/20100101 + Thunderbird/59.0a1 +MIME-Version: 1.0 +Content-Type: multipart/mixed; + boundary="------------B94553864BC0A4472640622E" +Content-Language: en-GB + +This is a multi-part message in MIME format. +--------------B94553864BC0A4472640622E +Content-Type: multipart/alternative; + boundary="------------B24EA868A72E5E6144485481" + + +--------------B24EA868A72E5E6144485481 +Content-Type: text/plain; charset=windows-1252; format=flowed +Content-Transfer-Encoding: quoted-printable + +Search for h=E4h=E4 + + +--------------B24EA868A72E5E6144485481 +Content-Type: multipart/related; + boundary="------------D1360749D11EBC0C64444B6C" + + +--------------D1360749D11EBC0C64444B6C +Content-Type: text/html; charset=windows-1252 +Content-Transfer-Encoding: quoted-printable + + + + + + + +

Search for h=F6h=F6

+

+ + + +--------------D1360749D11EBC0C64444B6C +Content-Type: image/png; + name="kigaaldcbanejcbi.png" +Content-Transfer-Encoding: base64 +Content-ID: +Content-Disposition: inline; + filename="kigaaldcbanejcbi.png" + +iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAIAAACQkWg2AAAAAXNSR0IArs4c6QAAAARnQU1B +AACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAASdEVYdFNvZnR3YXJlAEdyZWVuc2hv +dF5VCAUAAABpSURBVDhP3dA7EoAgDEXR7Ew+bgdx/018BEYyiICtb27FcCig3Z7Im6gK3ZxN +/RcQkb6aK8DjtuRMzMEAiNGvlFpgtyOdEjFz14xA10wA1pg5wLRZAthtVgEm5vGtA4DhvILa +O8A+AuYLy0U5xUUpL8kAAAAASUVORK5CYII= +--------------D1360749D11EBC0C64444B6C-- + +--------------B24EA868A72E5E6144485481-- + +--------------B94553864BC0A4472640622E +Content-Type: image/png; + name="attach2.png" +Content-Transfer-Encoding: base64 +Content-Disposition: attachment; + filename="attach2.png" + +iVBORw0KGgoAAAANSUhEUgAAAA4AAAAOCAIAAACQKrqGAAAAAXNSR0IArs4c6QAAAARnQU1B +AACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAASdEVYdFNvZnR3YXJlAEdyZWVuc2hv +dF5VCAUAAAAVSURBVChTY/hPNBhVOqqUaKX//wMA005J0zvV0VsAAAAASUVORK5CYII= +--------------B94553864BC0A4472640622E--