Skip to content

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

Description

@sidx1024

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"

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions