srdusr
aboutsummaryrefslogtreecommitdiffstats
path: root/web/src/util.js
diff options
context:
space:
mode:
Diffstat (limited to 'web/src/util.js')
-rw-r--r--web/src/util.js5
1 files changed, 5 insertions, 0 deletions
diff --git a/web/src/util.js b/web/src/util.js
new file mode 100644
index 0000000..65c718b
--- /dev/null
+++ b/web/src/util.js
@@ -0,0 +1,5 @@
+const ESCAPES = { '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' };
+
+export function escapeHtml(str) {
+ return str.replace(/[&<>"']/g, c => ESCAPES[c]);
+}