diff options
author | Mark Felder <feld@feld.me> | 2021-06-11 13:59:32 -0500 |
---|---|---|
committer | Mark Felder <feld@feld.me> | 2021-06-11 13:59:32 -0500 |
commit | 65137044c1d68eade974e5b5ac5caea4352e6a44 (patch) | |
tree | 584aa3c2bc7f22d4fc4eeffaf19e6c22ff819c99 /lib | |
parent | 2ad52086b826608ea93e2712d5e52ed555452582 (diff) | |
download | pleroma-65137044c1d68eade974e5b5ac5caea4352e6a44.tar.gz |
strip_html/1 is only called for titles of RSS feeds now, so move it
Diffstat (limited to 'lib')
-rw-r--r-- | lib/pleroma/web/feed/feed_view.ex | 5 | ||||
-rw-r--r-- | 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/<br\s?\/?>/, " ") + |> 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() - |> 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/<br\s?\/?>/, " ") - |> HTML.strip_tags() + |> Formatter.truncate(max_length) end - def scrub_html(content), do: content - def user_name_string(user) do "#{user.name} " <> if user.local do |