PageRenderTime 43ms CodeModel.GetById 22ms RepoModel.GetById 1ms app.codeStats 0ms

/plugins/vjCommentPlugin/lib/tools/htmlpurifier/library/HTMLPurifier/Strategy/ValidateAttributes.php

https://bitbucket.org/Kudlaty/360kdw
PHP | 39 lines | 17 code | 13 blank | 9 comment | 3 complexity | 3e085d73ce91a3d38f3017b112d07a0d MD5 | raw file
Possible License(s): LGPL-2.1
  1. <?php
  2. /**
  3. * Validate all attributes in the tokens.
  4. */
  5. class HTMLPurifier_Strategy_ValidateAttributes extends HTMLPurifier_Strategy
  6. {
  7. public function execute($tokens, $config, $context) {
  8. // setup validator
  9. $validator = new HTMLPurifier_AttrValidator();
  10. $token = false;
  11. $context->register('CurrentToken', $token);
  12. foreach ($tokens as $key => $token) {
  13. // only process tokens that have attributes,
  14. // namely start and empty tags
  15. if (!$token instanceof HTMLPurifier_Token_Start && !$token instanceof HTMLPurifier_Token_Empty) continue;
  16. // skip tokens that are armored
  17. if (!empty($token->armor['ValidateAttributes'])) continue;
  18. // note that we have no facilities here for removing tokens
  19. $validator->validateToken($token, $config, $context);
  20. $tokens[$key] = $token; // for PHP 4
  21. }
  22. $context->destroy('CurrentToken');
  23. return $tokens;
  24. }
  25. }
  26. // vim: et sw=4 sts=4