7f434fb2572c5b4739ad820039380111b3e9b685
[anni] / priv / scrubbers / links_only.ex
1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
4
5 defmodule Pleroma.HTML.Scrubber.LinksOnly do
6   @moduledoc """
7   An HTML scrubbing policy which limits to links only.
8   """
9
10   @valid_schemes Pleroma.Config.get([:uri_schemes, :valid_schemes], [])
11
12   require FastSanitize.Sanitizer.Meta
13   alias FastSanitize.Sanitizer.Meta
14
15   Meta.strip_comments()
16
17   # links
18   Meta.allow_tag_with_uri_attributes(:a, ["href"], @valid_schemes)
19
20   Meta.allow_tag_with_this_attribute_values(:a, "rel", [
21     "tag",
22     "nofollow",
23     "noopener",
24     "noreferrer",
25     "me",
26     "ugc"
27   ])
28
29   Meta.allow_tag_with_these_attributes(:a, ["name", "title"])
30   Meta.strip_everything_not_covered()
31 end