PageRenderTime 65ms CodeModel.GetById 20ms RepoModel.GetById 1ms app.codeStats 0ms

/plugins/vjCommentPlugin/lib/tools/htmlpurifier/library/HTMLPurifier/HTMLModule/SafeObject.php

https://bitbucket.org/Kudlaty/360kdw
PHP | 53 lines | 33 code | 9 blank | 11 comment | 0 complexity | dcd3afaa3b67376b9ed66a21ee3e97dc MD5 | raw file
Possible License(s): LGPL-2.1
  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