MDL-11517 reserved word MOD used in table alias in questions backup code
[moodle-pu.git] / lib / htmlpurifier / HTMLPurifier / Strategy / ValidateAttributes.php
blob869f3fab932000e09e508de4ee4ee4b8a567aefc
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 HTMLPurifier_ConfigSchema::define(
10 'Attr', 'IDBlacklist', array(), 'list',
11 'Array of IDs not allowed in the document.');
13 /**
14 * Validate all attributes in the tokens.
17 class HTMLPurifier_Strategy_ValidateAttributes extends HTMLPurifier_Strategy
20 function execute($tokens, $config, &$context) {
22 // setup id_accumulator context
23 $id_accumulator = new HTMLPurifier_IDAccumulator();
24 $id_accumulator->load($config->get('Attr', 'IDBlacklist'));
25 $context->register('IDAccumulator', $id_accumulator);
27 // setup validator
28 $validator = new HTMLPurifier_AttrValidator();
30 $token = false;
31 $context->register('CurrentToken', $token);
33 foreach ($tokens as $key => $token) {
35 // only process tokens that have attributes,
36 // namely start and empty tags
37 if ($token->type !== 'start' && $token->type !== 'empty') continue;
39 // skip tokens that are armored
40 if (!empty($token->armor['ValidateAttributes'])) continue;
42 // note that we have no facilities here for removing tokens
43 $validator->validateToken($token, $config, $context);
45 $tokens[$key] = $token; // for PHP 4
48 $context->destroy('IDAccumulator');
49 $context->destroy('CurrentToken');
51 return $tokens;