diff options
author | William Pitcock <nenolod@dereferenced.org> | 2018-09-16 02:07:01 +0000 |
---|---|---|
committer | William Pitcock <nenolod@dereferenced.org> | 2018-09-16 02:16:14 +0000 |
commit | cd13fa17fd8d2c959b4a257a3bdcf52e7f61ddf2 (patch) | |
tree | bd199b5517128820617dc16ebd199178c4bcb458 | |
parent | 28812752918c59bedc3526c0a4ac7c490d1a5b22 (diff) | |
download | pleroma-cd13fa17fd8d2c959b4a257a3bdcf52e7f61ddf2.tar.gz |
html: allow scrubbing policies to be stackable
-rw-r--r-- | lib/pleroma/html.ex | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/lib/pleroma/html.ex b/lib/pleroma/html.ex index a0c43b82c..1eb0fdc00 100644 --- a/lib/pleroma/html.ex +++ b/lib/pleroma/html.ex @@ -3,13 +3,24 @@ defmodule Pleroma.HTML do @markup Application.get_env(:pleroma, :markup) + defp get_scrubbers(scrubber) when is_atom(scrubber), do: [scrubber] + defp get_scrubbers(scrubbers) when is_list(scrubbers), do: scrubbers + defp get_scrubbers(_), do: [Pleroma.HTML.Scrubber.Default] + + def get_scrubbers() do + Keyword.get(@markup, :scrub_policy) + |> get_scrubbers + end + def filter_tags(html, scrubber) do html |> Scrubber.scrub(scrubber) end def filter_tags(html) do - scrubber = Keyword.get(@markup, :scrub_policy) - filter_tags(html, scrubber) + get_scrubbers() + |> Enum.reduce(html, fn scrubber, html -> + filter_tags(html, scrubber) + end) end def strip_tags(html) do |