fix xss issue
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
export default function elementFromString(value: string): HTMLDivElement {
|
export default function elementFromString(value: string): HTMLElement {
|
||||||
const element = document.createElement('div')
|
const htmlString = `<div>${value}</div>`
|
||||||
element.innerHTML = value.trim()
|
const parser = new window.DOMParser
|
||||||
|
const element = parser.parseFromString(htmlString, 'text/html').body
|
||||||
|
|
||||||
return element
|
return element
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user