From 4d9fe1b8f541ba5d92772a44abd7b53295f7354e Mon Sep 17 00:00:00 2001 From: Maksim Soldatjonok Date: Wed, 22 Jul 2026 12:48:07 +0300 Subject: [PATCH] fix: guard MageCookies.getAll() against non-JSON cookies JSON.parse() ran on any cookie starting with [ or {, so a foreign cookie that only looks like JSON (e.g. Adobe Analytics s_sq="[[B]]") threw a SyntaxError and aborted every caller of getAll()/get(). --- view/base/templates/script/cookies.phtml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/view/base/templates/script/cookies.phtml b/view/base/templates/script/cookies.phtml index f750c4b..5adf2c8 100644 --- a/view/base/templates/script/cookies.phtml +++ b/view/base/templates/script/cookies.phtml @@ -38,7 +38,11 @@ $cookieConfig = $block->getCookieConfig(); value = decodeURIComponent(value); if (value.startsWith('[') || value.startsWith('{')) { - value = JSON.parse(value); + try { + value = JSON.parse(value); + } catch (e) { + // Foreign non-JSON cookie (e.g. Adobe Analytics s_sq="[[B]]") — keep raw string. + } } cookies[name] = value;