HTMLPurifier 4.4.0
/home/ezyang/Dev/htmlpurifier/library/HTMLPurifier/Strategy/ValidateAttributes.php
Go to the documentation of this file.
00001 <?php
00002 
00007 class HTMLPurifier_Strategy_ValidateAttributes extends HTMLPurifier_Strategy
00008 {
00009 
00010     public function execute($tokens, $config, $context) {
00011 
00012         // setup validator
00013         $validator = new HTMLPurifier_AttrValidator();
00014 
00015         $token = false;
00016         $context->register('CurrentToken', $token);
00017 
00018         foreach ($tokens as $key => $token) {
00019 
00020             // only process tokens that have attributes,
00021             //   namely start and empty tags
00022             if (!$token instanceof HTMLPurifier_Token_Start && !$token instanceof HTMLPurifier_Token_Empty) continue;
00023 
00024             // skip tokens that are armored
00025             if (!empty($token->armor['ValidateAttributes'])) continue;
00026 
00027             // note that we have no facilities here for removing tokens
00028             $validator->validateToken($token, $config, $context);
00029 
00030             $tokens[$key] = $token; // for PHP 4
00031         }
00032         $context->destroy('CurrentToken');
00033 
00034         return $tokens;
00035     }
00036 
00037 }
00038 
00039 // vim: et sw=4 sts=4