diff options
author | William Pitcock <nenolod@dereferenced.org> | 2018-09-09 23:29:00 +0000 |
---|---|---|
committer | William Pitcock <nenolod@dereferenced.org> | 2018-09-10 00:13:57 +0000 |
commit | 255f46d7ab124d86a71e994deffca5f4f438b49b (patch) | |
tree | 590fa385f04993be72df0185403fa96163b6b71a | |
parent | 3f64ba5fc8f29efeadf7a072cf8339c778b3fd2d (diff) | |
download | pleroma-255f46d7ab124d86a71e994deffca5f4f438b49b.tar.gz |
html: new module providing a configurable markup scrubbing policy
-rw-r--r-- | config/config.exs | 3 | ||||
-rw-r--r-- | lib/pleroma/html.ex | 14 |
2 files changed, 17 insertions, 0 deletions
diff --git a/config/config.exs b/config/config.exs index ed718c3d3..559a12a91 100644 --- a/config/config.exs +++ b/config/config.exs @@ -76,6 +76,9 @@ config :pleroma, :instance, quarantined_instances: [], managed_config: true +config :pleroma, :markup, + scrub_policy: HtmlSanitizeEx.Scrubber.BasicHTML + config :pleroma, :fe, theme: "pleroma-dark", logo: "/static/logo.png", diff --git a/lib/pleroma/html.ex b/lib/pleroma/html.ex new file mode 100644 index 000000000..0ec73a91d --- /dev/null +++ b/lib/pleroma/html.ex @@ -0,0 +1,14 @@ +defmodule Pleroma.HTML do + alias HtmlSanitizeEx.Scrubber + + @markup Application.get_env(:pleroma, :markup) + + def filter_tags(html) do + scrubber = Keyword.get(@markup, :scrub_policy) + html |> Scrubber.scrub(scrubber) + end + + def strip_tags(html) do + html |> Scrubber.scrub(Scrubber.StripTags) + end +end |