fix(editor): Fixing XSS vulnerability in toast messages (#10329)

Co-authored-by: Adi <aditya@netroy.in>
This commit is contained in:
Milorad FIlipović
2024-08-08 16:28:51 +02:00
committed by GitHub
parent b6c47c0e32
commit 38bdd9f5d0
5 changed files with 25 additions and 18 deletions

View File

@@ -18,6 +18,10 @@ export function sanitizeHtml(dirtyHtml: string) {
}
if (ALLOWED_HTML_ATTRIBUTES.includes(name) || name.startsWith('data-')) {
// href is allowed but we need to sanitize certain protocols
if (name === 'href' && !value.match(/^https?:\/\//gm)) {
return '';
}
return `${name}="${friendlyAttrValue(value)}"`;
}