HTMLPurifier 4.4.0
|
00001 <?php 00002 00008 require_once dirname(__FILE__) . '/HTMLPurifier.auto.php'; 00009 00010 function kses($string, $allowed_html, $allowed_protocols = null) { 00011 $config = HTMLPurifier_Config::createDefault(); 00012 $allowed_elements = array(); 00013 $allowed_attributes = array(); 00014 foreach ($allowed_html as $element => $attributes) { 00015 $allowed_elements[$element] = true; 00016 foreach ($attributes as $attribute => $x) { 00017 $allowed_attributes["$element.$attribute"] = true; 00018 } 00019 } 00020 $config->set('HTML.AllowedElements', $allowed_elements); 00021 $config->set('HTML.AllowedAttributes', $allowed_attributes); 00022 $allowed_schemes = array(); 00023 if ($allowed_protocols !== null) { 00024 $config->set('URI.AllowedSchemes', $allowed_protocols); 00025 } 00026 $purifier = new HTMLPurifier($config); 00027 return $purifier->purify($string); 00028 } 00029 00030 // vim: et sw=4 sts=4