HTMLPurifier 4.4.0
/home/ezyang/Dev/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/Ident.php
Go to the documentation of this file.
00001 <?php
00002 
00006 class HTMLPurifier_AttrDef_CSS_Ident extends HTMLPurifier_AttrDef
00007 {
00008 
00009     public function validate($string, $config, $context) {
00010 
00011         $string = trim($string);
00012 
00013         // early abort: '' and '0' (strings that convert to false) are invalid
00014         if (!$string) return false;
00015 
00016         $pattern = '/^(-?[A-Za-z_][A-Za-z_\-0-9]*)$/';
00017         if (!preg_match($pattern, $string)) return false;
00018         return $string;
00019 
00020     }
00021 
00022 }
00023 
00024 // vim: et sw=4 sts=4