No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

Input.php 1.6KB

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