Iframe.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. /**
  3. * XHTML 1.1 Iframe Module provides inline frames.
  4. *
  5. * @note This module is not considered safe unless an Iframe
  6. * whitelisting mechanism is specified. Currently, the only
  7. * such mechanism is %URL.SafeIframeRegexp
  8. */
  9. class HTMLPurifier_HTMLModule_Iframe extends HTMLPurifier_HTMLModule
  10. {
  11. /**
  12. * @type string
  13. */
  14. public $name = 'Iframe';
  15. /**
  16. * @type bool
  17. */
  18. public $safe = false;
  19. /**
  20. * @param HTMLPurifier_Config $config
  21. */
  22. public function setup($config)
  23. {
  24. if ($config->get('HTML.SafeIframe')) {
  25. $this->safe = true;
  26. }
  27. $attrs = array(
  28. 'src' => 'URI#embedded',
  29. 'width' => 'Length',
  30. 'height' => 'Length',
  31. 'name' => 'ID',
  32. 'scrolling' => 'Enum#yes,no,auto',
  33. 'frameborder' => 'Enum#0,1',
  34. 'longdesc' => 'URI',
  35. 'marginheight' => 'Pixels',
  36. 'marginwidth' => 'Pixels',
  37. );
  38. if ($config->get('HTML.Trusted')) {
  39. $attrs['allowfullscreen'] = 'Bool#allowfullscreen';
  40. }
  41. $this->addElement(
  42. 'iframe',
  43. 'Inline',
  44. 'Flow',
  45. 'Common',
  46. $attrs
  47. );
  48. }
  49. }
  50. // vim: et sw=4 sts=4