🐛 Adds encoding entities
All checks were successful
Update RSS / update-rss (push) Successful in 5m13s

This commit is contained in:
2025-03-04 09:36:31 +01:00
parent b1db05311f
commit 3d1ac373e3
3 changed files with 79 additions and 70 deletions

15
cli.mjs
View File

@ -87,11 +87,11 @@ async function toRSS({ json, changed }){
return [
"<item>",
...[
`<title>${title}</title>`,
`<title>${encodeToXml(title)}</title>`,
`<link>${host+loc}</link>`,
`<guid>${host+loc}</guid>`,
`<description>${perex}</description>`,
`<dc:creator>${author}</dc:creator>`,
`<description>${encodeToXml(perex)}</description>`,
`<dc:creator>${encodeToXml(author)}</dc:creator>`,
`<pubDate>${pubDate(json.drops.find(d=> d.drop === drop).date)}</pubDate>`,
`<category>${drop}</category>`,
].map(l=> "\t"+l),
@ -154,6 +154,15 @@ async function sitemap(){
s.echo(JSON.stringify(json, null, "\t")).to(path);
return { json, changed: [ path ] };
}
function encodeToXml(str){
if(!str) return str;
return str
.replace(/&/g, "&amp;")
.replace(/"/g, "&quot;")
.replace(/'/g, "&apos;")
.replace(/</g, "&lt;")
.replace(/>/g, "&gt;");
}
function knownSitemap(){
const path= "sitemap.json";
/** @type {Sitemap} */