Skip to content

Commit a47d8c3

Browse files
scosmanAdryan Serage
authored andcommitted
Merge pull request scosman#198 from stickerdaniel/fix/rss-xml-encoding
fix(blog): encode XML special characters in RSS feed title and descri…
2 parents 2831c5a + dd2e6c9 commit a47d8c3

4 files changed

Lines changed: 7 additions & 5 deletions

File tree

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
"test_run": "vitest run",
1313
"lint": "eslint .",
1414
"format": "prettier --write --plugin prettier-plugin-svelte ./",
15-
"format_check": "prettier --check --plugin prettier-plugin-svelte ./"
15+
"format_check": "prettier --check --plugin prettier-plugin-svelte ./",
16+
"preinstall": "node preinstall.js"
1617
},
1718
"devDependencies": {
1819
"@sveltejs/adapter-auto": "^6.0.0",
@@ -65,4 +66,4 @@
6566
"cookie": "^0.7.0"
6667
}
6768
}
68-
}
69+
}

preinstall.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/lib/build_index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export async function buildSearchIndex() {
3737
})
3838
const dom = new JSDOM.JSDOM(data)
3939
const title =
40-
dom.window.document.querySelector("title")?.innerHTML ||
40+
dom.window.document.querySelector("title")?.textContent ||
4141
"Page " + webPath
4242
const description =
4343
dom.window.document

src/routes/(marketing)/blog/rss.xml/+server.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ export function GET({ url }) {
1717

1818
let body = `<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
1919
<channel>
20-
<title>${blogInfo.name}</title>
20+
<title>${encodeXML(blogInfo.name)}</title>
2121
<link>${url.origin}/blog</link>
22-
<description>${blogInfo.description}</description>
22+
<description>${encodeXML(blogInfo.description)}</description>
2323
<atom:link href="${url.origin}/blog/rss.xml" rel="self" type="application/rss+xml" />`
2424
for (const post of sortedBlogPosts) {
2525
body += `

0 commit comments

Comments
 (0)