fix(feed): correct RSS permalink metadata

This commit is contained in:
Lain Soykaf 2026-07-24 20:43:40 +04:00
commit c518319349
No known key found for this signature in database
3 changed files with 37 additions and 4 deletions

View file

@ -1,7 +1,7 @@
<item>
<activity:object-type>http://activitystrea.ms/schema/1.0/note</activity:object-type>
<activity:verb>http://activitystrea.ms/schema/1.0/post</activity:verb>
<guid isPermaLink="true"><%= @data["id"] %></guid>
<guid isPermaLink="true"><%= escape(@data["id"] || "") %></guid>
<title><%= activity_title(@data, Keyword.get(@feed_config, :post_title, %{})) %></title>
<description><%= activity_description(@data) %></description>
<content:encoded><![CDATA[<%= rss_content_encoded(@data) %>]]></content:encoded>
@ -10,7 +10,7 @@
<%= activity_context(@activity) %>
</ostatus:conversation>
<link><%= activity_link(@activity, @data) %></link>
<link><%= escape(activity_link(@activity, @data) || "") %></link>
<%= for tag <- Pleroma.Object.hashtags(@object) do %>
<%= if tag && tag != "" do %>

View file

@ -1,6 +1,6 @@
<item>
<guid isPermalink="true"><%= activity_link(@activity, @data) %></guid>
<link><%= activity_link(@activity, @data) %></link>
<guid isPermaLink="true"><%= escape(activity_link(@activity, @data) || "") %></guid>
<link><%= escape(activity_link(@activity, @data) || "") %></link>
<pubDate><%= to_rfc2822(@data["published"]) %></pubDate>
<title><%= activity_title(@data, Keyword.get(@feed_config, :post_title, %{})) %></title>
<description><%= activity_description(@data) %></description>

View file

@ -167,6 +167,8 @@ defmodule Pleroma.Web.Feed.TagControllerTest do
~c"yeah #PleromaArt"
]
assert xpath(xml, ~x"//channel/item/guid/@isPermaLink"sl) == ["true", "true"]
assert xpath(xml, ~x"//channel/item/pubDate/text()"sl) == [
FeedView.to_rfc2822(activity2.data["published"]),
FeedView.to_rfc2822(activity1.data["published"])
@ -232,6 +234,37 @@ defmodule Pleroma.Web.Feed.TagControllerTest do
refute response =~ "<lastBuildDate>"
end
test "escapes and round-trips RSS item permalinks", %{conn: conn} do
user = insert(:user, local: false)
permalink = "https://remote.example/post?first=one&second=two"
note =
insert(:note,
user: user,
object_local: false,
data: %{
"content" => "remote #rsslink",
"external_url" => permalink,
"summary" => "",
"tag" => ["rsslink"]
}
)
insert(:note_activity, user: user, note: note, local: false, object_local: false)
response =
conn
|> put_req_header("accept", "application/rss+xml")
|> get(tag_feed_path(conn, :feed, "rsslink.rss"))
|> response(200)
assert response =~ "https://remote.example/post?first=one&amp;second=two"
xml = parse(response)
assert xpath(xml, ~x"//channel/item/guid/text()"s) == permalink
assert xpath(xml, ~x"//channel/item/link/text()"s) == permalink
end
describe "private instance" do
setup do: clear_config([:instance, :public], false)