2006-08-16 15:12:48 +00:00
|
|
|
<?php
|
|
|
|
|
2006-08-20 21:47:15 +00:00
|
|
|
/**
|
|
|
|
* Validates the value for the CSS property text-decoration
|
|
|
|
* @note This class could be generalized into a version that acts sort of
|
|
|
|
* like Enum except you can compound the allowed values.
|
|
|
|
*/
|
2007-02-14 20:38:51 +00:00
|
|
|
class HTMLPurifier_AttrDef_CSS_TextDecoration extends HTMLPurifier_AttrDef
|
2006-08-16 15:12:48 +00:00
|
|
|
{
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2008-01-05 00:10:43 +00:00
|
|
|
public function validate($string, $config, $context) {
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2007-05-20 17:23:09 +00:00
|
|
|
static $allowed_values = array(
|
|
|
|
'line-through' => true,
|
|
|
|
'overline' => true,
|
2008-06-17 03:12:50 +00:00
|
|
|
'underline' => true,
|
2007-05-20 17:23:09 +00:00
|
|
|
);
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2006-08-16 15:12:48 +00:00
|
|
|
$string = strtolower($this->parseCDATA($string));
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2008-06-17 03:12:50 +00:00
|
|
|
if ($string === 'none') return $string;
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2006-08-16 15:12:48 +00:00
|
|
|
$parts = explode(' ', $string);
|
|
|
|
$final = '';
|
|
|
|
foreach ($parts as $part) {
|
2007-05-20 17:23:09 +00:00
|
|
|
if (isset($allowed_values[$part])) {
|
2006-08-16 15:12:48 +00:00
|
|
|
$final .= $part . ' ';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$final = rtrim($final);
|
|
|
|
if ($final === '') return false;
|
|
|
|
return $final;
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2006-08-16 15:12:48 +00:00
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2006-08-16 15:12:48 +00:00
|
|
|
}
|
|
|
|
|
2008-12-06 09:24:59 +00:00
|
|
|
// vim: et sw=4 sts=4
|