]> git.immae.eu Git - github/wallabag/wallabag.git/blame - inc/3rdparty/htmlpurifier/HTMLPurifier.kses.php
remove autoload section in composer.json
[github/wallabag/wallabag.git] / inc / 3rdparty / htmlpurifier / HTMLPurifier.kses.php
CommitLineData
d4949327
NL
1<?php\r
2\r
3/**\r
4 * @file\r
5 * Emulation layer for code that used kses(), substituting in HTML Purifier.\r
6 */\r
7\r
8require_once dirname(__FILE__) . '/HTMLPurifier.auto.php';\r
9\r
10function kses($string, $allowed_html, $allowed_protocols = null)\r
11{\r
12 $config = HTMLPurifier_Config::createDefault();\r
13 $allowed_elements = array();\r
14 $allowed_attributes = array();\r
15 foreach ($allowed_html as $element => $attributes) {\r
16 $allowed_elements[$element] = true;\r
17 foreach ($attributes as $attribute => $x) {\r
18 $allowed_attributes["$element.$attribute"] = true;\r
19 }\r
20 }\r
21 $config->set('HTML.AllowedElements', $allowed_elements);\r
22 $config->set('HTML.AllowedAttributes', $allowed_attributes);\r
23 if ($allowed_protocols !== null) {\r
24 $config->set('URI.AllowedSchemes', $allowed_protocols);\r
25 }\r
26 $purifier = new HTMLPurifier($config);\r
27 return $purifier->purify($string);\r
28}\r
29\r
30// vim: et sw=4 sts=4\r