Skip to content

Commit

Permalink
Merge pull request #1437 from lucasnetau/sanitiser-fallback-init
Browse files Browse the repository at this point in the history
fix: Setup of fallBack Sanitizer and processing of content when sanitizer is not enabled
  • Loading branch information
kevinchappell authored Oct 5, 2023
2 parents c6b9bf5 + 69c4a10 commit f6aa79f
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 @@ function 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 f6aa79f

Please sign in to comment.