0010126: Text gets removed in invalid tags
authorAlexander Stintzing <a.stintzing@metaways.de>
Thu, 7 Aug 2014 08:36:47 +0000 (10:36 +0200)
committerPhilipp Schüle <p.schuele@metaways.de>
Wed, 13 Aug 2014 12:22:21 +0000 (14:22 +0200)
In the invalid HTML Structure like
"<pre><font>Text .." the "<font>Text .." content is removed completely.

Change-Id: Iec3c6f986afb302071395921a1b9e1e5cb2d1952
Reviewed-on: http://gerrit.tine20.com/customers/942
Tested-by: Jenkins CI (http://ci.tine20.com/)
Reviewed-by: Philipp Schüle <p.schuele@metaways.de>
tests/tine20/Felamimail/Controller/MessageTest.php
tests/tine20/Felamimail/files/invalid_html.eml [new file with mode: 0644]
tine20/Felamimail/Controller/Message.php

index 2ac30c7..169cbb3 100644 (file)
@@ -1661,4 +1661,20 @@ class Felamimail_Controller_MessageTest extends PHPUnit_Framework_TestCase
     
         $this->assertEquals('winmail.dat', $message->attachments[0]['filename']);
     }
+    
+    /**
+     * @see: 0010126: Text gets removed in invalid tags
+     *       https://forge.tine20.org/mantisbt/view.php?id=10126
+     *       
+     *       http://htmlpurifier.org/live/configdoc/plain.html#HTML.TidyLevel
+     */
+    public function testInvalidHtml()
+    {
+        $cachedMessage = $this->messageTestHelper('invalid_html.eml');
+        $message = $this->_controller->getCompleteMessage($cachedMessage);
+        
+        $this->assertContains('hier seine Daten :)<br /><br /><span>
+        </span><pre><span style="font-family:tahoma;">John Smith
+Photographer', $message->body);
+    }
 }
diff --git a/tests/tine20/Felamimail/files/invalid_html.eml b/tests/tine20/Felamimail/files/invalid_html.eml
new file mode 100644 (file)
index 0000000..467dbdf
--- /dev/null
@@ -0,0 +1,82 @@
+X-Mozilla-Status: 1015\r
+X-Mozilla-Status2: 00800000\r
+X-Mozilla-Keys:                                                                                 \r
+X-Tine20TestMessage: invalid_html.eml\r
+Message-ID: <532C01E8.5020307@tine20.org>\r
+Date: Fri, 21 Mar 2014 10:10:00 +0100\r
+From: Roberta Wright <rwright@tine20.org>\r
+User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:24.0) Gecko/20100101 Thunderbird/24.4.0\r
+MIME-Version: 1.0\r
+To: Susan Clever <sclever@tine20.org>\r
+Subject: Re: Smith, John?\r
+References: <9b26dff0cf5a3db73228638d0eb8ccab18c70ab8@tine20.org>\r
+In-Reply-To: <9b26dff0cf5a3db73228638d0eb8ccab18c70ab8@tine20.org>\r
+Content-Type: multipart/alternative;\r
+ boundary="------------050101000408050106090209"\r
+\r
+This is a multi-part message in MIME format.\r
+--------------050101000408050106090209\r
+Content-Type: text/plain; charset=UTF-8; format=flowed\r
+Content-Transfer-Encoding: 8bit\r
+\r
+Hallo Susan,\r
+\r
+hier seine Daten :)\r
+\r
+John Smith\r
+Photographer\r
+\r
+\r
+jsmith@tine20.org\r
+www.tine20.org\r
+\r
+\r
+VG\r
+Roberta\r
+\r
+-- \r
+Roberta Wright\r
+Leitung Marketing & Kreation\r
+\r
+rwright@tine20.org\r
+www.tine20.org\r
+\r
+\r
+Am 21.03.14 09:01, schrieb Susan Clever:\r
+> Moin Roberta,\r
+>\r
+> ich wollte unseren Hausmeister um Hilfe / Infromationen bezügl. meines \r
+> Umzuges fragen\r
+> habe aber gestern vergessen ihn anzusprechen.\r
+> Kannst du mir kurz seine mail / Telenummer senden?\r
+>\r
+> Das wäre toll.\r
+> Grüße\r
+> Susan\r
+>\r
+> -- \r
+> Susan Clever\r
+> Grafik + Kreation\r
+>\r
+\r
+--------------050101000408050106090209\r
+Content-Type: text/html; charset=UTF-8\r
+Content-Transfer-Encoding: 8bit\r
+\r
+<html>\r
+  <head>\r
+    <meta content="text/html; charset=UTF-8" http-equiv="Content-Type">\r
+  </head>\r
+  <body bgcolor="#FFFFFF" text="#000000">\r
+    <div class="moz-cite-prefix">Hallo Susan, <br>\r
+      <br>\r
+      hier seine Daten :)<br>\r
+      <br>\r
+      <span id="felamimail-body-signature">\r
+        <pre><font face="tahoma">John Smith\r
+Photographer\r
+\r
+  </body>\r
+</html>\r
+\r
+--------------050101000408050106090209--\r
index 8a464b0..0c96e60 100644 (file)
@@ -670,6 +670,9 @@ class Felamimail_Controller_Message extends Tinebase_Controller_Record_Abstract
         $config->set('HTML.DefinitionID', 'purify message body contents');
         $config->set('HTML.DefinitionRev', 1);
         
+        // @see: http://htmlpurifier.org/live/configdoc/plain.html#HTML.TidyLevel
+        $config->set('HTML.TidyLevel', 'heavy');
+        
         // some config values to consider
         /*
         $config->set('Attr.EnableID', true);