Skip to content

Missing parameter validation on setCookie function causes TypeError #145

@fabiante

Description

@fabiante

I noticed missing parameter validation in the setCookie function:

tough-cookie/lib/cookie.js

Lines 995 to 1001 in 4350705

CookieJar.prototype.setCookie = function(cookie, url, options, cb) {
var err;
var context = getCookieContext(url);
if (options instanceof Function) {
cb = options;
options = {};
}

There is no parameter validation which may cause confusion when not setting url. If only cookies then the function will assume that the options parameter is an object and tries to access the loose property. This will cause a TypeException.

There should either be parameter validation throwing an Error or some kind of handling.

This was found when investigating this bug: valeriangalliat/fetch-cookie#35

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions