Skip to content

Commit e8e8ed2

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

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

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)