Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Loose mode flag is not preserved in toJSON() serialization #195

Closed
sidx1024 opened this issue Jun 16, 2020 · 2 comments
Closed

Loose mode flag is not preserved in toJSON() serialization #195

sidx1024 opened this issue Jun 16, 2020 · 2 comments
Assignees

Comments

@sidx1024
Copy link

sidx1024 commented Jun 16, 2020

CookieJar.toJSON() method doesn't preserve looseMode flag. Thus, setting an invalid cookie throws an error (after creating a new instance using fromJSON()).

Reproduceable code:

const { CookieJar } = require('tough-cookie');

const url = 'http://random.com';
const cookie = 'Invalid Cookie;';

const cookieJar = new CookieJar(null, { looseMode: true });

const deserializedCookieJar = CookieJar.fromJSON(cookieJar.toJSON());
deserializedCookieJar.setCookieSync(cookie, url);
// ^ throws "Error: Cookie failed to parse"
@medelibero-sfdc
Copy link
Contributor

Hi @sidx1024,

I can recreate this problem. Let me talk with the rest of the team and figure out the best course of action to fix it.

Thanks,
Mike

medelibero-sfdc added a commit that referenced this issue Sep 18, 2020
medelibero-sfdc added a commit that referenced this issue Sep 21, 2020
@medelibero-sfdc
Copy link
Contributor

Hi @sidx1024,

I have committed to master a fix for this issue. Thank you for reporting this to us!

-Mike

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants