purify.php 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. <?php
  2. return [
  3. /*
  4. |--------------------------------------------------------------------------
  5. | Settings
  6. |--------------------------------------------------------------------------
  7. |
  8. | The configuration settings array is passed directly to HTMLPurifier.
  9. |
  10. | Feel free to add / remove / customize these attributes as you wish.
  11. |
  12. | Documentation: http://htmlpurifier.org/live/configdoc/plain.html
  13. |
  14. */
  15. 'settings' => [
  16. /*
  17. |--------------------------------------------------------------------------
  18. | Core.Encoding
  19. |--------------------------------------------------------------------------
  20. |
  21. | The encoding to convert input to.
  22. |
  23. | http://htmlpurifier.org/live/configdoc/plain.html#Core.Encoding
  24. |
  25. */
  26. 'Core.Encoding' => 'utf-8',
  27. /*
  28. |--------------------------------------------------------------------------
  29. | Core.SerializerPath
  30. |--------------------------------------------------------------------------
  31. |
  32. | The HTML purifier serializer cache path.
  33. |
  34. | http://htmlpurifier.org/live/configdoc/plain.html#Cache.SerializerPath
  35. |
  36. */
  37. 'Cache.SerializerPath' => storage_path('purify'),
  38. /*
  39. |--------------------------------------------------------------------------
  40. | HTML.Doctype
  41. |--------------------------------------------------------------------------
  42. |
  43. | Doctype to use during filtering.
  44. |
  45. | http://htmlpurifier.org/live/configdoc/plain.html#HTML.Doctype
  46. |
  47. */
  48. 'HTML.Doctype' => 'XHTML 1.0 Transitional',
  49. /*
  50. |--------------------------------------------------------------------------
  51. | HTML.Allowed
  52. |--------------------------------------------------------------------------
  53. |
  54. | The allowed HTML Elements with their allowed attributes.
  55. |
  56. | http://htmlpurifier.org/live/configdoc/plain.html#HTML.Allowed
  57. |
  58. */
  59. 'HTML.Allowed' => env('RESTRICT_HTML_TYPES', true) ?
  60. 'a[href|title|rel|class],p[class],span[class],br' :
  61. 'a[href|title|rel|class],p[class],span[class],strong,em,del,b,i,s,strike,h1,h2,h3,h4,h5,h6,ul,ol,li,br',
  62. /*
  63. |--------------------------------------------------------------------------
  64. | HTML.ForbiddenElements
  65. |--------------------------------------------------------------------------
  66. |
  67. | The forbidden HTML elements. Elements that are listed in
  68. | this string will be removed, however their content will remain.
  69. |
  70. | For example if 'p' is inside the string, the string: '<p>Test</p>',
  71. |
  72. | Will be cleaned to: 'Test'
  73. |
  74. | http://htmlpurifier.org/live/configdoc/plain.html#HTML.ForbiddenElements
  75. |
  76. */
  77. 'HTML.ForbiddenElements' => '',
  78. /*
  79. |--------------------------------------------------------------------------
  80. | CSS.AllowedProperties
  81. |--------------------------------------------------------------------------
  82. |
  83. | The Allowed CSS properties.
  84. |
  85. | http://htmlpurifier.org/live/configdoc/plain.html#CSS.AllowedProperties
  86. |
  87. */
  88. 'CSS.AllowedProperties' => '',
  89. /*
  90. |--------------------------------------------------------------------------
  91. | AutoFormat.AutoParagraph
  92. |--------------------------------------------------------------------------
  93. |
  94. | The Allowed CSS properties.
  95. |
  96. | This directive turns on auto-paragraphing, where double
  97. | newlines are converted in to paragraphs whenever possible.
  98. |
  99. | http://htmlpurifier.org/live/configdoc/plain.html#AutoFormat.AutoParagraph
  100. |
  101. */
  102. 'AutoFormat.AutoParagraph' => false,
  103. /*
  104. |--------------------------------------------------------------------------
  105. | AutoFormat.RemoveEmpty
  106. |--------------------------------------------------------------------------
  107. |
  108. | When enabled, HTML Purifier will attempt to remove empty
  109. | elements that contribute no semantic information to the document.
  110. |
  111. | http://htmlpurifier.org/live/configdoc/plain.html#AutoFormat.RemoveEmpty
  112. |
  113. */
  114. 'AutoFormat.RemoveEmpty' => false,
  115. 'Attr.AllowedClasses' => [
  116. 'h-feed',
  117. 'h-entry',
  118. 'h-cite',
  119. 'h-card',
  120. 'p-author',
  121. 'p-name',
  122. 'p-in-reply-to',
  123. 'p-repost-of',
  124. 'p-comment',
  125. 'u-photo',
  126. 'u-uid',
  127. 'u-url',
  128. 'dt-published',
  129. 'e-content',
  130. 'mention',
  131. 'hashtag',
  132. 'ellipsis',
  133. 'invisible'
  134. ],
  135. 'Attr.AllowedRel' => [
  136. 'noreferrer',
  137. 'noopener',
  138. 'nofollow'
  139. ],
  140. 'HTML.TargetBlank' => true,
  141. 'HTML.Nofollow' => true,
  142. 'URI.DefaultScheme' => 'https',
  143. 'URI.DisableExternalResources' => true,
  144. 'URI.DisableResources' => true,
  145. 'URI.AllowedSchemes' => [
  146. 'http' => true,
  147. 'https' => true,
  148. ],
  149. 'URI.HostBlacklist' => config('costar.enabled') ? config('costar.domain.block') : [],
  150. ],
  151. ];