[Svn] r4667 - in trunk/roundcubemail: program/lib tests tests/src

trac at roundcube.net trac at roundcube.net
Tue Apr 19 10:23:31 CEST 2011


Author: alec
Date: 2011-04-19 03:23:31 -0500 (Tue, 19 Apr 2011)
New Revision: 4667

Added:
   trunk/roundcubemail/tests/src/htmlcom.txt
Modified:
   trunk/roundcubemail/program/lib/washtml.php
   trunk/roundcubemail/tests/mailfunc.php
Log:
- Fix regression in html conditional comments handling by washtml class


Modified: trunk/roundcubemail/program/lib/washtml.php
===================================================================
--- trunk/roundcubemail/program/lib/washtml.php	2011-04-17 09:34:02 UTC (rev 4666)
+++ trunk/roundcubemail/program/lib/washtml.php	2011-04-19 08:23:31 UTC (rev 4667)
@@ -273,7 +273,8 @@
       $this->config['base_url'] = '';
 
     // Remove invalid HTML comments (#1487759)
-    $html = preg_replace('/<!--[^->]*>/', '', $html);
+    // Don't remove valid conditional comments
+    $html = preg_replace('/<!--[^->[]*>/', '', $html);
 
     @$node->loadHTML($html);
     return $this->dumpHtml($node);

Modified: trunk/roundcubemail/tests/mailfunc.php
===================================================================
--- trunk/roundcubemail/tests/mailfunc.php	2011-04-17 09:34:02 UTC (rev 4666)
+++ trunk/roundcubemail/tests/mailfunc.php	2011-04-19 08:23:31 UTC (rev 4667)
@@ -121,7 +121,7 @@
   function test_mailto()
   {
     $part = $this->get_html_part('src/mailto.txt');
-    
+
     // render HTML in normal mode
     $html = rcmail_html4inline(rcmail_print_body($part, array('safe' => false)), 'foo');
 
@@ -131,4 +131,18 @@
     $this->assertPattern('|'.preg_quote($mailto, '|').'|', $html, "Extended mailto links");
   }
 
+  /**
+   * Test the elimination of HTML comments
+   */
+  function test_html_comments()
+  {
+    $part = $this->get_html_part('src/htmlcom.txt');
+    $washed = rcmail_print_body($part, array('safe' => true));
+
+    // #1487759
+    $this->assertPattern('|<p>test1</p>|', $washed, "Buggy HTML comments");
+    // but conditional comments (<!--[if ...) should be removed
+    $this->assertNoPattern('|<p>test2</p>|', $washed, "Conditional HTML comments");
+  }
+
 }

Added: trunk/roundcubemail/tests/src/htmlcom.txt
===================================================================
--- trunk/roundcubemail/tests/src/htmlcom.txt	                        (rev 0)
+++ trunk/roundcubemail/tests/src/htmlcom.txt	2011-04-19 08:23:31 UTC (rev 4667)
@@ -0,0 +1,16 @@
+<html>
+<head>
+<title>Roundcube Test Message</title>
+</head>
+<body>
+
+<!--REF>
+<p>test1</p>
+<!--DEREF>
+
+<!--[if gte mso 9]><xml>
+    <p>test2</p>
+</xml><![endif]-->
+
+</body>
+</html>
\ No newline at end of file

_______________________________________________
http://lists.roundcube.net/mailman/listinfo/svn



More information about the Svn mailing list