1
0
mirror of https://github.com/BookStackApp/BookStack.git synced 2025-06-15 23:01:44 +03:00

Started migrating tag manager JS to HTML-first component

This commit is contained in:
Dan Brown
2020-06-28 23:15:05 +01:00
parent 10305a4446
commit 4e107b9160
8 changed files with 201 additions and 16 deletions

View File

@ -45,4 +45,19 @@ export function scrollAndHighlightElement(element) {
element.classList.remove('selectFade');
element.style.backgroundColor = '';
}, 3000);
}
/**
* Escape any HTML in the given 'unsafe' string.
* Take from https://stackoverflow.com/a/6234804.
* @param {String} unsafe
* @returns {string}
*/
export function escapeHtml(unsafe) {
return unsafe
.replace(/&/g, "&")
.replace(/</g, "&lt;")
.replace(/>/g, "&gt;")
.replace(/"/g, "&quot;")
.replace(/'/g, "&#039;");
}