File indexing completed on 2024-12-22 05:36:18
0001 <?php 0002 0003 class HTMLPurifier_AttrDef_CSS_AlphaValue extends HTMLPurifier_AttrDef_CSS_Number 0004 { 0005 0006 public function __construct() 0007 { 0008 parent::__construct(false); // opacity is non-negative, but we will clamp it 0009 } 0010 0011 /** 0012 * @param string $number 0013 * @param HTMLPurifier_Config $config 0014 * @param HTMLPurifier_Context $context 0015 * @return string 0016 */ 0017 public function validate($number, $config, $context) 0018 { 0019 $result = parent::validate($number, $config, $context); 0020 if ($result === false) { 0021 return $result; 0022 } 0023 $float = (float)$result; 0024 if ($float < 0.0) { 0025 $result = '0'; 0026 } 0027 if ($float > 1.0) { 0028 $result = '1'; 0029 } 0030 return $result; 0031 } 0032 } 0033 0034 // vim: et sw=4 sts=4