| 1: | <?php
|
| 2: |
|
| 3: | |
| 4: | |
| 5: | |
| 6: |
|
| 7: | class HTMLPurifier_AttrTransform_Input extends HTMLPurifier_AttrTransform
|
| 8: | {
|
| 9: | |
| 10: | |
| 11: |
|
| 12: | protected $pixels;
|
| 13: |
|
| 14: | public function __construct()
|
| 15: | {
|
| 16: | $this->pixels = new HTMLPurifier_AttrDef_HTML_Pixels();
|
| 17: | }
|
| 18: |
|
| 19: | |
| 20: | |
| 21: | |
| 22: | |
| 23: | |
| 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: |
|
| 57: | |