I have experienced strange behaviour on some browsers. The library suddenly stopped working with type error URIError: malformed URI sequence
Stack trace:
cookieFun@............./angular-cookie.js:77:1
The problem comes with wrong assumption that all cookies for that domain is created only by this library and are encoded with encodeURIComponent. In some cases there are some other cookies for the domain created by another scripts which is not encoded on the same way.
The problem could be fixed by replacing:
value = decodeURIComponent(cookie.substring(pos + 1)); /* 77 row */
with:
try {
value = decodeURIComponent(cookie.substring(pos + 1));
} catch (e) {
value = cookie.substring(pos+1);
}
The whole idea to encode cookies seems to be wrong because you can accidentally damage other third party cookies for instance: google analytics cookie.
I have experienced strange behaviour on some browsers. The library suddenly stopped working with type error URIError: malformed URI sequence
Stack trace:
cookieFun@............./angular-cookie.js:77:1
The problem comes with wrong assumption that all cookies for that domain is created only by this library and are encoded with encodeURIComponent. In some cases there are some other cookies for the domain created by another scripts which is not encoded on the same way.
The problem could be fixed by replacing:
value = decodeURIComponent(cookie.substring(pos + 1)); /* 77 row */
with:
try {
value = decodeURIComponent(cookie.substring(pos + 1));
} catch (e) {
value = cookie.substring(pos+1);
}
The whole idea to encode cookies seems to be wrong because you can accidentally damage other third party cookies for instance: google analytics cookie.