From 9e17bd1faad5662e278685143305c1c3723eae21 Mon Sep 17 00:00:00 2001
From: Nathan Gray
Date: Mon, 5 Sep 2011 20:24:10 +0000
Subject: [PATCH] If HTML Tidy is available, use it to clean HTML content
---
etemplate/inc/class.bo_merge.inc.php | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/etemplate/inc/class.bo_merge.inc.php b/etemplate/inc/class.bo_merge.inc.php
index e010cab0fd..038f0813b5 100644
--- a/etemplate/inc/class.bo_merge.inc.php
+++ b/etemplate/inc/class.bo_merge.inc.php
@@ -56,6 +56,16 @@ abstract class bo_merge
*/
public $export_limit;
+
+ /**
+ * Configuration for HTML Tidy to clean up any HTML content that is kept
+ */
+ public static $tidy_config = array(
+ 'clean' => true,
+ 'output-xhtml' => true,
+ 'show-body-only' => true,
+ );
+
/**
* Constructor
*
@@ -723,6 +733,10 @@ abstract class bo_merge
// remove all html tags, evtl. included
if (is_string($value) && (strpos($value,'<') !== false))
{
+ // Clean HTML, if it's being kept
+ if($replace_tags && extension_loaded('tidy')) {
+ $value = tidy_repair_string($value, self::$tidy_config);
+ }
// replace
and
with CRLF (remove and CRLF)
$value = str_replace(array("\r","\n",'
','
','
'),array('','','',"\r\n","\r\n"),$value);
$value = strip_tags($value,implode('',$replace_tags));