diff --git a/public/pages/shopping.js b/public/pages/shopping.js index 88a9aec..cd15326 100644 --- a/public/pages/shopping.js +++ b/public/pages/shopping.js @@ -202,15 +202,15 @@ function renderItem(item) { data-item-id="${item.id}">
-
${item.name}
- ${item.quantity ? `
${item.quantity}
` : ''} +
${escHtml(item.name)}
+ ${item.quantity ? `
${escHtml(item.quantity)}
` : ''}
@@ -731,3 +731,16 @@ export async function render(container, { user }) { } }); } + +// -------------------------------------------------------- +// HTML-Escaping +// -------------------------------------------------------- + +function escHtml(str) { + if (!str) return ''; + return String(str) + .replace(/&/g, '&') + .replace(//g, '>') + .replace(/"/g, '"'); +}