purifier.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. /**
  3. * Ok, glad you are here
  4. * first we get a config instance, and set the settings
  5. * $config = HTMLPurifier_Config::createDefault();
  6. * $config->set('Core.Encoding', $this->config->get('purifier.encoding'));
  7. * $config->set('Cache.SerializerPath', $this->config->get('purifier.cachePath'));
  8. * if ( ! $this->config->get('purifier.finalize')) {
  9. * $config->autoFinalize = false;
  10. * }
  11. * $config->loadArray($this->getConfig());
  12. *
  13. * You must NOT delete the default settings
  14. * anything in settings should be compacted with params that needed to instance HTMLPurifier_Config.
  15. *
  16. * @link http://htmlpurifier.org/live/configdoc/plain.html
  17. */
  18. return [
  19. 'encoding' => 'UTF-8',
  20. 'finalize' => true,
  21. 'cachePath' => storage_path('app/purifier'),
  22. 'settings' => [
  23. 'default' => [
  24. 'HTML.Doctype' => 'HTML 4.01 Transitional',
  25. 'HTML.Allowed' => 'iframe[src|height|width|class],div,b,font[color|style],strong,i,em,pre,a[href|title|target],ul,ol,li,p[style],br,span[style],img[width|height|alt|src|style|class],table[class|width],td,tr,blockquote,h1,h2,h3,h4,h4,h5',
  26. 'CSS.AllowedProperties' => 'font,font-size,width,height,font-weight,font-style,font-family,text-decoration,padding-left,color,background-color,text-align',
  27. 'Attr.AllowedFrameTargets' =>'_blank',
  28. 'AutoFormat.AutoParagraph' => true,
  29. 'AutoFormat.RemoveEmpty' => true,
  30. "HTML.SafeIframe" => 'true',
  31. "URI.SafeIframeRegexp" => "%^(http://|https://|//)(www.youtube.com/embed/|player.youku.com/embed/)%",
  32. ],
  33. 'custom_definition'=>[
  34. 'id'=>'html5-definitions',
  35. 'rev'=>'1',
  36. 'elements'=>[['video', 'Block', 'Optional: (source, Flow) | (Flow, source) | Flow', 'Common',[
  37. 'src' => 'URI',
  38. 'type' => 'Text',
  39. 'width' => 'Length',
  40. 'height' => 'Length',
  41. 'poster' => 'URI',
  42. 'preload' => 'Enum#auto,metadata,none',
  43. 'controls' => 'Bool',
  44. ]]],
  45. ],
  46. 'test' => [
  47. 'Attr.EnableID' => true
  48. ],
  49. "youtube" => [
  50. "HTML.SafeIframe" => 'true',
  51. "URI.SafeIframeRegexp" => "%^(http://|https://|//)(www.youtube.com/embed/|player.vimeo.com/video/)%",
  52. ],
  53. ],
  54. ];