mirror of
https://github.com/d0zingcat/BroadcastChannel.git
synced 2026-05-16 07:26:44 +00:00
feat: add sanitize-html for content filtering
Enhance RSS feed content safety by integrating sanitize-html to allow specific media tags and attributes, ensuring a secure and controlled presentation of content.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import rss from '@astrojs/rss'
|
||||
|
||||
import sanitizeHtml from 'sanitize-html'
|
||||
import { getChannelInfo } from '../lib/telegram'
|
||||
|
||||
export const prerender = false
|
||||
@@ -22,7 +22,14 @@ export async function GET(Astro) {
|
||||
title: item.title,
|
||||
description: item.description,
|
||||
pubDate: new Date(item.datetime),
|
||||
content: item.content,
|
||||
content: sanitizeHtml(item.content, {
|
||||
allowedTags: sanitizeHtml.defaults.allowedTags.concat(['img', 'video', 'audio']),
|
||||
allowedAttributes: {
|
||||
video: ['src', 'width', 'height', 'poster'],
|
||||
audio: ['src', 'controls'],
|
||||
img: ['src', 'width', 'height', 'loading'],
|
||||
},
|
||||
}),
|
||||
})),
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user