SafeObject.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. /**
  3. * A "safe" object module. In theory, objects permitted by this module will
  4. * be safe, and untrusted users can be allowed to embed arbitrary flash objects
  5. * (maybe other types too, but only Flash is supported as of right now).
  6. * Highly experimental.
  7. */
  8. class HTMLPurifier_HTMLModule_SafeObject extends HTMLPurifier_HTMLModule
  9. {
  10. public $name = 'SafeObject';
  11. public function setup($config) {
  12. // These definitions are not intrinsically safe: the attribute transforms
  13. // are a vital part of ensuring safety.
  14. $max = $config->get('HTML.MaxImgLength');
  15. $object = $this->addElement(
  16. 'object',
  17. 'Inline',
  18. 'Optional: param | Flow | #PCDATA',
  19. 'Common',
  20. array(
  21. // While technically not required by the spec, we're forcing
  22. // it to this value.
  23. 'type' => 'Enum#application/x-shockwave-flash',
  24. 'width' => 'Pixels#' . $max,
  25. 'height' => 'Pixels#' . $max,
  26. 'data' => 'URI#embedded',
  27. 'classid' => 'Enum#clsid:d27cdb6e-ae6d-11cf-96b8-444553540000',
  28. 'codebase' => new HTMLPurifier_AttrDef_Enum(array(
  29. 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0')),
  30. )
  31. );
  32. $object->attr_transform_post[] = new HTMLPurifier_AttrTransform_SafeObject();
  33. $param = $this->addElement('param', false, 'Empty', false,
  34. array(
  35. 'id' => 'ID',
  36. 'name*' => 'Text',
  37. 'value' => 'Text'
  38. )
  39. );
  40. $param->attr_transform_post[] = new HTMLPurifier_AttrTransform_SafeParam();
  41. $this->info_injector[] = 'SafeObject';
  42. }
  43. }
  44. // vim: et sw=4 sts=4