Bug 1230815 - remove unused SetStripHtml() and accumulate HTML part to correct tag stripping, test. r=aceman
authorJorg K <jorgk@jorgk.com>
Tue, 23 Oct 2018 10:10:49 +0200
changeset 33540 617e07ac0498edf0a03aad617447f7f89abef2a3
parent 33539 8072f03fc22d28f8ecefd4dd0dc1b640c78419e0
child 33541 1fdc6763b5472cf29564e8c257bf84ab7402b55a
push id388
push userclokep@gmail.com
push dateMon, 28 Jan 2019 20:54:56 +0000
reviewersaceman
bugs1230815
Bug 1230815 - remove unused SetStripHtml() and accumulate HTML part to correct tag stripping, test. r=aceman
mailnews/base/test/unit/test_searchBody.js
mailnews/test/data/HTML-with-split-tag1.eml
mailnews/test/data/HTML-with-split-tag2.eml
--- a/mailnews/base/test/unit/test_searchBody.js
+++ b/mailnews/base/test/unit/test_searchBody.js
@@ -31,16 +31,18 @@ var Body = nsMsgSearchAttrib.Body;
 
 var Files =
 [
   "../../../data/base64-1",
   "../../../data/basic1",
   "../../../data/multipart-base64-2",
   "../../../data/bug132340",
   "../../../data/bad-charset.eml",
+  "../../../data/HTML-with-split-tag1.eml",
+  "../../../data/HTML-with-split-tag2.eml",
 
   // Base64 encoded bodies.
   "../../../data/01-plaintext.eml",
   "../../../data/02-plaintext+attachment.eml",
   "../../../data/03-HTML.eml",
   "../../../data/04-HTML+attachment.eml",
   "../../../data/05-HTML+embedded-image.eml",
   "../../../data/06-plaintext+HMTL.eml",
@@ -132,16 +134,24 @@ var Tests =
 
   // The four messages with message/rfc822 attachment contain "bodyOfAttachedMessagePlain"
   // or "bodyOfAttachedMessagePläin" in the plaintext part and "bodyOfAttachedMessageHTML"
   // or "bodyOfAttachedMessägeHTML" in the HTML part.
   { value: "bodyOfAttachedMessagePlain", op: Contains, count: 2 },
   { value: "bodyOfAttachedMessagePläin", op: Contains, count: 2 },
   { value: "bodyOfAttachedMessageHTML", op: Contains, count: 1 },
   { value: "bodyOfAttachedMessägeHTML", op: Contains, count: 1 },
+
+  // Test that we don't find anything in HTML tags.
+  { value: "ShouldNotFindThis", op: Contains, count: 0 },
+  { value: "ShouldntFindThisEither", op: Contains, count: 0 },
+  { value: "ShouldntFindHref", op: Contains, count: 0 },
+  { value: "ShouldNotFindAcrossLines", op: Contains, count: 0 },
+  { value: "ShouldFindThisAgain", op: Contains, count: 2 },
+  { value: "ShouldFind AcrossLines", op: Contains, count: 2 },
 ];
 
 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);
new file mode 100644
--- /dev/null
+++ b/mailnews/test/data/HTML-with-split-tag1.eml
@@ -0,0 +1,26 @@
+To: test@example.com
+From: test@example.com
+Subject: HTML with split tag
+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: 8bit
+Content-Language: en-GB
+
+<body>
+HTML part. Now comes the tag
+
+<tag attr1=ShouldNotFindThis
+attr2="ShouldntFindThisEither">
+
+ShouldFindThisAgain
+
+The following should *not* be found: ShouldNotFind
+AcrossLines
+
+<a href="ShouldntFindHref">ShouldFind
+AcrossLines</a>
+</body>
new file mode 100644
--- /dev/null
+++ b/mailnews/test/data/HTML-with-split-tag2.eml
@@ -0,0 +1,41 @@
+To: test@example.com
+From: test@example.com
+Subject: HTML with split tag
+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: multipart/alternative;
+ boundary="------------FAB286B8794CC63C0A0FD1BB"
+
+This is a multi-part message in MIME format.
+--------------FAB286B8794CC63C0A0FD1BB
+Content-Type: text/plain; charset="us-ascii"
+Content-Transfer-Encoding: 7bit
+
+Text part
+
+
+--------------FAB286B8794CC63C0A0FD1BB
+Content-Type: text/html; charset="us-ascii"
+Content-Transfer-Encoding: 7bit
+
+<body>
+HTML part. Now comes the tag
+
+<tag attr1=ShouldNotFindThis
+attr2="ShouldntFindThisEither">
+
+ShouldFindThisAgain
+
+The following should *not* be found: ShouldNotFind
+AcrossLines
+
+<a href="ShouldntFindHref">ShouldFind
+AcrossLines</a>
+</body>
+
+--------------FAB286B8794CC63C0A0FD1BB--
+
+