3 require_once 'HTMLPurifier/Strategy.php';
4 require_once 'HTMLPurifier/HTMLDefinition.php';
5 require_once 'HTMLPurifier/IDAccumulator.php';
7 require_once 'HTMLPurifier/AttrValidator.php';
10 * Validate all attributes in the tokens.
13 class HTMLPurifier_Strategy_ValidateAttributes
extends HTMLPurifier_Strategy
16 function execute($tokens, $config, &$context) {
19 $validator = new HTMLPurifier_AttrValidator();
22 $context->register('CurrentToken', $token);
24 foreach ($tokens as $key => $token) {
26 // only process tokens that have attributes,
27 // namely start and empty tags
28 if ($token->type
!== 'start' && $token->type
!== 'empty') continue;
30 // skip tokens that are armored
31 if (!empty($token->armor
['ValidateAttributes'])) continue;
33 // note that we have no facilities here for removing tokens
34 $validator->validateToken($token, $config, $context);
36 $tokens[$key] = $token; // for PHP 4
38 $context->destroy('CurrentToken');