HTMLPurifier 4.4.0
|
00001 <?php 00002 00006 class HTMLPurifier_AttrDef_HTML_Class extends HTMLPurifier_AttrDef_HTML_Nmtokens 00007 { 00008 protected function split($string, $config, $context) { 00009 // really, this twiddle should be lazy loaded 00010 $name = $config->getDefinition('HTML')->doctype->name; 00011 if ($name == "XHTML 1.1" || $name == "XHTML 2.0") { 00012 return parent::split($string, $config, $context); 00013 } else { 00014 return preg_split('/\s+/', $string); 00015 } 00016 } 00017 protected function filter($tokens, $config, $context) { 00018 $allowed = $config->get('Attr.AllowedClasses'); 00019 $forbidden = $config->get('Attr.ForbiddenClasses'); 00020 $ret = array(); 00021 foreach ($tokens as $token) { 00022 if ( 00023 ($allowed === null || isset($allowed[$token])) && 00024 !isset($forbidden[$token]) && 00025 // We need this O(n) check because of PHP's array 00026 // implementation that casts -0 to 0. 00027 !in_array($token, $ret, true) 00028 ) { 00029 $ret[] = $token; 00030 } 00031 } 00032 return $ret; 00033 } 00034 }