Bug 1230815 - remove unused SetStripHtml() and accumulate HTML part to correct tag stripping, test. r=aceman a=jorgk
authorJorg K <jorgk@jorgk.com>
Tue, 23 Oct 2018 10:10:49 +0200
changeset 33445 91563a76b489220e6a017e409878251e5b490946
parent 33444 033b51e4a84171dc703e99dc5792fc06cdf147cd
child 33446 6e8c0cff670e744c8f85a5a403025c970a6deae8
push id387
push userclokep@gmail.com
push dateMon, 10 Dec 2018 21:30:47 +0000
reviewersaceman, jorgk
bugs1230815
Bug 1230815 - remove unused SetStripHtml() and accumulate HTML part to correct tag stripping, test. r=aceman a=jorgk
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--
+
+