summaryrefslogtreecommitdiff
path: root/functions.php
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2009-06-22 13:56:49 +0400
committerAndrew Dolgov <[email protected]>2009-06-22 13:56:49 +0400
commitf45a286b8d62f710b519a98c7d4b75a0c34d5d10 (patch)
tree0c310b7b9d44e12fac1cd11e1563c4cef9b5eab2 /functions.php
parent5c4461432c290ad4863fd7dc4107121db59b298c (diff)
strip_tags_long: use htmlpurifier to properly reformat html content
Diffstat (limited to 'functions.php')
-rw-r--r--functions.php23
1 files changed, 18 insertions, 5 deletions
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,
+// "<p><a><i><em><b><strong><code><pre><blockquote><br><img><ul><ol><li>");
+
$res = strip_tags_long($res,
- "<p><a><i><em><b><strong><code><pre><blockquote><br><img><ul><ol><li>");
+ "p,a[href],i,em,b,strong,code,pre,blockquote,br,img[src|alt|title],ul,ol,li,h1,h2,h3,h4");
-// $res = preg_replace("/\r\n|\n|\r/", "", $res);
-// $res = strip_tags_long($res, "<p><a><i><em><b><strong><blockquote><br><img><div><span>");
}
if (get_pref($link, "STRIP_IMAGES")) {