Merge branch 'static-accept-missing' into 'develop'
[akkoma] / lib / pleroma / web / activity_pub / mrf / normalize_markup.ex
1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
4
5 defmodule Pleroma.Web.ActivityPub.MRF.NormalizeMarkup do
6 @moduledoc "Scrub configured hypertext markup"
7 alias Pleroma.HTML
8
9 @behaviour Pleroma.Web.ActivityPub.MRF
10
11 def filter(%{"type" => "Create", "object" => child_object} = object) do
12 scrub_policy = Pleroma.Config.get([:mrf_normalize_markup, :scrub_policy])
13
14 content =
15 child_object["content"]
16 |> HTML.filter_tags(scrub_policy)
17
18 object = put_in(object, ["object", "content"], content)
19
20 {:ok, object}
21 end
22
23 def filter(object), do: {:ok, object}
24
25 def describe, do: {:ok, %{}}
26 end