summaryrefslogtreecommitdiff
path: root/priv/scrubbers/search_indexing.ex
blob: 02756ab797acf0c120c0d902eb3756717a849918 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# Pleroma: A lightweight social networking server
# Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only

defmodule Pleroma.HTML.Scrubber.SearchIndexing do
  @moduledoc """
  An HTML scrubbing policy that scrubs things for searching.
  """

  require FastSanitize.Sanitizer.Meta
  alias FastSanitize.Sanitizer.Meta

  # Explicitly remove mentions
  def scrub({:a, attrs, children}) do
    if(Enum.any?(attrs, fn {att, val} -> att == "class" and String.contains?(val, "mention") end),
      do: nil,
      # Strip the tag itself, leave only children (text, presumably)
      else: children
    )
  end

  Meta.strip_comments()
  Meta.strip_everything_not_covered()
end