From d2003d45d640ed0927e5aff890e74c6779861185 Mon Sep 17 00:00:00 2001 From: Sami Mokaddem Date: Thu, 16 Feb 2023 13:30:54 +0100 Subject: [PATCH] chg: [js-utils:sanitize] Added sanitization function --- webroot/js/utils.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/webroot/js/utils.js b/webroot/js/utils.js index a248772..1a04fb0 100644 --- a/webroot/js/utils.js +++ b/webroot/js/utils.js @@ -200,4 +200,10 @@ function download(filename, data, type='application/json') { a.click() document.body.removeChild(a) URL.revokeObjectURL(objectURL) +} + +function sanitize(unsafeText) { + const decoder = $('
') + decoder.text(unsafeText) + return decoder.html() } \ No newline at end of file