From f45a286b8d62f710b519a98c7d4b75a0c34d5d10 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Mon, 22 Jun 2009 13:56:49 +0400 Subject: strip_tags_long: use htmlpurifier to properly reformat html content --- functions.php | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) (limited to 'functions.php') diff --git a/functions.php b/functions.php index 6a8e85628..8e98d4874 100644 --- a/functions.php +++ b/functions.php @@ -106,6 +106,7 @@ require_once "lib/simplepie/simplepie.inc"; require_once "lib/magpierss/rss_fetch.inc"; require_once 'lib/magpierss/rss_utils.inc'; + require_once 'lib/htmlpurifier/library/HTMLPurifier.auto.php'; /** * Print a timestamped debug message. @@ -3550,9 +3551,20 @@ } } + function strip_tags_long($string, $allowed) { + + $config = HTMLPurifier_Config::createDefault(); + + $config->set('HTML', 'Allowed', $allowed); + $purifier = new HTMLPurifier($config); + + return $purifier->purify($string); + + } + // http://ru2.php.net/strip-tags - function strip_tags_long($textstring, $allowed){ +/* function strip_tags_long($textstring, $allowed){ while($textstring != strip_tags($textstring, $allowed)) { while (strlen($textstring) != 0) @@ -3569,7 +3581,7 @@ $textstring = $safetext; } return $textstring; - } +} */ function sanitize_rss($link, $str, $force_strip_tags = false) { @@ -3577,11 +3589,12 @@ if (get_pref($link, "STRIP_UNSAFE_TAGS") || $force_strip_tags) { +// $res = strip_tags_long($res, +// "