purify.php 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. <?php
  2. use Stevebauman\Purify\Definitions\Html5Definition;
  3. return [
  4. /*
  5. |--------------------------------------------------------------------------
  6. | Default Config
  7. |--------------------------------------------------------------------------
  8. |
  9. | This option defines the default config that is provided to HTMLPurifier.
  10. |
  11. */
  12. 'default' => 'default',
  13. /*
  14. |--------------------------------------------------------------------------
  15. | Config sets
  16. |--------------------------------------------------------------------------
  17. |
  18. | Here you may configure various sets of configuration for differentiated use of HTMLPurifier.
  19. | A specific set of configuration can be applied by calling the "config($name)" method on
  20. | a Purify instance. Feel free to add/remove/customize these attributes as you wish.
  21. |
  22. | Documentation: http://htmlpurifier.org/live/configdoc/plain.html
  23. |
  24. | Core.Encoding The encoding to convert input to.
  25. | HTML.Doctype Doctype to use during filtering.
  26. | HTML.Allowed The allowed HTML Elements with their allowed attributes.
  27. | HTML.ForbiddenElements The forbidden HTML elements. Elements that are listed in this
  28. | string will be removed, however their content will remain.
  29. | CSS.AllowedProperties The Allowed CSS properties.
  30. | AutoFormat.AutoParagraph Newlines are converted in to paragraphs whenever possible.
  31. | AutoFormat.RemoveEmpty Remove empty elements that contribute no semantic information to the document.
  32. |
  33. */
  34. 'configs' => [
  35. 'default' => [
  36. 'Core.Encoding' => 'utf-8',
  37. 'HTML.Doctype' => 'HTML 4.01 Transitional',
  38. 'HTML.Allowed' => env('RESTRICT_HTML_TYPES', true) ?
  39. 'a[href|title|rel|class],p[class],span[class],br' :
  40. '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',
  41. 'HTML.ForbiddenElements' => '',
  42. 'CSS.AllowedProperties' => '',
  43. 'AutoFormat.AutoParagraph' => false,
  44. 'AutoFormat.RemoveEmpty' => false,
  45. 'Attr.AllowedClasses' => [
  46. 'h-feed',
  47. 'h-entry',
  48. 'h-cite',
  49. 'h-card',
  50. 'p-author',
  51. 'p-name',
  52. 'p-in-reply-to',
  53. 'p-repost-of',
  54. 'p-comment',
  55. 'u-photo',
  56. 'u-uid',
  57. 'u-url',
  58. 'dt-published',
  59. 'e-content',
  60. 'mention',
  61. 'hashtag',
  62. 'ellipsis',
  63. 'invisible'
  64. ],
  65. 'Attr.AllowedRel' => [
  66. 'noreferrer',
  67. 'noopener',
  68. 'nofollow'
  69. ],
  70. 'HTML.TargetBlank' => true,
  71. 'HTML.Nofollow' => true,
  72. 'URI.DefaultScheme' => 'https',
  73. 'URI.DisableExternalResources' => true,
  74. 'URI.DisableResources' => true,
  75. 'URI.AllowedSchemes' => [
  76. 'http' => true,
  77. 'https' => true,
  78. ],
  79. 'URI.HostBlacklist' => config('costar.enabled') ? config('costar.domain.block') : [],
  80. ],
  81. ],
  82. /*
  83. |--------------------------------------------------------------------------
  84. | HTMLPurifier definitions
  85. |--------------------------------------------------------------------------
  86. |
  87. | Here you may specify a class that augments the HTML definitions used by
  88. | HTMLPurifier. Additional HTML5 definitions are provided out of the box.
  89. | When specifying a custom class, make sure it implements the interface:
  90. |
  91. | \Stevebauman\Purify\Definitions\Definition
  92. |
  93. | Note that these definitions are applied to every Purifier instance.
  94. |
  95. | Documentation: http://htmlpurifier.org/docs/enduser-customize.html
  96. |
  97. */
  98. 'definitions' => Html5Definition::class,
  99. /*
  100. |--------------------------------------------------------------------------
  101. | Serializer
  102. |--------------------------------------------------------------------------
  103. |
  104. | The storage implementation where HTMLPurifier can store its serializer files.
  105. | If the filesystem cache is in use, the path must be writable through the
  106. | storage disk by the web server, otherwise an exception will be thrown.
  107. |
  108. */
  109. 'serializer' => [
  110. 'driver' => env('CACHE_DRIVER', 'file'),
  111. 'cache' => \Stevebauman\Purify\Cache\CacheDefinitionCache::class,
  112. ],
  113. // 'serializer' => [
  114. // 'disk' => env('FILESYSTEM_DISK', 'local'),
  115. // 'path' => 'purify',
  116. // 'cache' => \Stevebauman\Purify\Cache\FilesystemDefinitionCache::class,
  117. // ],
  118. ];