diff options
author | Nicolas LÅ“uillet <nicolas@loeuillet.org> | 2014-02-21 15:57:10 +0100 |
---|---|---|
committer | Nicolas LÅ“uillet <nicolas@loeuillet.org> | 2014-02-21 15:57:10 +0100 |
commit | 99679d06884120c57f43b44e55e03595f1f87bed (patch) | |
tree | a3f2a1aa1afdaeca1386d0c6e8a75344fd2241fb /inc/3rdparty/htmlpurifier/HTMLPurifier.kses.php | |
parent | 655214ab30ee84884dc408488b85586f36263fcb (diff) | |
parent | d3b47e94705e17b3ba3529cbb1dc6efe69c5d2b7 (diff) | |
download | wallabag-99679d06884120c57f43b44e55e03595f1f87bed.tar.gz wallabag-99679d06884120c57f43b44e55e03595f1f87bed.tar.zst wallabag-99679d06884120c57f43b44e55e03595f1f87bed.zip |
Merge pull request #481 from wallabag/dev1.5.2
1.5.2
Diffstat (limited to 'inc/3rdparty/htmlpurifier/HTMLPurifier.kses.php')
-rw-r--r-- | inc/3rdparty/htmlpurifier/HTMLPurifier.kses.php | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/inc/3rdparty/htmlpurifier/HTMLPurifier.kses.php b/inc/3rdparty/htmlpurifier/HTMLPurifier.kses.php new file mode 100644 index 00000000..cf0c322f --- /dev/null +++ b/inc/3rdparty/htmlpurifier/HTMLPurifier.kses.php | |||
@@ -0,0 +1,30 @@ | |||
1 | <?php | ||
2 | |||
3 | /** | ||
4 | * @file | ||
5 | * Emulation layer for code that used kses(), substituting in HTML Purifier. | ||
6 | */ | ||
7 | |||
8 | require_once dirname(__FILE__) . '/HTMLPurifier.auto.php'; | ||
9 | |||
10 | function kses($string, $allowed_html, $allowed_protocols = null) | ||
11 | { | ||
12 | $config = HTMLPurifier_Config::createDefault(); | ||
13 | $allowed_elements = array(); | ||
14 | $allowed_attributes = array(); | ||
15 | foreach ($allowed_html as $element => $attributes) { | ||
16 | $allowed_elements[$element] = true; | ||
17 | foreach ($attributes as $attribute => $x) { | ||
18 | $allowed_attributes["$element.$attribute"] = true; | ||
19 | } | ||
20 | } | ||
21 | $config->set('HTML.AllowedElements', $allowed_elements); | ||
22 | $config->set('HTML.AllowedAttributes', $allowed_attributes); | ||
23 | if ($allowed_protocols !== null) { | ||
24 | $config->set('URI.AllowedSchemes', $allowed_protocols); | ||
25 | } | ||
26 | $purifier = new HTMLPurifier($config); | ||
27 | return $purifier->purify($string); | ||
28 | } | ||
29 | |||
30 | // vim: et sw=4 sts=4 | ||