logo

pleroma

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

default.ex (4689B)


  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. ])
  20. Meta.allow_tag_with_this_attribute_values(:a, "rel", [
  21. "tag",
  22. "nofollow",
  23. "noopener",
  24. "noreferrer",
  25. "ugc"
  26. ])
  27. Meta.allow_tag_with_these_attributes(:a, ["name", "title", "lang"])
  28. Meta.allow_tag_with_these_attributes(:abbr, ["title", "lang"])
  29. Meta.allow_tag_with_these_attributes(:acronym, ["title", "lang"])
  30. # sort(1)-ed list
  31. Meta.allow_tag_with_these_attributes(:bdi, [])
  32. Meta.allow_tag_with_these_attributes(:bdo, ["dir"])
  33. Meta.allow_tag_with_these_attributes(:big, ["lang"])
  34. Meta.allow_tag_with_these_attributes(:b, ["lang"])
  35. Meta.allow_tag_with_these_attributes(:blockquote, ["lang"])
  36. Meta.allow_tag_with_these_attributes(:br, ["lang"])
  37. Meta.allow_tag_with_these_attributes(:cite, ["lang"])
  38. Meta.allow_tag_with_these_attributes(:code, ["lang"])
  39. Meta.allow_tag_with_these_attributes(:del, ["lang"])
  40. Meta.allow_tag_with_these_attributes(:dfn, ["lang"])
  41. Meta.allow_tag_with_these_attributes(:em, ["lang"])
  42. Meta.allow_tag_with_these_attributes(:hr, ["lang"])
  43. Meta.allow_tag_with_these_attributes(:i, ["lang"])
  44. Meta.allow_tag_with_these_attributes(:ins, ["lang"])
  45. Meta.allow_tag_with_these_attributes(:kbd, ["lang"])
  46. Meta.allow_tag_with_these_attributes(:li, ["lang"])
  47. Meta.allow_tag_with_these_attributes(:ol, ["lang"])
  48. Meta.allow_tag_with_these_attributes(:p, ["lang"])
  49. Meta.allow_tag_with_these_attributes(:pre, ["lang"])
  50. Meta.allow_tag_with_these_attributes(:q, ["lang"])
  51. Meta.allow_tag_with_these_attributes(:rb, ["lang"])
  52. Meta.allow_tag_with_these_attributes(:rp, ["lang"])
  53. Meta.allow_tag_with_these_attributes(:rtc, ["lang"])
  54. Meta.allow_tag_with_these_attributes(:rt, ["lang"])
  55. Meta.allow_tag_with_these_attributes(:ruby, ["lang"])
  56. Meta.allow_tag_with_these_attributes(:samp, ["lang"])
  57. Meta.allow_tag_with_these_attributes(:s, ["lang"])
  58. Meta.allow_tag_with_these_attributes(:small, ["lang"])
  59. Meta.allow_tag_with_these_attributes(:strong, ["lang"])
  60. Meta.allow_tag_with_these_attributes(:sub, ["lang"])
  61. Meta.allow_tag_with_these_attributes(:sup, ["lang"])
  62. Meta.allow_tag_with_these_attributes(:tt, ["lang"])
  63. Meta.allow_tag_with_these_attributes(:u, ["lang"])
  64. Meta.allow_tag_with_these_attributes(:ul, ["lang"])
  65. Meta.allow_tag_with_these_attributes(:var, ["lang"])
  66. Meta.allow_tag_with_these_attributes(:wbr, ["lang"])
  67. Meta.allow_tag_with_this_attribute_values(:span, "class", [
  68. "h-card",
  69. "recipients-inline",
  70. "quote-inline"
  71. ])
  72. Meta.allow_tag_with_these_attributes(:span, ["lang"])
  73. Meta.allow_tag_with_this_attribute_values(:code, "class", ["inline"])
  74. @allow_inline_images Pleroma.Config.get([:markup, :allow_inline_images])
  75. if @allow_inline_images do
  76. Meta.allow_tag_with_this_attribute_values(:img, "class", ["emoji"])
  77. # restrict img tags to http/https only, because of MediaProxy.
  78. Meta.allow_tag_with_uri_attributes(:img, ["src"], ["http", "https"])
  79. Meta.allow_tag_with_these_attributes(:img, [
  80. "width",
  81. "height",
  82. "title",
  83. "alt",
  84. "lang"
  85. ])
  86. end
  87. if Pleroma.Config.get([:markup, :allow_tables]) do
  88. Meta.allow_tag_with_these_attributes(:table, ["lang"])
  89. Meta.allow_tag_with_these_attributes(:tbody, ["lang"])
  90. Meta.allow_tag_with_these_attributes(:td, ["lang"])
  91. Meta.allow_tag_with_these_attributes(:th, ["lang"])
  92. Meta.allow_tag_with_these_attributes(:thead, ["lang"])
  93. Meta.allow_tag_with_these_attributes(:tr, ["lang"])
  94. end
  95. if Pleroma.Config.get([:markup, :allow_headings]) do
  96. Meta.allow_tag_with_these_attributes(:h1, ["lang"])
  97. Meta.allow_tag_with_these_attributes(:h2, ["lang"])
  98. Meta.allow_tag_with_these_attributes(:h3, ["lang"])
  99. Meta.allow_tag_with_these_attributes(:h4, ["lang"])
  100. Meta.allow_tag_with_these_attributes(:h5, ["lang"])
  101. end
  102. if Pleroma.Config.get([:markup, :allow_fonts]) do
  103. Meta.allow_tag_with_these_attributes(:font, ["face", "lang"])
  104. end
  105. Meta.strip_everything_not_covered()
  106. end