Skip to content

Commit 2631c8a

Browse files
[FIX] web: Quoted cookie values are not handled by cookie_utils.js
When we set a cookie value (i.e. 'frontend_lang') on backend which can contain "invalid" character like @ (i.e. Serbian lang code: sr@latin) that cookie value will be double-quoted by werkzeug, so our example cookie will end up like: frontend_lang="sr@latin" instead of what's expected on the front-end: frontend_lang=sr@latin.On the front-end side we need to remove that additional double-quote before returning the actual cookie value. closes odoo#113490 Signed-off-by: Géry Debongnie <ged@odoo.com>
1 parent 85db377 commit 2631c8a

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

addons/web/static/src/legacy/js/core/cookie_utils.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,15 @@ const utils = {
1616
var cookie = parts.join('=');
1717

1818
if (cookieName && cookieName === name) {
19+
if (cookie.startsWith('"')) {
20+
if (cookie.includes('\\')){
21+
// see werkzeug _cookie_quote
22+
throw new Error(
23+
`Cookie value contains unknown characters ${cookie}`
24+
)
25+
}
26+
cookie = cookie.slice(1, -1);
27+
}
1928
return cookie;
2029
}
2130
}

0 commit comments

Comments
 (0)