Skip to content

Commit

Permalink
fix: Setup of fallBack Sanitizer and processing of content when sanit…
Browse files Browse the repository at this point in the history
…izer is not enabled
  • Loading branch information
lucasnetau committed Oct 5, 2023
1 parent 8f88df2 commit 69c4a10
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/js/sanitizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const sanitizerConfig = {
})
return purify
})(window.DOMPurify) : false,
fallback: fallbackSanitizer,
fallback: content => content,
}
}

Expand Down Expand Up @@ -134,6 +134,8 @@ const fallbackSanitizer = content => {
return tmp.innerHTML
}

sanitizerConfig.backends.fallback = fallbackSanitizer

export const attributeWillClobber = value => {
const check_doc = document
const check_form = document.createElement('form')
Expand Down Expand Up @@ -211,8 +213,12 @@ export const setElementContent = (element, content, asText = false) => {
const performedBy = sanitizerConfig.backendOrder.find(type => sanitizersCallbacks[type](proxyElem, content))
if (performedBy !== undefined) {
sanitizeDomClobbering(proxyElem)
element.innerHTML = proxyElem.innerHTML
return element
}
element.innerHTML = proxyElem.innerHTML
element.innerHTML = content

return element
}
}

Expand Down

0 comments on commit 69c4a10

Please sign in to comment.