4 * Validates based on {ident} CSS grammar production
6 class HTMLPurifier_AttrDef_CSS_Ident
extends HTMLPurifier_AttrDef
9 public function validate($string, $config, $context) {
11 $string = trim($string);
13 // early abort: '' and '0' (strings that convert to false) are invalid
14 if (!$string) return false;
16 $pattern = '/^(-?[A-Za-z_][A-Za-z_\-0-9]*)$/';
17 if (!preg_match($pattern, $string)) return false;