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.HTML.Scrubber.TwitterText do
7 An HTML scrubbing policy which limits to twitter-style text. Only
8 paragraphs, breaks and links are allowed through the filter.
11 @valid_schemes Pleroma.Config.get([:uri_schemes, :valid_schemes], [])
13 require FastSanitize.Sanitizer.Meta
14 alias FastSanitize.Sanitizer.Meta
19 Meta.allow_tag_with_uri_attributes(:a, ["href", "data-user", "data-tag"], @valid_schemes)
21 Meta.allow_tag_with_this_attribute_values(:a, "class", [
29 Meta.allow_tag_with_this_attribute_values(:a, "rel", [
36 Meta.allow_tag_with_these_attributes(:a, ["name", "title"])
38 # paragraphs and linebreaks
39 Meta.allow_tag_with_these_attributes(:br, [])
40 Meta.allow_tag_with_these_attributes(:p, [])
43 Meta.allow_tag_with_this_attribute_values(:span, "class", ["h-card"])
44 Meta.allow_tag_with_these_attributes(:span, [])
46 # allow inline images for custom emoji
47 if Pleroma.Config.get([:markup, :allow_inline_images]) do
48 Meta.allow_tag_with_this_attribute_values(:img, "class", ["emoji"])
50 # restrict img tags to http/https only, because of MediaProxy.
51 Meta.allow_tag_with_uri_attributes(:img, ["src"], ["http", "https"])
53 Meta.allow_tag_with_these_attributes(:img, [
61 Meta.strip_everything_not_covered()