From cf4f7cdd2871d33e93d651ae28e01082135f6965 Mon Sep 17 00:00:00 2001 From: end-4 <97237370+end-4@users.noreply.github.com> Date: Mon, 26 May 2025 20:02:58 +0200 Subject: [PATCH] string utils: add escape html --- .../modules/common/functions/string_utils.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/.config/quickshell/modules/common/functions/string_utils.js b/.config/quickshell/modules/common/functions/string_utils.js index 23b0f1f88..c22671ebf 100644 --- a/.config/quickshell/modules/common/functions/string_utils.js +++ b/.config/quickshell/modules/common/functions/string_utils.js @@ -175,4 +175,14 @@ function friendlyTimeForSeconds(seconds) { } else { return `${m}:${s.toString().padStart(2, '0')}`; } -} \ No newline at end of file +} + +function escapeHtml(str) { + if (typeof str !== 'string') return str; + return str + .replace(/&/g, '&') + .replace(//g, '>') + .replace(/"/g, '"') + .replace(/'/g, '''); +}