[3.1.1] Fix text-decoration: none bug
[htmlpurifier.git] / library / HTMLPurifier / AttrDef / CSS / TextDecoration.php
blobaf16d5915572080277f36bf2c4c0a03362ef62df
1 <?php
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 class HTMLPurifier_AttrDef_CSS_TextDecoration extends HTMLPurifier_AttrDef
11 public function validate($string, $config, $context) {
13 static $allowed_values = array(
14 'line-through' => true,
15 'overline' => true,
16 'underline' => true,
19 $string = strtolower($this->parseCDATA($string));
21 if ($string === 'none') return $string;
23 $parts = explode(' ', $string);
24 $final = '';
25 foreach ($parts as $part) {
26 if (isset($allowed_values[$part])) {
27 $final .= $part . ' ';
30 $final = rtrim($final);
31 if ($final === '') return false;
32 return $final;