logo

pleroma

My custom branche(s) on git.pleroma.social/pleroma/pleroma git clone https://anongit.hacktivis.me/git/pleroma.git/

default.ex (4712B)


  1. # Pleroma: A lightweight social networking server
  2. # Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
  3. # SPDX-License-Identifier: AGPL-3.0-only
  4. defmodule Pleroma.HTML.Scrubber.Default do
  5. @doc "The default HTML scrubbing policy: no "
  6. require FastSanitize.Sanitizer.Meta
  7. alias FastSanitize.Sanitizer.Meta
  8. # credo:disable-for-previous-line
  9. # No idea how to fix this one…
  10. @valid_schemes Pleroma.Config.get([:uri_schemes, :valid_schemes], [])
  11. Meta.strip_comments()
  12. Meta.allow_tag_with_uri_attributes(:a, ["href", "data-user", "data-tag"], @valid_schemes)
  13. Meta.allow_tag_with_this_attribute_values(:a, "class", [
  14. "hashtag",
  15. "u-url",
  16. "mention",
  17. "u-url mention",
  18. "mention u-url",
  19. "mention hashtag"
  20. ])
  21. Meta.allow_tag_with_this_attribute_values(:a, "rel", [
  22. "tag",
  23. "nofollow",
  24. "noopener",
  25. "noreferrer",
  26. "ugc"
  27. ])
  28. Meta.allow_tag_with_these_attributes(:a, ["name", "title", "lang"])
  29. Meta.allow_tag_with_these_attributes(:abbr, ["title", "lang"])
  30. Meta.allow_tag_with_these_attributes(:acronym, ["title", "lang"])
  31. # sort(1)-ed list
  32. Meta.allow_tag_with_these_attributes(:bdi, [])
  33. Meta.allow_tag_with_these_attributes(:bdo, ["dir"])
  34. Meta.allow_tag_with_these_attributes(:big, ["lang"])
  35. Meta.allow_tag_with_these_attributes(:b, ["lang"])
  36. Meta.allow_tag_with_these_attributes(:blockquote, ["lang"])
  37. Meta.allow_tag_with_these_attributes(:br, ["lang"])
  38. Meta.allow_tag_with_these_attributes(:cite, ["lang"])
  39. Meta.allow_tag_with_these_attributes(:code, ["lang"])
  40. Meta.allow_tag_with_these_attributes(:del, ["lang"])
  41. Meta.allow_tag_with_these_attributes(:dfn, ["lang"])
  42. Meta.allow_tag_with_these_attributes(:em, ["lang"])
  43. Meta.allow_tag_with_these_attributes(:hr, ["lang"])
  44. Meta.allow_tag_with_these_attributes(:i, ["lang"])
  45. Meta.allow_tag_with_these_attributes(:ins, ["lang"])
  46. Meta.allow_tag_with_these_attributes(:kbd, ["lang"])
  47. Meta.allow_tag_with_these_attributes(:li, ["lang"])
  48. Meta.allow_tag_with_these_attributes(:ol, ["lang"])
  49. Meta.allow_tag_with_these_attributes(:p, ["lang"])
  50. Meta.allow_tag_with_these_attributes(:pre, ["lang"])
  51. Meta.allow_tag_with_these_attributes(:q, ["lang"])
  52. Meta.allow_tag_with_these_attributes(:rb, ["lang"])
  53. Meta.allow_tag_with_these_attributes(:rp, ["lang"])
  54. Meta.allow_tag_with_these_attributes(:rtc, ["lang"])
  55. Meta.allow_tag_with_these_attributes(:rt, ["lang"])
  56. Meta.allow_tag_with_these_attributes(:ruby, ["lang"])
  57. Meta.allow_tag_with_these_attributes(:samp, ["lang"])
  58. Meta.allow_tag_with_these_attributes(:s, ["lang"])
  59. Meta.allow_tag_with_these_attributes(:small, ["lang"])
  60. Meta.allow_tag_with_these_attributes(:strong, ["lang"])
  61. Meta.allow_tag_with_these_attributes(:sub, ["lang"])
  62. Meta.allow_tag_with_these_attributes(:sup, ["lang"])
  63. Meta.allow_tag_with_these_attributes(:tt, ["lang"])
  64. Meta.allow_tag_with_these_attributes(:u, ["lang"])
  65. Meta.allow_tag_with_these_attributes(:ul, ["lang"])
  66. Meta.allow_tag_with_these_attributes(:var, ["lang"])
  67. Meta.allow_tag_with_these_attributes(:wbr, ["lang"])
  68. Meta.allow_tag_with_this_attribute_values(:span, "class", [
  69. "h-card",
  70. "recipients-inline",
  71. "quote-inline"
  72. ])
  73. Meta.allow_tag_with_these_attributes(:span, ["lang"])
  74. Meta.allow_tag_with_this_attribute_values(:code, "class", ["inline"])
  75. @allow_inline_images Pleroma.Config.get([:markup, :allow_inline_images])
  76. if @allow_inline_images do
  77. Meta.allow_tag_with_this_attribute_values(:img, "class", ["emoji"])
  78. # restrict img tags to http/https only, because of MediaProxy.
  79. Meta.allow_tag_with_uri_attributes(:img, ["src"], ["http", "https"])
  80. Meta.allow_tag_with_these_attributes(:img, [
  81. "width",
  82. "height",
  83. "title",
  84. "alt",
  85. "lang"
  86. ])
  87. end
  88. if Pleroma.Config.get([:markup, :allow_tables]) do
  89. Meta.allow_tag_with_these_attributes(:table, ["lang"])
  90. Meta.allow_tag_with_these_attributes(:tbody, ["lang"])
  91. Meta.allow_tag_with_these_attributes(:td, ["lang"])
  92. Meta.allow_tag_with_these_attributes(:th, ["lang"])
  93. Meta.allow_tag_with_these_attributes(:thead, ["lang"])
  94. Meta.allow_tag_with_these_attributes(:tr, ["lang"])
  95. end
  96. if Pleroma.Config.get([:markup, :allow_headings]) do
  97. Meta.allow_tag_with_these_attributes(:h1, ["lang"])
  98. Meta.allow_tag_with_these_attributes(:h2, ["lang"])
  99. Meta.allow_tag_with_these_attributes(:h3, ["lang"])
  100. Meta.allow_tag_with_these_attributes(:h4, ["lang"])
  101. Meta.allow_tag_with_these_attributes(:h5, ["lang"])
  102. end
  103. if Pleroma.Config.get([:markup, :allow_fonts]) do
  104. Meta.allow_tag_with_these_attributes(:font, ["face", "lang"])
  105. end
  106. Meta.strip_everything_not_covered()
  107. end