summaryrefslogtreecommitdiffstats
path: root/public/.local/share/dmenu/snippet/htmlEscape.js
diff options
context:
space:
mode:
Diffstat (limited to 'public/.local/share/dmenu/snippet/htmlEscape.js')
-rw-r--r--public/.local/share/dmenu/snippet/htmlEscape.js9
1 files changed, 9 insertions, 0 deletions
diff --git a/public/.local/share/dmenu/snippet/htmlEscape.js b/public/.local/share/dmenu/snippet/htmlEscape.js
new file mode 100644
index 0000000..f4a3673
--- /dev/null
+++ b/public/.local/share/dmenu/snippet/htmlEscape.js
@@ -0,0 +1,9 @@
+/* https://stackoverflow.com/questions/7381974/which-characters-need-to-be-escaped-in-html#7382028 */
+function htmlEscape(text) {
+ return String(text)
+ .replaceAll("&", "&")
+ .replaceAll("<", "&lt;")
+ .replaceAll(">", "&gt;")
+ .replaceAll('"', "&quot;")
+ .replaceAll("'", "&#39;");
+}