3 require_once 'HTMLPurifier/AttrDef.php';
6 * Validates shorthand CSS property list-style.
7 * @note This currently does not support list-style-image, as that functionality
8 * is not implemented yet elsewhere.
10 class HTMLPurifier_AttrDef_ListStyle
extends HTMLPurifier_AttrDef
14 * Local copy of component validators.
15 * @note See HTMLPurifier_AttrDef_Font::$info for a similar impl.
19 function HTMLPurifier_AttrDef_ListStyle($config) {
20 $def = $config->getCSSDefinition();
21 $this->info
['list-style-type'] = $def->info
['list-style-type'];
22 $this->info
['list-style-position'] = $def->info
['list-style-position'];
25 function validate($string, $config, &$context) {
27 // regular pre-processing
28 $string = $this->parseCDATA($string);
29 if ($string === '') return false;
31 $bits = explode(' ', strtolower($string)); // bits to process
34 $caught_position = false;
35 $caught_none = false; // as in keyword none, which is in all of them
39 foreach ($bits as $bit) {
40 if ($caught_none && ($caught_type ||
$caught_position)) break;
41 if ($caught_type && $caught_position) break;
43 if ($bit === '') continue;
45 if ($bit === 'none') {
46 if ($caught_none) continue;
52 // if we add anymore, roll it into a loop
54 $r = $this->info
['list-style-type']->validate($bit, $config, $context);
56 if ($caught_type) continue;
62 $r = $this->info
['list-style-position']->validate($bit, $config, $context);
64 if ($caught_position) continue;
65 $caught_position = true;
72 return $ret ?
$ret : false;