diff --git a/js/cart-manager.js b/js/cart-manager.js index 3520d5b..9828c0e 100644 --- a/js/cart-manager.js +++ b/js/cart-manager.js @@ -67,9 +67,10 @@ class CartManager { // NORMALIZE ITEM (CRITICAL FIX) // ===================== normalize(item) { + const safeName = typeof sanitizeInput !== "undefined" ? sanitizeInput(item.name, 100) : item.name; return { - id: item.id || item.name + "-" + item.price, - name: item.name, + id: item.id || safeName + "-" + item.price, + name: safeName, price: Number(item.price), // ✅ SAFE IMAGE FIX (does NOT affect menu) diff --git a/js/main.js b/js/main.js index 0db96c1..6626c7e 100644 --- a/js/main.js +++ b/js/main.js @@ -272,7 +272,11 @@ function fuzzyMatch(target, query) { function highlightText(text, query) { if (!text) return ""; - if (!query) return text; + + // Always wrap text to be safe + const safeText = typeof escapeHTML !== "undefined" ? escapeHTML(text) : text; + + if (!query) return safeText; const escapedQuery = query.replace( /[-\/\\^$*+?.()|[\]{}]/g, @@ -280,7 +284,7 @@ function highlightText(text, query) { ); const regex = new RegExp(`(${escapedQuery})`, "gi"); - return text.replace(regex, "$1"); + return safeText.replace(regex, "$1"); } // ===== Render Functions =====