HTMLPurifier 4.4.0
|
00001 <?php 00002 00007 class HTMLPurifier_AttrTransform_Input extends HTMLPurifier_AttrTransform { 00008 00009 protected $pixels; 00010 00011 public function __construct() { 00012 $this->pixels = new HTMLPurifier_AttrDef_HTML_Pixels(); 00013 } 00014 00015 public function transform($attr, $config, $context) { 00016 if (!isset($attr['type'])) $t = 'text'; 00017 else $t = strtolower($attr['type']); 00018 if (isset($attr['checked']) && $t !== 'radio' && $t !== 'checkbox') { 00019 unset($attr['checked']); 00020 } 00021 if (isset($attr['maxlength']) && $t !== 'text' && $t !== 'password') { 00022 unset($attr['maxlength']); 00023 } 00024 if (isset($attr['size']) && $t !== 'text' && $t !== 'password') { 00025 $result = $this->pixels->validate($attr['size'], $config, $context); 00026 if ($result === false) unset($attr['size']); 00027 else $attr['size'] = $result; 00028 } 00029 if (isset($attr['src']) && $t !== 'image') { 00030 unset($attr['src']); 00031 } 00032 if (!isset($attr['value']) && ($t === 'radio' || $t === 'checkbox')) { 00033 $attr['value'] = ''; 00034 } 00035 return $attr; 00036 } 00037 00038 } 00039 00040 // vim: et sw=4 sts=4