Merge commit 'catalyst/MOODLE_19_STABLE' into mdl19-linuxchix
[moodle-linuxchix.git] / lib / htmlpurifier / HTMLPurifier / Strategy / ValidateAttributes.php
blob6debcc336bd2748a40a11cf7d08287c24dfaa49e
1 <?php
3 require_once 'HTMLPurifier/Strategy.php';
4 require_once 'HTMLPurifier/HTMLDefinition.php';
5 require_once 'HTMLPurifier/IDAccumulator.php';
7 require_once 'HTMLPurifier/AttrValidator.php';
9 /**
10 * Validate all attributes in the tokens.
13 class HTMLPurifier_Strategy_ValidateAttributes extends HTMLPurifier_Strategy
16 function execute($tokens, $config, &$context) {
18 // setup validator
19 $validator = new HTMLPurifier_AttrValidator();
21 $token = false;
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');
40 return $tokens;