2022-02-26 06:11:42 +00:00
|
|
|
# Pleroma: A lightweight social networking server
|
2023-01-01 11:11:47 +00:00
|
|
|
# Copyright © 2017-2023 Pleroma Authors <https://pleroma.social/>
|
2022-02-26 06:11:42 +00:00
|
|
|
# SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
2019-12-08 16:42:40 +00:00
|
|
|
defmodule Pleroma.HTML.Scrubber.LinksOnly do
|
|
|
|
@moduledoc """
|
|
|
|
An HTML scrubbing policy which limits to links only.
|
|
|
|
"""
|
|
|
|
|
|
|
|
@valid_schemes Pleroma.Config.get([:uri_schemes, :valid_schemes], [])
|
|
|
|
|
|
|
|
require FastSanitize.Sanitizer.Meta
|
|
|
|
alias FastSanitize.Sanitizer.Meta
|
|
|
|
|
|
|
|
Meta.strip_comments()
|
|
|
|
|
|
|
|
# links
|
|
|
|
Meta.allow_tag_with_uri_attributes(:a, ["href"], @valid_schemes)
|
|
|
|
|
|
|
|
Meta.allow_tag_with_this_attribute_values(:a, "rel", [
|
|
|
|
"tag",
|
|
|
|
"nofollow",
|
|
|
|
"noopener",
|
|
|
|
"noreferrer",
|
|
|
|
"me",
|
|
|
|
"ugc"
|
|
|
|
])
|
|
|
|
|
|
|
|
Meta.allow_tag_with_these_attributes(:a, ["name", "title"])
|
|
|
|
Meta.strip_everything_not_covered()
|
|
|
|
end
|