[3.1.0] Implement DenyElementDecorator for imagecrash-protection against CSS width...
[htmlpurifier/bfroehle.git] / library / HTMLPurifier / AttrDef / CSS / DenyElementDecorator.php
blob756dec3ce8e8f7574470beddf43d8b2817498f47
1 <?php
3 /**
4 * Decorator which enables CSS properties to be disabled for specific elements.
5 */
6 class HTMLPurifier_AttrDef_CSS_DenyElementDecorator extends HTMLPurifier_AttrDef
8 protected $def, $element;
10 /**
11 * @param $def Definition to wrap
12 * @param $element Element to deny
14 public function __construct($def, $element) {
15 $this->def = $def;
16 $this->element = $element;
18 /**
19 * Checks if CurrentToken is set and equal to $this->element
21 public function validate($string, $config, $context) {
22 $token = $context->get('CurrentToken', true);
23 if ($token && $token->name == $this->element) return false;
24 return $this->def->validate($string, $config, $context);