2006-08-16 15:12:48 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
require_once 'HTMLPurifier/AttrDef.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-01-05 00:10:43 +00:00
|
|
|
public function validate($string, $config, $context) {
|
2006-08-16 15:12:48 +00:00
|
|
|
|
2007-05-20 17:23:09 +00:00
|
|
|
static $allowed_values = array(
|
|
|
|
'line-through' => true,
|
|
|
|
'overline' => true,
|
|
|
|
'underline' => true
|
|
|
|
);
|
|
|
|
|
2006-08-16 15:12:48 +00:00
|
|
|
$string = strtolower($this->parseCDATA($string));
|
|
|
|
$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;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|