Fix two bugs with caching of customized raw definitions.
[htmlpurifier.git] / library / HTMLPurifier / Strategy / ValidateAttributes.php
blobc3328a9d44199d596371976e9da5209d0f8f52a3
1 <?php
3 /**
4 * Validate all attributes in the tokens.
5 */
7 class HTMLPurifier_Strategy_ValidateAttributes extends HTMLPurifier_Strategy
10 public function execute($tokens, $config, $context) {
12 // setup validator
13 $validator = new HTMLPurifier_AttrValidator();
15 $token = false;
16 $context->register('CurrentToken', $token);
18 foreach ($tokens as $key => $token) {
20 // only process tokens that have attributes,
21 // namely start and empty tags
22 if (!$token instanceof HTMLPurifier_Token_Start && !$token instanceof HTMLPurifier_Token_Empty) continue;
24 // skip tokens that are armored
25 if (!empty($token->armor['ValidateAttributes'])) continue;
27 // note that we have no facilities here for removing tokens
28 $validator->validateToken($token, $config, $context);
30 $tokens[$key] = $token; // for PHP 4
32 $context->destroy('CurrentToken');
34 return $tokens;
39 // vim: et sw=4 sts=4