Skip to content

Bug with reading cookie set by other libraries #39

Description

@Hypnoticbg

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions