[Fusionforge-commits] r14766 - trunk/src/common/include

Alain Peyrat aljeux at fusionforge.org
Wed Nov 9 10:43:01 CET 2011


Author: aljeux
Date: 2011-11-09 10:43:00 +0100 (Wed, 09 Nov 2011)
New Revision: 14766

Modified:
   trunk/src/common/include/TextSanitizer.class.php
Log:
Improve purify for broken html code

Modified: trunk/src/common/include/TextSanitizer.class.php
===================================================================
--- trunk/src/common/include/TextSanitizer.class.php	2011-11-09 09:38:07 UTC (rev 14765)
+++ trunk/src/common/include/TextSanitizer.class.php	2011-11-09 09:43:00 UTC (rev 14766)
@@ -245,6 +245,16 @@
 	static function purify ($text) {
 		// Remove string like "<![if !supportLists]>" or "<![endif]>"
 		$text = preg_replace('/<!\[.+?\]>/', '', $text);
+		// Remove non opened tags at the begining
+		$count = 1;
+		while ($count) {
+			$text = preg_replace('/^(<\/[^>]+>)/', '', $text, -1, $count);
+		}
+		// Remove non closed tags at the end
+		$count = 1;
+		while ($count) {
+			$text = preg_replace('/(<[^\/][^>]+>)$/', '', $text, -1, $count);
+		}
 		$config = HTMLPurifier_Config::createDefault();
 		//$config->set('HTML.Allowed','a[href|title],strike,sub,span,font,hr,br,tbody,tr,td,table,div,u,p,ul,li,ol,blockquote,em,strong,sup,input,img,textarea,h1,h2,h3,h4,h5,h6,pre,address');
 		$config->set('Cache.DefinitionImpl', NULL);




More information about the Fusionforge-commits mailing list