tough-cookie
Advanced tools
Comparing version 0.9.15 to 0.10.0
@@ -42,7 +42,7 @@ /* | ||
var COOKIE_OCTET = /[\x21\x23-\x2B\x2D-\x3A\x3C-\x5B\x5D-\x7E]/; | ||
var COOKIE_OCTETS = /^[\x21\x23-\x2B\x2D-\x3A\x3C-\x5B\x5D-\x7E]+$/; | ||
var COOKIE_OCTETS = new RegExp('^'+COOKIE_OCTET.source+'$'); | ||
// The name/key cannot be empty but the value can (S5.2): | ||
var COOKIE_PAIR_STRICT = new RegExp('^('+TOKEN.source+'+)=("?)('+COOKIE_OCTET.source+'*)\\2'); | ||
var COOKIE_PAIR = /^([^=\s]+)\s*=\s*("?)\s*(.*)\s*\2/; | ||
var COOKIE_PAIR_STRICT = new RegExp('^('+TOKEN.source+'+)=("?)('+COOKIE_OCTET.source+'*)\\2$'); | ||
var COOKIE_PAIR = /^([^=\s]+)\s*=\s*("?)\s*(.*)\s*\2\s*$/; | ||
@@ -613,6 +613,3 @@ // RFC6265 S4.1.1 defines extension-av as 'any CHAR except CTLs or ";"' | ||
if (val == null) val = ''; | ||
if (!val.length || COOKIE_OCTETS.test(val)) | ||
return this.key+'='+val; | ||
else | ||
return this.key+'="'+val+'"'; | ||
return this.key+'='+val; | ||
}; | ||
@@ -619,0 +616,0 @@ |
{ | ||
"author": "Jeremy Stashewsky <jeremy@goinstant.com> (https://github.com/stash)", | ||
"author": "GoInstant Inc., a salesforce.com company", | ||
"license": "MIT", | ||
"name": "tough-cookie", | ||
"description": "RFC6265 Cookies and Cookie Jar for node.js", | ||
"keywords":["HTTP","cookie","cookies","set-cookie","cookiejar","jar","RFC6265","RFC2965"], | ||
"version": "0.9.15", | ||
"keywords": [ | ||
"HTTP", | ||
"cookie", | ||
"cookies", | ||
"set-cookie", | ||
"cookiejar", | ||
"jar", | ||
"RFC6265", | ||
"RFC2965" | ||
], | ||
"version": "0.10.0", | ||
"homepage": "https://github.com/goinstant/node-cookie", | ||
@@ -26,5 +36,5 @@ "repository": { | ||
"devDependencies": { | ||
"vows": ">=0.6.0", | ||
"vows": "0.7.0", | ||
"async": ">=0.1.12" | ||
} | ||
} |
@@ -5,2 +5,7 @@ [RFC6265](http://tools.ietf.org/html/rfc6265) Cookies and CookieJar for Node.js | ||
[![Build Status](https://travis-ci.org/goinstant/node-cookie.png?branch=master)](https://travis-ci.org/goinstant/node-cookie) | ||
[![NPM Stats](https://nodei.co/npm/tough-cookie.png?downloads=true&stars=true)](https://npmjs.org/package/tough-cookie) | ||
![NPM Downloads](https://nodei.co/npm-dl/tough-cookie.png?months=9) | ||
# Synopsis | ||
@@ -128,3 +133,3 @@ | ||
if (res.headers['set-cookie'] instanceof Array) | ||
cookies = res.headers['set-cookie'].map(Cookie.parse); | ||
cookies = res.headers['set-cookie'].map(function (c) { return (Cookie.parse(c)); }); | ||
else | ||
@@ -151,3 +156,3 @@ cookies = [Cookie.parse(res.headers['set-cookie'])]; | ||
* _extensions_ - `Array` - any unrecognized cookie attributes as strings (even if equal-signs inside) | ||
After a cookie has been passed through `CookieJar.setCookie()` it will have the following additional attributes: | ||
@@ -242,3 +247,3 @@ | ||
* _rejectPublicSuffixes_ - boolean - reject cookies with domains like "com" and "co.uk" (default: `true`) | ||
Since eventually this module would like to support database/remote/etc. CookieJars, continuation passing style is used for CookieJar methods. | ||
@@ -265,3 +270,3 @@ | ||
__REMOVED__ removed in lieu of the CookieStore API below | ||
.getCookies(currentUrl, [{options},] cb(err,cookies)) | ||
@@ -366,3 +371,3 @@ ----------------------------------------------------- | ||
Copyright GoInstant, Inc. and other contributors. All rights reserved. | ||
Copyright 2012- GoInstant, Inc. and other contributors. All rights reserved. | ||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
@@ -369,0 +374,0 @@ of this software and associated documentation files (the "Software"), to |
77
test.js
@@ -138,4 +138,4 @@ /* | ||
}, | ||
"to string": function(c) { | ||
assert.equal(c.toString(), 'a="beta gamma"'); | ||
"'garbage in, garbage out'": function(c) { | ||
assert.equal(c.toString(), 'a=beta gamma'); | ||
}, | ||
@@ -511,3 +511,60 @@ }, | ||
"httponly": function(c) { assert.ok(c.httpOnly) }, | ||
} | ||
}, | ||
"spaces in value": { | ||
"strict": { | ||
topic: function() { | ||
return Cookie.parse('a=one two three',true) || null; | ||
}, | ||
"did not parse": function(c) { assert.isNull(c) }, | ||
}, | ||
"non-strict": { | ||
topic: function() { | ||
return Cookie.parse('a=one two three',false) || null; | ||
}, | ||
"parsed": function(c) { assert.ok(c) }, | ||
"key": function(c) { assert.equal(c.key, 'a') }, | ||
"value": function(c) { assert.equal(c.value, 'one two three') }, | ||
"no path": function(c) { assert.equal(c.path, null) }, | ||
"no domain": function(c) { assert.equal(c.domain, null) }, | ||
"no extensions": function(c) { assert.ok(!c.extensions) }, | ||
}, | ||
}, | ||
"quoted spaces in value": { | ||
"strict": { | ||
topic: function() { | ||
return Cookie.parse('a="one two three"',true) || null; | ||
}, | ||
"did not parse": function(c) { assert.isNull(c) }, | ||
}, | ||
"non-strict": { | ||
topic: function() { | ||
return Cookie.parse('a="one two three"',false) || null; | ||
}, | ||
"parsed": function(c) { assert.ok(c) }, | ||
"key": function(c) { assert.equal(c.key, 'a') }, | ||
"value": function(c) { assert.equal(c.value, 'one two three') }, | ||
"no path": function(c) { assert.equal(c.path, null) }, | ||
"no domain": function(c) { assert.equal(c.domain, null) }, | ||
"no extensions": function(c) { assert.ok(!c.extensions) }, | ||
} | ||
}, | ||
"non-ASCII in value": { | ||
"strict": { | ||
topic: function() { | ||
return Cookie.parse('farbe=weiß',true) || null; | ||
}, | ||
"did not parse": function(c) { assert.isNull(c) }, | ||
}, | ||
"non-strict": { | ||
topic: function() { | ||
return Cookie.parse('farbe=weiß',false) || null; | ||
}, | ||
"parsed": function(c) { assert.ok(c) }, | ||
"key": function(c) { assert.equal(c.key, 'farbe') }, | ||
"value": function(c) { assert.equal(c.value, 'weiß') }, | ||
"no path": function(c) { assert.equal(c.path, null) }, | ||
"no domain": function(c) { assert.equal(c.domain, null) }, | ||
"no extensions": function(c) { assert.ok(!c.extensions) }, | ||
}, | ||
}, | ||
} | ||
@@ -711,2 +768,16 @@ }) | ||
}, | ||
"Setting a sub-path cookie on a super-domain": { | ||
topic: function() { | ||
var cj = new CookieJar(); | ||
var c = Cookie.parse("a=b; Domain=example.com; Path=/subpath"); | ||
assert.strictEqual(c.hostOnly, null); | ||
assert.instanceOf(c.creation, Date); | ||
assert.strictEqual(c.lastAccessed, null); | ||
c.creation = new Date(Date.now()-10000); | ||
cj.setCookie(c, 'http://www.example.com/index.html', this.callback); | ||
}, | ||
"domain is super-domain": function(c) { assert.equal(c.domain, 'example.com') }, | ||
"path is /subpath": function(c) { assert.equal(c.path, '/subpath') }, | ||
"path was NOT derived": function(c) { assert.strictEqual(c.pathIsDefault, null) }, | ||
}, | ||
"Setting HttpOnly cookie over non-HTTP API": { | ||
@@ -713,0 +784,0 @@ topic: function() { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
Mixed license
License(Experimental) Package contains multiple licenses.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Mixed license
License(Experimental) Package contains multiple licenses.
Found 1 instance in 1 package
268006
12
2843
386
2