fix: sanitize html of all description fields

This commit is contained in:
Jannat Patel
2025-12-10 17:25:56 +05:30
parent 316e739dd6
commit 0877e32e1b
6 changed files with 40 additions and 26 deletions

View File

@@ -19,6 +19,7 @@ import SimpleImage from '@editorjs/simple-image'
import Table from '@editorjs/table'
import Plyr from 'plyr'
import 'plyr/dist/plyr.css'
import DOMPurify from 'dompurify'
const readOnlyMode = window.read_only_mode
@@ -540,6 +541,26 @@ export const escapeHTML = (text) => {
)
}
export const sanitizeHTML = (text) => {
text = DOMPurify.sanitize(decodeEntities(text), {
ALLOWED_TAGS: [
'b',
'i',
'em',
'strong',
'a',
'p',
'br',
'ul',
'ol',
'li',
'img',
],
ALLOWED_ATTR: ['href', 'target', 'src'],
})
return text
}
export const canCreateCourse = () => {
const { userResource } = usersStore()
return (