fix(feed): escape self link URLs

This commit is contained in:
Lain Soykaf 2026-07-24 20:11:19 +04:00
commit d0c8ca92a5
No known key found for this signature in database
2 changed files with 17 additions and 1 deletions

View file

@ -167,7 +167,11 @@ defmodule Pleroma.Web.Feed.FeedView do
def activity_context(activity), do: escape(activity.data["context"]) def activity_context(activity), do: escape(activity.data["context"])
def feed_self_url(conn), do: Phoenix.Controller.current_url(conn) def feed_self_url(conn) do
conn
|> Phoenix.Controller.current_url()
|> escape()
end
def activity_link(activity, data) do def activity_link(activity, data) do
cond do cond do

View file

@ -138,6 +138,18 @@ defmodule Pleroma.Web.Feed.UserControllerTest do
assert activity_titles == [~c"2hu & as"] assert activity_titles == [~c"2hu & as"]
end end
test "escapes query parameters in feed self links", %{conn: conn, user: user} do
for format <- ~w[atom rss] do
response =
conn
|> get("/users/#{user.nickname}/feed.#{format}?first=one&second=two")
|> response(200)
assert response =~ "first=one&amp;second=two"
refute response =~ "first=one&second=two"
end
end
test "returns 404 for a missing feed", %{conn: conn} do test "returns 404 for a missing feed", %{conn: conn} do
conn = conn =
conn conn