+ @uri_schemes Application.get_env(:pleroma, :uri_schemes, [])
+ @valid_schemes Keyword.get(@uri_schemes, :valid_schemes, [])
+
+ require HtmlSanitizeEx.Scrubber.Meta
+ alias HtmlSanitizeEx.Scrubber.Meta
+
+ Meta.remove_cdata_sections_before_scrub()
+ Meta.strip_comments()
+
+ # links
+ Meta.allow_tag_with_uri_attributes("a", ["href", "data-user", "data-tag"], @valid_schemes)
+ Meta.allow_tag_with_these_attributes("a", ["name", "title"])
+
+ # paragraphs and linebreaks
+ Meta.allow_tag_with_these_attributes("br", [])
+ Meta.allow_tag_with_these_attributes("p", [])
+
+ # microformats
+ Meta.allow_tag_with_these_attributes("span", [])
+
+ # allow inline images for custom emoji
+ @allow_inline_images Keyword.get(@markup, :allow_inline_images)
+
+ if @allow_inline_images do
+ # restrict img tags to http/https only, because of MediaProxy.
+ Meta.allow_tag_with_uri_attributes("img", ["src"], ["http", "https"])
+
+ Meta.allow_tag_with_these_attributes("img", [
+ "width",
+ "height",
+ "title",
+ "alt"
+ ])
+ end
+
+ Meta.strip_everything_not_covered()
+end
+
+defmodule Pleroma.HTML.Scrubber.Default do
+ @doc "The default HTML scrubbing policy: no "
+
+ require HtmlSanitizeEx.Scrubber.Meta
+ alias HtmlSanitizeEx.Scrubber.Meta
+
+ @markup Application.get_env(:pleroma, :markup)
+ @uri_schemes Application.get_env(:pleroma, :uri_schemes, [])
+ @valid_schemes Keyword.get(@uri_schemes, :valid_schemes, [])
+
+ Meta.remove_cdata_sections_before_scrub()
+ Meta.strip_comments()
+
+ Meta.allow_tag_with_uri_attributes("a", ["href", "data-user", "data-tag"], @valid_schemes)
+ Meta.allow_tag_with_these_attributes("a", ["name", "title"])