File indexing completed on 2024-06-16 05:29:43

0001 <?php
0002 
0003 /**
0004  * Validates the value for the CSS property text-decoration
0005  * @note This class could be generalized into a version that acts sort of
0006  *       like Enum except you can compound the allowed values.
0007  */
0008 class HTMLPurifier_AttrDef_CSS_TextDecoration extends HTMLPurifier_AttrDef
0009 {
0010 
0011     /**
0012      * @param string $string
0013      * @param HTMLPurifier_Config $config
0014      * @param HTMLPurifier_Context $context
0015      * @return bool|string
0016      */
0017     public function validate($string, $config, $context)
0018     {
0019         static $allowed_values = array(
0020             'line-through' => true,
0021             'overline' => true,
0022             'underline' => true,
0023         );
0024 
0025         $string = strtolower($this->parseCDATA($string));
0026 
0027         if ($string === 'none') {
0028             return $string;
0029         }
0030 
0031         $parts = explode(' ', $string);
0032         $final = '';
0033         foreach ($parts as $part) {
0034             if (isset($allowed_values[$part])) {
0035                 $final .= $part . ' ';
0036             }
0037         }
0038         $final = rtrim($final);
0039         if ($final === '') {
0040             return false;
0041         }
0042         return $final;
0043     }
0044 }
0045 
0046 // vim: et sw=4 sts=4