[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/odoo#114565

X-original-commit: 2631c8a39ccb03f5a0f142e479e3264f8885c5d2
Signed-off-by: Géry Debongnie <ged@odoo.com>
Signed-off-by: Julien Castiaux (juc) <juc@odoo.com>
This commit is contained in:
Petar Najman
2023-03-13 10:53:00 +01:00
parent fd5a082984
commit 62a08bfa0a
@@ -16,6 +16,15 @@ const utils = {
var cookie = parts.join('=');
if (cookieName && cookieName === name) {
if (cookie.startsWith('"')) {
if (cookie.includes('\\')){
// see werkzeug _cookie_quote
throw new Error(
`Cookie value contains unknown characters ${cookie}`
)
}
cookie = cookie.slice(1, -1);
}
return cookie;
}
}