1 : <?php
2 :
3 : /**
4 : * Validates the value for the CSS property text-decoration
5 : * @note This class could be generalized into a version that acts sort of
6 : * like Enum except you can compound the allowed values.
7 : */
8 1 : class HTMLPurifier_AttrDef_CSS_TextDecoration extends HTMLPurifier_AttrDef
9 : {
10 :
11 : public function validate($string, $config, $context) {
12 :
13 : static $allowed_values = array(
14 : 'line-through' => true,
15 : 'overline' => true,
16 : 'underline' => true,
17 0 : );
18 :
19 0 : $string = strtolower($this->parseCDATA($string));
20 :
21 0 : if ($string === 'none') return $string;
22 :
23 0 : $parts = explode(' ', $string);
24 0 : $final = '';
25 0 : foreach ($parts as $part) {
26 0 : if (isset($allowed_values[$part])) {
27 0 : $final .= $part . ' ';
28 0 : }
29 0 : }
30 0 : $final = rtrim($final);
31 0 : if ($final === '') return false;
32 0 : return $final;
33 :
34 : }
35 :
36 : }
37 :
|