From 29547ce8aba63454e84d277b0597fb2764e8cb23 Mon Sep 17 00:00:00 2001
From: kim
Date: Mon, 3 Nov 2025 21:16:42 +0100
Subject: [bugfix] more RSS validation issues (#4517)
Fixes some validation issues relating to author information often expected to be valid email addresses, which our @displayname@username is not. There's still a few more validation issues, but honestly if we're going have better support I think it might be worth dropping gorilla/feeds for our own tagged XML / JSON structs.
Also does a bunch of housekeeping in the typeutils package removing error returns where never used / only ever logged, removing unused contexts etc.
Reviewed-on: https://codeberg.org/superseriousbusiness/gotosocial/pulls/4517
Co-authored-by: kim
Co-committed-by: kim
---
internal/processing/account/rss_test.go | 65 +++------------------------------
1 file changed, 5 insertions(+), 60 deletions(-)
(limited to 'internal/processing/account/rss_test.go')
diff --git a/internal/processing/account/rss_test.go b/internal/processing/account/rss_test.go
index b053a3795..75aa20891 100644
--- a/internal/processing/account/rss_test.go
+++ b/internal/processing/account/rss_test.go
@@ -44,7 +44,6 @@ func (suite *GetRSSTestSuite) TestGetAccountRSSAdmin() {
http://localhost:8080/@admin/statuses/01F8MHAAY43M6RJ473VQFCVH37
@admin@localhost:8080 made a new post: "🐕🐕🐕🐕🐕"🐕🐕🐕🐕🐕
]]>
- @admin@localhost:8080http://localhost:8080/@admin/statuses/01F8MHAAY43M6RJ473VQFCVH37Wed, 20 Oct 2021 12:36:45 +0000http://localhost:8080/@admin/feed.rss
@@ -54,7 +53,6 @@ func (suite *GetRSSTestSuite) TestGetAccountRSSAdmin() {
http://localhost:8080/@admin/statuses/01F8MH75CBF9JFX4ZAD54N0W0R
@admin@localhost:8080 posted 1 attachment: "hello world! #welcome ! first post on the instance :rainbow: !"hello world! #welcome ! first post on the instance !]]>
- @admin@localhost:8080http://localhost:8080/@admin/statuses/01F8MH75CBF9JFX4ZAD54N0W0RWed, 20 Oct 2021 11:36:45 +0000
@@ -78,11 +76,7 @@ func (suite *GetRSSTestSuite) TestGetAccountAtomAdmin() {
http://localhost:8080/@admin/statuses/01F8MHAAY43M6RJ473VQFCVH37<p>🐕🐕🐕🐕🐕</p>
-
@admin@localhost:8080 made a new post: "🐕🐕🐕🐕🐕"
-
- @admin@localhost:8080
- hello world! #welcome ! first post on the instance :rainbow: !
@@ -92,9 +86,6 @@ func (suite *GetRSSTestSuite) TestGetAccountAtomAdmin() {
@admin@localhost:8080 posted 1 attachment: "hello world! #welcome ! first post on the instance :rainbow: !"
-
- @admin@localhost:8080
-
`)
}
@@ -114,15 +105,7 @@ func (suite *GetRSSTestSuite) TestGetAccountJSONAdmin() {
"title": "open to see some \u003cstrong\u003epuppies\u003c/strong\u003e",
"content_html": "\u003cp\u003e🐕🐕🐕🐕🐕\u003c/p\u003e",
"summary": "@admin@localhost:8080 made a new post: \"🐕🐕🐕🐕🐕\"",
- "date_published": "2021-10-20T12:36:45Z",
- "author": {
- "name": "@admin@localhost:8080"
- },
- "authors": [
- {
- "name": "@admin@localhost:8080"
- }
- ]
+ "date_published": "2021-10-20T12:36:45Z"
},
{
"id": "http://localhost:8080/@admin/statuses/01F8MH75CBF9JFX4ZAD54N0W0R",
@@ -132,15 +115,7 @@ func (suite *GetRSSTestSuite) TestGetAccountJSONAdmin() {
"content_html": "\u003cp\u003ehello world! \u003ca href=\"http://localhost:8080/tags/welcome\" class=\"mention hashtag\" rel=\"tag nofollow noreferrer noopener\" target=\"_blank\"\u003e#\u003cspan\u003ewelcome\u003c/span\u003e\u003c/a\u003e ! first post on the instance \u003cimg src=\"http://localhost:8080/fileserver/01AY6P665V14JJR0AFVRT7311Y/emoji/original/01F8MH9H8E4VG3KDYJR9EGPXCQ.png\" title=\":rainbow:\" alt=\":rainbow:\" width=\"25\" height=\"25\" /\u003e !\u003c/p\u003e",
"summary": "@admin@localhost:8080 posted 1 attachment: \"hello world! #welcome ! first post on the instance :rainbow: !\"",
"image": "http://localhost:8080/fileserver/01F8MH17FWEB39HZJ76B6VXSKF/attachment/original/01F8MH6NEM8D7527KZAECTCR76.jpg",
- "date_published": "2021-10-20T11:36:45Z",
- "author": {
- "name": "@admin@localhost:8080"
- },
- "authors": [
- {
- "name": "@admin@localhost:8080"
- }
- ]
+ "date_published": "2021-10-20T11:36:45Z"
}
]
}`)
@@ -165,7 +140,6 @@ func (suite *GetRSSTestSuite) TestGetAccountRSSZork() {
http://localhost:8080/@the_mighty_zork/statuses/01JDPZC707CKDN8N4QVWM4Z1NR
@the_mighty_zork@localhost:8080 made a new post: "this is the latest revision of the status, with a content-warning"this is the latest revision of the status, with a content-warning]]>
- @the_mighty_zork@localhost:8080http://localhost:8080/@the_mighty_zork/statuses/01JDPZC707CKDN8N4QVWM4Z1NRFri, 01 Nov 2024 09:00:00 +0000http://localhost:8080/@the_mighty_zork/feed.rss
@@ -210,7 +184,6 @@ func (suite *GetRSSTestSuite) TestGetAccountRSSZork() {
</div>
</section>
There, hope you liked that!
]]>
- @the_mighty_zork@localhost:8080http://localhost:8080/@the_mighty_zork/statuses/01HH9KYNQPA416TNJ53NSATP40Sun, 10 Dec 2023 09:24:00 +0000http://localhost:8080/@the_mighty_zork/feed.rss
@@ -220,7 +193,6 @@ func (suite *GetRSSTestSuite) TestGetAccountRSSZork() {
http://localhost:8080/@the_mighty_zork/statuses/01F8MHAMCHF6Y650WCRSCP4WMY
@the_mighty_zork@localhost:8080 made a new post: "hello everyone!"hello everyone!]]>
- @the_mighty_zork@localhost:8080http://localhost:8080/@the_mighty_zork/statuses/01F8MHAMCHF6Y650WCRSCP4WMYWed, 20 Oct 2021 10:40:37 +0000http://localhost:8080/@the_mighty_zork/feed.rss
@@ -248,7 +220,6 @@ func (suite *GetRSSTestSuite) TestGetAccountAtomZork() {
http://localhost:8080/@the_mighty_zork/statuses/01JDPZC707CKDN8N4QVWM4Z1NR
@the_mighty_zork@localhost:8080 made a new post: "this is the latest revision of the status, with a content-warning"this is the latest revision of the status, with a content-warning]]>
- @the_mighty_zork@localhost:8080http://localhost:8080/@the_mighty_zork/statuses/01JDPZC707CKDN8N4QVWM4Z1NRFri, 01 Nov 2024 09:00:00 +0000http://localhost:8080/@the_mighty_zork/feed.rss
@@ -293,7 +264,6 @@ func (suite *GetRSSTestSuite) TestGetAccountAtomZork() {
</div>
</section>
There, hope you liked that!
]]>
- @the_mighty_zork@localhost:8080http://localhost:8080/@the_mighty_zork/statuses/01HH9KYNQPA416TNJ53NSATP40Sun, 10 Dec 2023 09:24:00 +0000http://localhost:8080/@the_mighty_zork/feed.rss
@@ -303,7 +273,6 @@ func (suite *GetRSSTestSuite) TestGetAccountAtomZork() {
http://localhost:8080/@the_mighty_zork/statuses/01F8MHAMCHF6Y650WCRSCP4WMY
@the_mighty_zork@localhost:8080 made a new post: "hello everyone!"hello everyone!]]>
- @the_mighty_zork@localhost:8080http://localhost:8080/@the_mighty_zork/statuses/01F8MHAMCHF6Y650WCRSCP4WMYWed, 20 Oct 2021 10:40:37 +0000http://localhost:8080/@the_mighty_zork/feed.rss
@@ -328,15 +297,7 @@ func (suite *GetRSSTestSuite) TestGetAccountJSONZork() {
"content_html": "\u003cp\u003ethis is the latest revision of the status, with a content-warning\u003c/p\u003e",
"summary": "@the_mighty_zork@localhost:8080 made a new post: \"this is the latest revision of the status, with a content-warning\"",
"date_published": "2024-11-01T09:00:00Z",
- "date_modified": "2024-11-01T09:02:00Z",
- "author": {
- "name": "@the_mighty_zork@localhost:8080"
- },
- "authors": [
- {
- "name": "@the_mighty_zork@localhost:8080"
- }
- ]
+ "date_modified": "2024-11-01T09:02:00Z"
},
{
"id": "http://localhost:8080/@the_mighty_zork/statuses/01HH9KYNQPA416TNJ53NSATP40",
@@ -345,15 +306,7 @@ func (suite *GetRSSTestSuite) TestGetAccountJSONZork() {
"title": "HTML in post",
"content_html": "\u003cp\u003eHere's a bunch of HTML, read it and weep, weep then!\u003c/p\u003e\u003cpre\u003e\u003ccode class=\"language-html\"\u003e\u0026lt;section class=\u0026#34;about-user\u0026#34;\u0026gt;\n \u0026lt;div class=\u0026#34;col-header\u0026#34;\u0026gt;\n \u0026lt;h2\u0026gt;About\u0026lt;/h2\u0026gt;\n \u0026lt;/div\u0026gt; \n \u0026lt;div class=\u0026#34;fields\u0026#34;\u0026gt;\n \u0026lt;h3 class=\u0026#34;sr-only\u0026#34;\u0026gt;Fields\u0026lt;/h3\u0026gt;\n \u0026lt;dl\u0026gt;\n \u0026lt;div class=\u0026#34;field\u0026#34;\u0026gt;\n \u0026lt;dt\u0026gt;should you follow me?\u0026lt;/dt\u0026gt;\n \u0026lt;dd\u0026gt;maybe!\u0026lt;/dd\u0026gt;\n \u0026lt;/div\u0026gt;\n \u0026lt;div class=\u0026#34;field\u0026#34;\u0026gt;\n \u0026lt;dt\u0026gt;age\u0026lt;/dt\u0026gt;\n \u0026lt;dd\u0026gt;120\u0026lt;/dd\u0026gt;\n \u0026lt;/div\u0026gt;\n \u0026lt;/dl\u0026gt;\n \u0026lt;/div\u0026gt;\n \u0026lt;div class=\u0026#34;bio\u0026#34;\u0026gt;\n \u0026lt;h3 class=\u0026#34;sr-only\u0026#34;\u0026gt;Bio\u0026lt;/h3\u0026gt;\n \u0026lt;p\u0026gt;i post about things that concern me\u0026lt;/p\u0026gt;\n \u0026lt;/div\u0026gt;\n \u0026lt;div class=\u0026#34;sr-only\u0026#34; role=\u0026#34;group\u0026#34;\u0026gt;\n \u0026lt;h3 class=\u0026#34;sr-only\u0026#34;\u0026gt;Stats\u0026lt;/h3\u0026gt;\n \u0026lt;span\u0026gt;Joined in Jun, 2022.\u0026lt;/span\u0026gt;\n \u0026lt;span\u0026gt;8 posts.\u0026lt;/span\u0026gt;\n \u0026lt;span\u0026gt;Followed by 1.\u0026lt;/span\u0026gt;\n \u0026lt;span\u0026gt;Following 1.\u0026lt;/span\u0026gt;\n \u0026lt;/div\u0026gt;\n \u0026lt;div class=\u0026#34;accountstats\u0026#34; aria-hidden=\u0026#34;true\u0026#34;\u0026gt;\n \u0026lt;b\u0026gt;Joined\u0026lt;/b\u0026gt;\u0026lt;time datetime=\u0026#34;2022-06-04T13:12:00.000Z\u0026#34;\u0026gt;Jun, 2022\u0026lt;/time\u0026gt;\n \u0026lt;b\u0026gt;Posts\u0026lt;/b\u0026gt;\u0026lt;span\u0026gt;8\u0026lt;/span\u0026gt;\n \u0026lt;b\u0026gt;Followed by\u0026lt;/b\u0026gt;\u0026lt;span\u0026gt;1\u0026lt;/span\u0026gt;\n \u0026lt;b\u0026gt;Following\u0026lt;/b\u0026gt;\u0026lt;span\u0026gt;1\u0026lt;/span\u0026gt;\n \u0026lt;/div\u0026gt;\n\u0026lt;/section\u0026gt;\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eThere, hope you liked that!\u003c/p\u003e",
"summary": "@the_mighty_zork@localhost:8080 made a new post: \"Here's a bunch of HTML, read it and weep, weep then!\n\n`+"```"+`html\n\u003csection class=\"about-user\"\u003e\n \u003cdiv class=\"col-header\"\u003e\n \u003ch2\u003eAbout\u003c/h2\u003e\n \u003c/div\u003e \n \u003cdiv class=\"fields\"\u003e\n \u003ch3 class=\"sr-only\"\u003eFields\u003c/h3\u003e\n \u003cdl\u003e\n...",
- "date_published": "2023-12-10T09:24:00Z",
- "author": {
- "name": "@the_mighty_zork@localhost:8080"
- },
- "authors": [
- {
- "name": "@the_mighty_zork@localhost:8080"
- }
- ]
+ "date_published": "2023-12-10T09:24:00Z"
},
{
"id": "http://localhost:8080/@the_mighty_zork/statuses/01F8MHAMCHF6Y650WCRSCP4WMY",
@@ -362,15 +315,7 @@ func (suite *GetRSSTestSuite) TestGetAccountJSONZork() {
"title": "introduction post",
"content_html": "\u003cp\u003ehello everyone!\u003c/p\u003e",
"summary": "@the_mighty_zork@localhost:8080 made a new post: \"hello everyone!\"",
- "date_published": "2021-10-20T10:40:37Z",
- "author": {
- "name": "@the_mighty_zork@localhost:8080"
- },
- "authors": [
- {
- "name": "@the_mighty_zork@localhost:8080"
- }
- ]
+ "date_published": "2021-10-20T10:40:37Z"
}
]
}`)
--
cgit v1.2.3