Skip to content

Commit 6154581

Browse files
committed
tests/worker/rss: Work around broken ]]> escaping
1 parent ee9ce44 commit 6154581

File tree

6 files changed

+14
-6
lines changed

6 files changed

+14
-6
lines changed

src/tests/worker/rss/snapshots/crates_io__tests__worker__rss__sync_crates_feed__sync_crates_feed-2.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ snapshot_kind: text
2121
<item>
2222
<title>New crate created: baz</title>
2323
<link>https://crates.io/crates/baz</link>
24-
<description><![CDATA[does it handle XML? <item>]]></description>
24+
<description><![CDATA[does it handle XML? <item> ]]]]><![CDATA[>]]></description>
2525
<guid>https://crates.io/crates/baz</guid>
2626
<pubDate>Fri, 21 Jun 2024 17:01:33 +0000</pubDate>
2727
<crates:name>baz</crates:name>

src/tests/worker/rss/snapshots/crates_io__tests__worker__rss__sync_updates_feed__sync_updates_feed-2.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ snapshot_kind: text
3030
<item>
3131
<title>New crate version published: bar v3.0.0-beta.1</title>
3232
<link>https://crates.io/crates/bar/3.0.0-beta.1</link>
33-
<description><![CDATA[let's try & break this <item>]]></description>
33+
<description><![CDATA[let's try & break this <item> ]]]]><![CDATA[>]]></description>
3434
<guid>https://crates.io/crates/bar/3.0.0-beta.1</guid>
3535
<pubDate>Fri, 21 Jun 2024 17:03:45 +0000</pubDate>
3636
<crates:name>bar</crates:name>

src/tests/worker/rss/sync_crates_feed.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ async fn test_sync_crates_feed() {
1515
let description = Some("something something foo");
1616
create_crate(&mut conn, "foo", description, "2024-06-20T10:13:54Z").await;
1717
create_crate(&mut conn, "bar", None, "2024-06-20T12:45:12Z").await;
18-
let description = Some("does it handle XML? <item>");
18+
let description = Some("does it handle XML? <item> ]]>");
1919
create_crate(&mut conn, "baz", description, "2024-06-21T17:01:33Z").await;
2020
create_crate(&mut conn, "quux", None, "2024-06-21T17:03:45Z").await;
2121

src/tests/worker/rss/sync_updates_feed.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ async fn test_sync_updates_feed() {
1212
let (app, _) = TestApp::full().empty();
1313
let mut conn = app.async_db_conn().await;
1414

15-
let d = Some("let's try & break this <item>");
15+
let d = Some("let's try & break this <item> ]]>");
1616

1717
create_version(&mut conn, "foo", "0.1.0", None, "2024-06-20T10:13:54Z").await;
1818
create_version(&mut conn, "foo", "0.1.1", None, "2024-06-20T12:45:12Z").await;

src/worker/jobs/rss/sync_crates_feed.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,10 @@ impl NewCrate {
125125
permalink: true,
126126
};
127127

128+
let description = self
129+
.description
130+
.map(|d| d.replace("]]>", "]]]]><![CDATA[>"));
131+
128132
let name_extension = rss::extension::Extension {
129133
name: "crates:name".into(),
130134
value: Some(self.name),
@@ -140,7 +144,7 @@ impl NewCrate {
140144
guid: Some(guid),
141145
title: Some(title),
142146
link: Some(link),
143-
description: self.description,
147+
description,
144148
pub_date: Some(pub_date),
145149
extensions,
146150
..Default::default()

src/worker/jobs/rss/sync_updates_feed.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,10 @@ impl VersionUpdate {
132132
permalink: true,
133133
};
134134

135+
let description = self
136+
.description
137+
.map(|d| d.replace("]]>", "]]]]><![CDATA[>"));
138+
135139
let name_extension = rss::extension::Extension {
136140
name: "crates:name".into(),
137141
value: Some(self.name),
@@ -156,7 +160,7 @@ impl VersionUpdate {
156160
guid: Some(guid),
157161
title: Some(title),
158162
link: Some(link),
159-
description: self.description,
163+
description,
160164
pub_date: Some(pub_date),
161165
extensions,
162166
..Default::default()

0 commit comments

Comments
 (0)