[IMP] cookies: when retrieving session cookie, catch eventual parsing errors and...
authorMartin Trigaux <mat@openerp.com>
Thu, 27 Mar 2014 12:08:26 +0000 (13:08 +0100)
committerMartin Trigaux <mat@openerp.com>
Thu, 27 Mar 2014 12:08:26 +0000 (13:08 +0100)
In case of unparsable cookie (modified, corrupted,...), openerp would not load and crash with white screen until expiration.
With the fix goes back to login screen.

bzr revid: mat@openerp.com-20140327120826-2p6ebnojtmdl1wpm

1  2 
addons/web/static/src/js/coresetup.js

@@@ -125,7 -125,12 +125,12 @@@ instance.web.Session = instance.web.Jso
          for(var i=0; i<cookies.length; ++i) {
              var cookie = cookies[i].replace(/^\s*/, '');
              if(cookie.indexOf(nameEQ) === 0) {
-                 return JSON.parse(decodeURIComponent(cookie.substring(nameEQ.length)));
+                 try {
+                     return JSON.parse(decodeURIComponent(cookie.substring(nameEQ.length)));
+                 } catch (err) {
 -                    // delete malformed cookie
++                    // wrong cookie, delete it
+                     this.set_cookie(name, '', -1);
+                 }
              }
          }
          return null;