[FIX] web: correct cookie parsing.

avoid reading wrong cookie by matching the whole cookie name

bzr revid: chs@openerp.com-20131107143212-50hrpvkaw3gxxlop
This commit is contained in:
Christophe Simonis
2013-11-07 15:32:12 +01:00
parent 8dd53f6652
commit a48e793355
+8 -9
View File
@@ -1209,15 +1209,14 @@ openerp.TranslationDataBase = openerp.Class.extend(/** @lends instance.Translati
openerp._t = new openerp.TranslationDataBase().build_translation_function();
openerp.get_cookie = function(c_name) {
if (document.cookie.length > 0) {
var c_start = document.cookie.indexOf(c_name + "=");
if (c_start != -1) {
c_start = c_start + c_name.length + 1;
var c_end = document.cookie.indexOf(";", c_start);
if (c_end == -1) {
c_end = document.cookie.length;
}
return unescape(document.cookie.substring(c_start, c_end));
var cookies = document.cookie ? document.cookie.split('; ') : [];
for (var i = 0, l = cookies.length; i < l; i++) {
var parts = cookies[i].split('=');
var name = parts.shift();
var cookie = parts.join('=');
if (c_name && c_name === name) {
return cookie;
}
}
return "";