summaryrefslogtreecommitdiffstats
path: root/public/.local/share/dmenu/snippet/htmlEscape.js
blob: f4a3673114584f0b2019785716b189a50f9d331b (plain)
1
2
3
4
5
6
7
8
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;");
}