From 65137044c1d68eade974e5b5ac5caea4352e6a44 Mon Sep 17 00:00:00 2001 From: Mark Felder Date: Fri, 11 Jun 2021 13:59:32 -0500 Subject: [PATCH] strip_html/1 is only called for titles of RSS feeds now, so move it --- lib/pleroma/web/feed/feed_view.ex | 5 ++++- lib/pleroma/web/metadata/utils.ex | 13 +------------ 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/lib/pleroma/web/feed/feed_view.ex b/lib/pleroma/web/feed/feed_view.ex index c0fb35e01..44d0dac2a 100644 --- a/lib/pleroma/web/feed/feed_view.ex +++ b/lib/pleroma/web/feed/feed_view.ex @@ -7,6 +7,7 @@ defmodule Pleroma.Web.Feed.FeedView do use Pleroma.Web, :view alias Pleroma.Formatter + alias Pleroma.HTML alias Pleroma.Object alias Pleroma.User alias Pleroma.Web.MediaProxy @@ -70,7 +71,9 @@ defmodule Pleroma.Web.Feed.FeedView do def activity_title(%{"content" => content}, opts \\ %{}) do content - |> Pleroma.Web.Metadata.Utils.scrub_html() + |> HtmlEntities.decode() + |> String.replace(~r//, " ") + |> HTML.strip_tags() |> Pleroma.Emoji.Formatter.demojify() |> Formatter.truncate(opts[:max_length], opts[:omission]) |> escape() diff --git a/lib/pleroma/web/metadata/utils.ex b/lib/pleroma/web/metadata/utils.ex index caca42934..3c0dfb6ad 100644 --- a/lib/pleroma/web/metadata/utils.ex +++ b/lib/pleroma/web/metadata/utils.ex @@ -6,7 +6,6 @@ defmodule Pleroma.Web.Metadata.Utils do alias Pleroma.Activity alias Pleroma.Emoji alias Pleroma.Formatter - alias Pleroma.HTML def scrub_html_and_truncate(%{data: %{"content" => content}} = object) do content @@ -21,22 +20,12 @@ defmodule Pleroma.Web.Metadata.Utils do def scrub_html_and_truncate(content, max_length \\ 200) when is_binary(content) do content - |> scrub_html |> Emoji.Formatter.demojify() |> HtmlEntities.decode() + |> String.replace(~r//, " ") |> Formatter.truncate(max_length) end - def scrub_html(content) when is_binary(content) do - content - # html content comes from DB already encoded, decode first and scrub after - |> HtmlEntities.decode() - |> String.replace(~r//, " ") - |> HTML.strip_tags() - end - - def scrub_html(content), do: content - def user_name_string(user) do "#{user.name} " <> if user.local do