feat: enhance HTML escaping to include single quotes (#4755)

b0dd267b9e90d9f276239b362433142982149515

Wolfsblvt <wolfsblvt@gmail.com>

Signed
1 files changed, +11 -1Ignore whitespace
public/scripts/utils.js+11 -1
@@ -140,8 +140,18 @@ export function ensurePlainObject(obj) {
140 return obj;140 return obj;
141}141}
142142
143/**
144 * Escapes text for safe HTML rendering.
145 * @param {string?} str
146 * @returns {string}
147 */
143export function escapeHtml(str) {148export function escapeHtml(str) {
144 return String(str).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');149 return String(str ?? '')
150 .replace(/&/g, '&amp;')
151 .replace(/</g, '&lt;')
152 .replace(/>/g, '&gt;')
153 .replace(/"/g, '&quot;')
154 .replace(/'/g, '&#39;');
145}155}
146156
147/**157/**