2006-08-27 00:49:34 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
require_once 'HTMLPurifier/AttrDef.php';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Validates the border property as defined by CSS.
|
|
|
|
*/
|
2007-02-14 20:38:51 +00:00
|
|
|
class HTMLPurifier_AttrDef_CSS_Border extends HTMLPurifier_AttrDef
|
2006-08-27 00:49:34 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Local copy of properties this property is shorthand for.
|
|
|
|
*/
|
|
|
|
var $info = array();
|
|
|
|
|
2007-02-14 20:38:51 +00:00
|
|
|
function HTMLPurifier_AttrDef_CSS_Border($config) {
|
2006-08-31 20:33:07 +00:00
|
|
|
$def = $config->getCSSDefinition();
|
2006-08-27 00:49:34 +00:00
|
|
|
$this->info['border-width'] = $def->info['border-width'];
|
|
|
|
$this->info['border-style'] = $def->info['border-style'];
|
|
|
|
$this->info['border-top-color'] = $def->info['border-top-color'];
|
|
|
|
}
|
|
|
|
|
|
|
|
function validate($string, $config, &$context) {
|
|
|
|
$string = $this->parseCDATA($string);
|
|
|
|
// we specifically will not support rgb() syntax with spaces
|
|
|
|
$bits = explode(' ', $string);
|
|
|
|
$done = array(); // segments we've finished
|
|
|
|
$ret = ''; // return value
|
|
|
|
foreach ($bits as $bit) {
|
|
|
|
foreach ($this->info as $propname => $validator) {
|
|
|
|
if (isset($done[$propname])) continue;
|
2006-08-27 02:08:50 +00:00
|
|
|
$r = $validator->validate($bit, $config, $context);
|
2006-08-27 00:49:34 +00:00
|
|
|
if ($r !== false) {
|
|
|
|
$ret .= $r . ' ';
|
|
|
|
$done[$propname] = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return rtrim($ret);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|