purifier.php 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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. 'cacheFileMode' => 0755,
  23. 'settings' => [
  24. 'default' => [
  25. 'HTML.Doctype' => 'HTML 4.01 Transitional',
  26. 'HTML.Allowed' => 'div,b,strong,i,em,u,a[href|title],ul,ol,li,p[style],br,span[style],img[width|height|alt|src]',
  27. 'CSS.AllowedProperties' => 'font,font-size,font-weight,font-style,font-family,text-decoration,padding-left,color,background-color,text-align',
  28. 'AutoFormat.AutoParagraph' => true,
  29. 'AutoFormat.RemoveEmpty' => true,
  30. ],
  31. 'test' => [
  32. 'Attr.EnableID' => 'true',
  33. ],
  34. "youtube" => [
  35. "HTML.SafeIframe" => 'true',
  36. "URI.SafeIframeRegexp" => "%^(http://|https://|//)(www.youtube.com/embed/|player.vimeo.com/video/)%",
  37. ],
  38. 'custom_definition' => [
  39. 'id' => 'html5-definitions',
  40. 'rev' => 1,
  41. 'debug' => false,
  42. 'elements' => [
  43. // http://developers.whatwg.org/sections.html
  44. ['section', 'Block', 'Flow', 'Common'],
  45. ['nav', 'Block', 'Flow', 'Common'],
  46. ['article', 'Block', 'Flow', 'Common'],
  47. ['aside', 'Block', 'Flow', 'Common'],
  48. ['header', 'Block', 'Flow', 'Common'],
  49. ['footer', 'Block', 'Flow', 'Common'],
  50. // Content model actually excludes several tags, not modelled here
  51. ['address', 'Block', 'Flow', 'Common'],
  52. ['hgroup', 'Block', 'Required: h1 | h2 | h3 | h4 | h5 | h6', 'Common'],
  53. // http://developers.whatwg.org/grouping-content.html
  54. ['figure', 'Block', 'Optional: (figcaption, Flow) | (Flow, figcaption) | Flow', 'Common'],
  55. ['figcaption', 'Inline', 'Flow', 'Common'],
  56. // http://developers.whatwg.org/the-video-element.html#the-video-element
  57. ['video', 'Block', 'Optional: (source, Flow) | (Flow, source) | Flow', 'Common', [
  58. 'src' => 'URI',
  59. 'type' => 'Text',
  60. 'width' => 'Length',
  61. 'height' => 'Length',
  62. 'poster' => 'URI',
  63. 'preload' => 'Enum#auto,metadata,none',
  64. 'controls' => 'Bool',
  65. ]],
  66. ['source', 'Block', 'Flow', 'Common', [
  67. 'src' => 'URI',
  68. 'type' => 'Text',
  69. ]],
  70. // http://developers.whatwg.org/text-level-semantics.html
  71. ['s', 'Inline', 'Inline', 'Common'],
  72. ['var', 'Inline', 'Inline', 'Common'],
  73. ['sub', 'Inline', 'Inline', 'Common'],
  74. ['sup', 'Inline', 'Inline', 'Common'],
  75. ['mark', 'Inline', 'Inline', 'Common'],
  76. ['wbr', 'Inline', 'Empty', 'Core'],
  77. // http://developers.whatwg.org/edits.html
  78. ['ins', 'Block', 'Flow', 'Common', ['cite' => 'URI', 'datetime' => 'CDATA']],
  79. ['del', 'Block', 'Flow', 'Common', ['cite' => 'URI', 'datetime' => 'CDATA']],
  80. ],
  81. 'attributes' => [
  82. ['iframe', 'allowfullscreen', 'Bool'],
  83. ['table', 'height', 'Text'],
  84. ['td', 'border', 'Text'],
  85. ['th', 'border', 'Text'],
  86. ['tr', 'width', 'Text'],
  87. ['tr', 'height', 'Text'],
  88. ['tr', 'border', 'Text'],
  89. ],
  90. ],
  91. 'custom_attributes' => [
  92. ['a', 'target', 'Enum#_blank,_self,_target,_top'],
  93. ],
  94. 'custom_elements' => [
  95. ['u', 'Inline', 'Inline', 'Common'],
  96. ],
  97. ],
  98. ];