coming together
This commit is contained in:
@@ -64,14 +64,24 @@
|
||||
return window.DOMPurify.sanitize(dirty);
|
||||
}
|
||||
// Trigger async load so the next call benefits
|
||||
ensureDOMPurifyLoaded().catch(() => {});
|
||||
try {
|
||||
const loader = (window && window.htmlSanitizer && typeof window.htmlSanitizer.ensureDOMPurifyLoaded === 'function')
|
||||
? window.htmlSanitizer.ensureDOMPurifyLoaded
|
||||
: ensureDOMPurifyLoaded;
|
||||
loader().catch(() => {});
|
||||
} catch (_) {}
|
||||
return fallbackSanitize(dirty);
|
||||
}
|
||||
|
||||
function escapeHtml(text) {
|
||||
const span = document.createElement('span');
|
||||
span.textContent = String(text == null ? '' : text);
|
||||
return span.innerHTML;
|
||||
// Encode &, <, >, ", and '
|
||||
const str = String(text == null ? '' : text);
|
||||
return str
|
||||
.replace(/&/g, '&')
|
||||
.replace(/</g, '<')
|
||||
.replace(/>/g, '>')
|
||||
.replace(/"/g, '"')
|
||||
.replace(/'/g, ''');
|
||||
}
|
||||
|
||||
function setSafeHTML(element, html) {
|
||||
|
||||
Reference in New Issue
Block a user