diff --git a/apps/web/app/blog/rss.xml/route.ts b/apps/web/app/blog/rss.xml/route.ts index 795e767..de87d15 100644 --- a/apps/web/app/blog/rss.xml/route.ts +++ b/apps/web/app/blog/rss.xml/route.ts @@ -4,6 +4,15 @@ import { getDb } from '@/lib/db'; const BASE = 'https://c0upons.com'; +function escapeXml(str: string): string { + return str + .replace(/&/g, '&') + .replace(//g, '>') + .replace(/"/g, '"') + .replace(/'/g, '''); +} + export async function GET() { let posts: Array<{ slug: string; title: string; excerpt: string | null; published_at: string; author: string | null }> = []; @@ -23,10 +32,10 @@ export async function GET() { const items = posts.map((p) => ` <![CDATA[${p.title}]]> - ${BASE}/blog/${p.slug} - ${BASE}/blog/${p.slug} + ${BASE}/blog/${encodeURIComponent(p.slug)} + ${BASE}/blog/${encodeURIComponent(p.slug)} ${p.excerpt ? `` : ''} - ${p.author ? `${p.author}` : ''} + ${p.author ? `${escapeXml(p.author)}` : ''} ${new Date(p.published_at).toUTCString()} `).join('');