]> git.wh0rd.org - tt-rss.git/blame - lib/htmlpurifier/library/HTMLPurifier.kses.php
update HTMLPurifier; enable embedded flash video in articles
[tt-rss.git] / lib / htmlpurifier / library / HTMLPurifier.kses.php
CommitLineData
f45a286b
AD
1<?php
2
3/**
4 * @file
5 * Emulation layer for code that used kses(), substituting in HTML Purifier.
6 */
7
8require_once dirname(__FILE__) . '/HTMLPurifier.auto.php';
9
10function kses($string, $allowed_html, $allowed_protocols = null) {
11 $config = HTMLPurifier_Config::createDefault();
12 $allowed_elements = array();
13 $allowed_attributes = array();
14 foreach ($allowed_html as $element => $attributes) {
15 $allowed_elements[$element] = true;
16 foreach ($attributes as $attribute => $x) {
17 $allowed_attributes["$element.$attribute"] = true;
18 }
19 }
f4f0f80d
AD
20 $config->set('HTML.AllowedElements', $allowed_elements);
21 $config->set('HTML.AllowedAttributes', $allowed_attributes);
f45a286b
AD
22 $allowed_schemes = array();
23 if ($allowed_protocols !== null) {
f4f0f80d 24 $config->set('URI.AllowedSchemes', $allowed_protocols);
f45a286b
AD
25 }
26 $purifier = new HTMLPurifier($config);
27 return $purifier->purify($string);
28}
29
30// vim: et sw=4 sts=4