mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2024-11-10 07:38:41 +00:00
baf053b016
Signed-off-by: Edward Z. Yang <edwardzyang@thewritingpot.com>
23 lines
635 B
PHP
23 lines
635 B
PHP
<?php
|
|
|
|
/**
|
|
* Implements special behavior for class attribute (normally NMTOKENS)
|
|
*/
|
|
class HTMLPurifier_AttrDef_HTML_Class extends HTMLPurifier_AttrDef_HTML_Nmtokens
|
|
{
|
|
protected function filter($tokens, $config, $context) {
|
|
$allowed = $config->get('Attr.AllowedClasses');
|
|
$forbidden = $config->get('Attr.ForbiddenClasses');
|
|
$ret = array();
|
|
foreach ($tokens as $token) {
|
|
if (
|
|
($allowed === null || isset($allowed[$token])) &&
|
|
!isset($forbidden[$token])
|
|
) {
|
|
$ret[] = $token;
|
|
}
|
|
}
|
|
return $ret;
|
|
}
|
|
}
|