4
* Validate all attributes in the tokens.
7
class HTMLPurifier_Strategy_ValidateAttributes extends HTMLPurifier_Strategy
10
public function execute($tokens, $config, $context) {
13
$validator = new HTMLPurifier_AttrValidator();
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');
4
* Validate all attributes in the tokens.
7
class HTMLPurifier_Strategy_ValidateAttributes extends HTMLPurifier_Strategy
11
* @param HTMLPurifier_Token[] $tokens
12
* @param HTMLPurifier_Config $config
13
* @param HTMLPurifier_Context $context
14
* @return HTMLPurifier_Token[]
16
public 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 instanceof HTMLPurifier_Token_Start && !$token instanceof HTMLPurifier_Token_Empty) {
32
// skip tokens that are armored
33
if (!empty($token->armor['ValidateAttributes'])) {
37
// note that we have no facilities here for removing tokens
38
$validator->validateToken($token, $config, $context);
40
$context->destroy('CurrentToken');