1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.Web.ActivityPub.MRF.NormalizeMarkup do
6 @moduledoc "Scrub configured hypertext markup"
9 @behaviour Pleroma.Web.ActivityPub.MRF.Policy
12 def history_awareness, do: :auto
15 def filter(%{"type" => type, "object" => child_object} = object)
16 when type in ["Create", "Update"] do
17 scrub_policy = Pleroma.Config.get([:mrf_normalize_markup, :scrub_policy])
20 child_object["content"]
21 |> HTML.filter_tags(scrub_policy)
23 object = put_in(object, ["object", "content"], content)
28 def filter(object), do: {:ok, object}
31 def describe, do: {:ok, %{}}
34 def config_description do
36 key: :mrf_normalize_markup,
37 related_policy: "Pleroma.Web.ActivityPub.MRF.NormalizeMarkup",
38 label: "MRF Normalize Markup",
39 description: "MRF NormalizeMarkup settings. Scrub configured hypertext markup.",
44 suggestions: [Pleroma.HTML.Scrubber.Default]