4 * Microsoft's proprietary filter: CSS property
5 * @note Currently supports the alpha filter. In the future, this will
6 * probably need an extensible framework
8 class HTMLPurifier_AttrDef_CSS_Filter
extends HTMLPurifier_AttrDef
11 * @type HTMLPurifier_AttrDef_Integer
13 protected $intValidator;
15 public function __construct()
17 $this->intValidator
= new HTMLPurifier_AttrDef_Integer();
21 * @param string $value
22 * @param HTMLPurifier_Config $config
23 * @param HTMLPurifier_Context $context
26 public function validate($value, $config, $context)
28 $value = $this->parseCDATA($value);
29 if ($value === 'none') {
32 // if we looped this we could support multiple filters
33 $function_length = strcspn($value, '(');
34 $function = trim(substr($value, 0, $function_length));
35 if ($function !== 'alpha' &&
36 $function !== 'Alpha' &&
37 $function !== 'progid:DXImageTransform.Microsoft.Alpha'
41 $cursor = $function_length +
1;
42 $parameters_length = strcspn($value, ')', $cursor);
43 $parameters = substr($value, $cursor, $parameters_length);
44 $params = explode(',', $parameters);
45 $ret_params = array();
47 foreach ($params as $param) {
48 list($key, $value) = explode('=', $param);
50 $value = trim($value);
51 if (isset($lookup[$key])) {
54 if ($key !== 'opacity') {
57 $value = $this->intValidator
->validate($value, $config, $context);
58 if ($value === false) {
68 $ret_params[] = "$key=$value";
71 $ret_parameters = implode(',', $ret_params);
72 $ret_function = "$function($ret_parameters)";