fix: vulnerability problems

This commit is contained in:
ikechan8370 2023-02-19 01:19:08 +08:00
parent b5afe1f4fb
commit 6da40e3843
7 changed files with 42 additions and 19 deletions

View file

@ -6,6 +6,17 @@
// .processSync(markdown ?? '')
// .toString()
// }
export function escapeHtml (str) {
const htmlEntities = {
'&': '&',
'<': '&lt;',
'>': '&gt;',
'"': '&quot;',
"'": '&#39;',
'/': '&#x2F;'
}
return str.replace(/[&<>"'/]/g, (match) => htmlEntities[match])
}
export async function upsertMessage (message) {
await redis.set(`CHATGPT:MESSAGE:${message.id}`, JSON.stringify(message))