diff --git a/config/config.exs b/config/config.exs index 765cfa4db..604761a66 100644 --- a/config/config.exs +++ b/config/config.exs @@ -286,7 +286,7 @@ config :pleroma, :feed, max_length: 100, omission: "...", # New method to extract title - parse_source: true + parse_source: false } config :pleroma, :markup, diff --git a/config/description.exs b/config/description.exs index 505f07431..7cc8bc96e 100644 --- a/config/description.exs +++ b/config/description.exs @@ -2919,6 +2919,7 @@ config :pleroma, :config_description, [ %{ group: :pleroma, key: :feed, + label: "RSS Feeds", type: :group, description: "Configure feed rendering", children: [ diff --git a/lib/pleroma/formatter.ex b/lib/pleroma/formatter.ex index d794c4d7a..3c7d4ad5f 100644 --- a/lib/pleroma/formatter.ex +++ b/lib/pleroma/formatter.ex @@ -156,10 +156,13 @@ defmodule Pleroma.Formatter do length_with_omission = max_length - String.length(omission) - if length_with_omission <= 0 do - String.slice(text, 0, max_length) - else - String.slice(text, 0, length_with_omission) <> omission + cond do + String.length(text) <= max_length -> + text + length_with_omission > 0 -> + String.slice(text, 0, length_with_omission) <> omission + true -> + String.slice(text, 0, max_length) end end diff --git a/lib/pleroma/web/feed/feed_view.ex b/lib/pleroma/web/feed/feed_view.ex index 87422f183..5f34d0bfa 100644 --- a/lib/pleroma/web/feed/feed_view.ex +++ b/lib/pleroma/web/feed/feed_view.ex @@ -86,6 +86,7 @@ defmodule Pleroma.Web.Feed.FeedView do split_content(content, content_type, opts) |> elem(0) end + # TODO: scrub_html should replace
with " "
def activity_title(%{"content" => content}, opts) do
content
|> Pleroma.Web.Metadata.Utils.scrub_html()
diff --git a/lib/pleroma/web/metadata/utils.ex b/lib/pleroma/web/metadata/utils.ex
index 8990bef54..7c11c3e87 100644
--- a/lib/pleroma/web/metadata/utils.ex
+++ b/lib/pleroma/web/metadata/utils.ex
@@ -42,8 +42,12 @@ defmodule Pleroma.Web.Metadata.Utils do
content
# html content comes from DB already encoded, decode first and scrub after
|> HtmlEntities.decode()
- |> String.replace(~r/
/, " ")
+ |> String.replace(~r/<(br|p)[^>]*>/, "\\0 ")
+ |> String.replace(~r/<\/p\s*\/?>/, " \\0")
|> HTML.strip_tags()
+ # strip_tags will convert to U+00A0, adding /u will match these to " "
+ |> String.replace(~r/\s+/u, " ")
+ |> String.trim()
end
def scrub_html(content), do: content