1 <?php 2 3 /** 4 * Performs miscellaneous cross attribute validation and filtering for 5 * input elements. This is meant to be a post-transform. 6 */ 7 class HTMLPurifier_AttrTransform_Input extends HTMLPurifier_AttrTransform 8 { 9 /** 10 * @type HTMLPurifier_AttrDef_HTML_Pixels 11 */ 12 protected $pixels; 13 14 public function __construct() 15 { 16 $this->pixels = new HTMLPurifier_AttrDef_HTML_Pixels(); 17 } 18 19 /** 20 * @param array $attr 21 * @param HTMLPurifier_Config $config 22 * @param HTMLPurifier_Context $context 23 * @return array 24 */ 25 public function transform($attr, $config, $context) 26 { 27 if (!isset($attr['type'])) { 28 $t = 'text'; 29 } else { 30 $t = strtolower($attr['type']); 31 } 32 if (isset($attr['checked']) && $t !== 'radio' && $t !== 'checkbox') { 33 unset($attr['checked']); 34 } 35 if (isset($attr['maxlength']) && $t !== 'text' && $t !== 'password') { 36 unset($attr['maxlength']); 37 } 38 if (isset($attr['size']) && $t !== 'text' && $t !== 'password') { 39 $result = $this->pixels->validate($attr['size'], $config, $context); 40 if ($result === false) { 41 unset($attr['size']); 42 } else { 43 $attr['size'] = $result; 44 } 45 } 46 if (isset($attr['src']) && $t !== 'image') { 47 unset($attr['src']); 48 } 49 if (!isset($attr['value']) && ($t === 'radio' || $t === 'checkbox')) { 50 $attr['value'] = ''; 51 } 52 return $attr; 53 } 54 } 55 56 // vim: et sw=4 sts=4
title
Description
Body
title
Description
Body
title
Description
Body
title
Body