tough-cookie 0.13.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +189 -127
- package/generate-pubsuffix.js +60 -26
- package/lib/cookie.js +330 -171
- package/lib/memstore.js +33 -6
- package/lib/pathMatch.js +61 -0
- package/lib/permuteDomain.js +56 -0
- package/lib/pubsuffix.js +25 -6
- package/lib/store.js +5 -1
- package/package.json +5 -8
- package/public-suffix.txt +5752 -672
- package/test/api_test.js +0 -16
- package/test/cookie_sorting_test.js +66 -0
- package/test/cookie_to_json_test.js +2 -2
- package/test/domain_and_path_test.js +2 -2
- package/test/ietf_test.js +1 -2
- package/test/jar_serialization_test.js +348 -0
- package/test/parsing_test.js +71 -133
- package/test/regression_test.js +15 -0
- package/tough-cookie-deps.tsv +0 -6
package/test/parsing_test.js
CHANGED
|
@@ -40,7 +40,7 @@ vows
|
|
|
40
40
|
.addBatch({
|
|
41
41
|
"simple": {
|
|
42
42
|
topic: function() {
|
|
43
|
-
return Cookie.parse('a=bcd'
|
|
43
|
+
return Cookie.parse('a=bcd') || null;
|
|
44
44
|
},
|
|
45
45
|
"parsed": function(c) { assert.ok(c) },
|
|
46
46
|
"key": function(c) { assert.equal(c.key, 'a') },
|
|
@@ -51,7 +51,7 @@ vows
|
|
|
51
51
|
},
|
|
52
52
|
"with expiry": {
|
|
53
53
|
topic: function() {
|
|
54
|
-
return Cookie.parse('a=bcd; Expires=Tue, 18 Oct 2011 07:05:03 GMT'
|
|
54
|
+
return Cookie.parse('a=bcd; Expires=Tue, 18 Oct 2011 07:05:03 GMT') || null;
|
|
55
55
|
},
|
|
56
56
|
"parsed": function(c) { assert.ok(c) },
|
|
57
57
|
"key": function(c) { assert.equal(c.key, 'a') },
|
|
@@ -63,11 +63,11 @@ vows
|
|
|
63
63
|
},
|
|
64
64
|
"with expiry and path": {
|
|
65
65
|
topic: function() {
|
|
66
|
-
return Cookie.parse('abc="xyzzy!"; Expires=Tue, 18 Oct 2011 07:05:03 GMT; Path=/aBc'
|
|
66
|
+
return Cookie.parse('abc="xyzzy!"; Expires=Tue, 18 Oct 2011 07:05:03 GMT; Path=/aBc') || null;
|
|
67
67
|
},
|
|
68
68
|
"parsed": function(c) { assert.ok(c) },
|
|
69
69
|
"key": function(c) { assert.equal(c.key, 'abc') },
|
|
70
|
-
"value": function(c) { assert.equal(c.value, 'xyzzy!') },
|
|
70
|
+
"value": function(c) { assert.equal(c.value, '"xyzzy!"') },
|
|
71
71
|
"has expires": function(c) {
|
|
72
72
|
assert.ok(c.expires !== Infinity, 'expiry is infinite when it shouldn\'t be');
|
|
73
73
|
assert.equal(c.expires.getTime(), 1318921503000);
|
|
@@ -80,11 +80,11 @@ vows
|
|
|
80
80
|
},
|
|
81
81
|
"with everything": {
|
|
82
82
|
topic: function() {
|
|
83
|
-
return Cookie.parse('abc="xyzzy!"; Expires=Tue, 18 Oct 2011 07:05:03 GMT; Path=/aBc; Domain=example.com; Secure; HTTPOnly; Max-Age=1234; Foo=Bar; Baz'
|
|
83
|
+
return Cookie.parse('abc="xyzzy!"; Expires=Tue, 18 Oct 2011 07:05:03 GMT; Path=/aBc; Domain=example.com; Secure; HTTPOnly; Max-Age=1234; Foo=Bar; Baz') || null;
|
|
84
84
|
},
|
|
85
85
|
"parsed": function(c) { assert.ok(c) },
|
|
86
86
|
"key": function(c) { assert.equal(c.key, 'abc') },
|
|
87
|
-
"value": function(c) { assert.equal(c.value, 'xyzzy!') },
|
|
87
|
+
"value": function(c) { assert.equal(c.value, '"xyzzy!"') },
|
|
88
88
|
"has expires": function(c) {
|
|
89
89
|
assert.ok(c.expires !== Infinity, 'expiry is infinite when it shouldn\'t be');
|
|
90
90
|
assert.equal(c.expires.getTime(), 1318921503000);
|
|
@@ -100,57 +100,35 @@ vows
|
|
|
100
100
|
assert.equal(c.extensions[1], 'Baz');
|
|
101
101
|
}
|
|
102
102
|
},
|
|
103
|
-
"invalid expires": {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
assert.ok(c);
|
|
108
|
-
assert.equal(c.expires, Infinity);
|
|
109
|
-
}
|
|
103
|
+
"invalid expires": function() {
|
|
104
|
+
var c = Cookie.parse("a=b; Expires=xyzzy");
|
|
105
|
+
assert.ok(c);
|
|
106
|
+
assert.equal(c.expires, Infinity);
|
|
110
107
|
},
|
|
111
|
-
"zero max-age": {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
assert.ok(c);
|
|
116
|
-
assert.equal(c.maxAge, 0);
|
|
117
|
-
}
|
|
108
|
+
"zero max-age": function() {
|
|
109
|
+
var c = Cookie.parse("a=b; Max-Age=0");
|
|
110
|
+
assert.ok(c);
|
|
111
|
+
assert.equal(c.maxAge, 0);
|
|
118
112
|
},
|
|
119
|
-
"negative max-age": {
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
assert.ok(c);
|
|
124
|
-
assert.equal(c.maxAge, -1);
|
|
125
|
-
}
|
|
113
|
+
"negative max-age": function() {
|
|
114
|
+
var c = Cookie.parse("a=b; Max-Age=-1");
|
|
115
|
+
assert.ok(c);
|
|
116
|
+
assert.equal(c.maxAge, -1);
|
|
126
117
|
},
|
|
127
|
-
"empty domain": {
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
assert.ok(c);
|
|
132
|
-
assert.equal(c.domain, null);
|
|
133
|
-
}
|
|
118
|
+
"empty domain": function() {
|
|
119
|
+
var c = Cookie.parse("a=b; domain=");
|
|
120
|
+
assert.ok(c);
|
|
121
|
+
assert.equal(c.domain, null);
|
|
134
122
|
},
|
|
135
|
-
"dot domain": {
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
assert.ok(c);
|
|
140
|
-
assert.equal(c.domain, null);
|
|
141
|
-
}
|
|
123
|
+
"dot domain": function() {
|
|
124
|
+
var c = Cookie.parse("a=b; domain=.");
|
|
125
|
+
assert.ok(c);
|
|
126
|
+
assert.equal(c.domain, null);
|
|
142
127
|
},
|
|
143
|
-
"uppercase domain": {
|
|
144
|
-
"
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
assert.equal(c.domain, 'example.com');
|
|
148
|
-
},
|
|
149
|
-
"non-strict lowercases": function() {
|
|
150
|
-
var c = Cookie.parse("a=b; domain=EXAMPLE.COM");
|
|
151
|
-
assert.ok(c);
|
|
152
|
-
assert.equal(c.domain, 'example.com');
|
|
153
|
-
}
|
|
128
|
+
"uppercase domain": function() {
|
|
129
|
+
var c = Cookie.parse("a=b; domain=EXAMPLE.COM");
|
|
130
|
+
assert.ok(c);
|
|
131
|
+
assert.equal(c.domain, 'example.com');
|
|
154
132
|
},
|
|
155
133
|
"trailing dot in domain": {
|
|
156
134
|
topic: function() {
|
|
@@ -159,21 +137,15 @@ vows
|
|
|
159
137
|
"has the domain": function(c) { assert.equal(c.domain,"example.com.") },
|
|
160
138
|
"but doesn't validate": function(c) { assert.equal(c.validate(),false) }
|
|
161
139
|
},
|
|
162
|
-
"empty path": {
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
assert.ok(c);
|
|
167
|
-
assert.equal(c.path, null);
|
|
168
|
-
}
|
|
140
|
+
"empty path": function() {
|
|
141
|
+
var c = Cookie.parse("a=b; path=");
|
|
142
|
+
assert.ok(c);
|
|
143
|
+
assert.equal(c.path, null);
|
|
169
144
|
},
|
|
170
|
-
"no-slash path": {
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
assert.ok(c);
|
|
175
|
-
assert.equal(c.path, null);
|
|
176
|
-
}
|
|
145
|
+
"no-slash path": function() {
|
|
146
|
+
var c = Cookie.parse("a=b; path=xyzzy");
|
|
147
|
+
assert.ok(c);
|
|
148
|
+
assert.equal(c.path, null);
|
|
177
149
|
},
|
|
178
150
|
"trailing semi-colons after path": {
|
|
179
151
|
topic: function () {
|
|
@@ -182,11 +154,7 @@ vows
|
|
|
182
154
|
"c=d;;;;"
|
|
183
155
|
];
|
|
184
156
|
},
|
|
185
|
-
"
|
|
186
|
-
assert.ok(!Cookie.parse(t[0], true));
|
|
187
|
-
assert.ok(!Cookie.parse(t[1], true));
|
|
188
|
-
},
|
|
189
|
-
"non-strict": function (t) {
|
|
157
|
+
"strips semi-colons": function (t) {
|
|
190
158
|
var c1 = Cookie.parse(t[0]);
|
|
191
159
|
var c2 = Cookie.parse(t[1]);
|
|
192
160
|
assert.ok(c1);
|
|
@@ -194,21 +162,15 @@ vows
|
|
|
194
162
|
assert.equal(c1.path, '/');
|
|
195
163
|
}
|
|
196
164
|
},
|
|
197
|
-
"secure-with-value": {
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
assert.ok(c);
|
|
202
|
-
assert.equal(c.secure, true);
|
|
203
|
-
}
|
|
165
|
+
"secure-with-value": function() {
|
|
166
|
+
var c = Cookie.parse("a=b; Secure=xyzzy");
|
|
167
|
+
assert.ok(c);
|
|
168
|
+
assert.equal(c.secure, true);
|
|
204
169
|
},
|
|
205
|
-
"httponly-with-value": {
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
assert.ok(c);
|
|
210
|
-
assert.equal(c.httpOnly, true);
|
|
211
|
-
}
|
|
170
|
+
"httponly-with-value": function() {
|
|
171
|
+
var c = Cookie.parse("a=b; HttpOnly=xyzzy");
|
|
172
|
+
assert.ok(c);
|
|
173
|
+
assert.equal(c.httpOnly, true);
|
|
212
174
|
},
|
|
213
175
|
"garbage": {
|
|
214
176
|
topic: function() {
|
|
@@ -296,61 +258,37 @@ vows
|
|
|
296
258
|
"httponly": function(c) { assert.ok(c.httpOnly) }
|
|
297
259
|
},
|
|
298
260
|
"spaces in value": {
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
return Cookie.parse('a=one two three',true) || null;
|
|
302
|
-
},
|
|
303
|
-
"did not parse": function(c) { assert.isNull(c) }
|
|
261
|
+
topic: function() {
|
|
262
|
+
return Cookie.parse('a=one two three',false) || null;
|
|
304
263
|
},
|
|
305
|
-
"
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
"value": function(c) { assert.equal(c.value, 'one two three') },
|
|
312
|
-
"no path": function(c) { assert.equal(c.path, null) },
|
|
313
|
-
"no domain": function(c) { assert.equal(c.domain, null) },
|
|
314
|
-
"no extensions": function(c) { assert.ok(!c.extensions) }
|
|
315
|
-
}
|
|
264
|
+
"parsed": function(c) { assert.ok(c) },
|
|
265
|
+
"key": function(c) { assert.equal(c.key, 'a') },
|
|
266
|
+
"value": function(c) { assert.equal(c.value, 'one two three') },
|
|
267
|
+
"no path": function(c) { assert.equal(c.path, null) },
|
|
268
|
+
"no domain": function(c) { assert.equal(c.domain, null) },
|
|
269
|
+
"no extensions": function(c) { assert.ok(!c.extensions) }
|
|
316
270
|
},
|
|
317
271
|
"quoted spaces in value": {
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
return Cookie.parse('a="one two three"',true) || null;
|
|
321
|
-
},
|
|
322
|
-
"did not parse": function(c) { assert.isNull(c) }
|
|
272
|
+
topic: function() {
|
|
273
|
+
return Cookie.parse('a="one two three"',false) || null;
|
|
323
274
|
},
|
|
324
|
-
"
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
"value": function(c) { assert.equal(c.value, '"one two three"') },
|
|
331
|
-
"no path": function(c) { assert.equal(c.path, null) },
|
|
332
|
-
"no domain": function(c) { assert.equal(c.domain, null) },
|
|
333
|
-
"no extensions": function(c) { assert.ok(!c.extensions) }
|
|
334
|
-
}
|
|
275
|
+
"parsed": function(c) { assert.ok(c) },
|
|
276
|
+
"key": function(c) { assert.equal(c.key, 'a') },
|
|
277
|
+
"value": function(c) { assert.equal(c.value, '"one two three"') },
|
|
278
|
+
"no path": function(c) { assert.equal(c.path, null) },
|
|
279
|
+
"no domain": function(c) { assert.equal(c.domain, null) },
|
|
280
|
+
"no extensions": function(c) { assert.ok(!c.extensions) }
|
|
335
281
|
},
|
|
336
282
|
"non-ASCII in value": {
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
return Cookie.parse('farbe=weiß',true) || null;
|
|
340
|
-
},
|
|
341
|
-
"did not parse": function(c) { assert.isNull(c) }
|
|
283
|
+
topic: function() {
|
|
284
|
+
return Cookie.parse('farbe=weiß',false) || null;
|
|
342
285
|
},
|
|
343
|
-
"
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
"value": function(c) { assert.equal(c.value, 'weiß') },
|
|
350
|
-
"no path": function(c) { assert.equal(c.path, null) },
|
|
351
|
-
"no domain": function(c) { assert.equal(c.domain, null) },
|
|
352
|
-
"no extensions": function(c) { assert.ok(!c.extensions) }
|
|
353
|
-
}
|
|
286
|
+
"parsed": function(c) { assert.ok(c) },
|
|
287
|
+
"key": function(c) { assert.equal(c.key, 'farbe') },
|
|
288
|
+
"value": function(c) { assert.equal(c.value, 'weiß') },
|
|
289
|
+
"no path": function(c) { assert.equal(c.path, null) },
|
|
290
|
+
"no domain": function(c) { assert.equal(c.domain, null) },
|
|
291
|
+
"no extensions": function(c) { assert.ok(!c.extensions) }
|
|
354
292
|
}
|
|
355
293
|
})
|
|
356
294
|
.export(module);
|
package/test/regression_test.js
CHANGED
|
@@ -125,4 +125,19 @@ vows
|
|
|
125
125
|
}
|
|
126
126
|
}
|
|
127
127
|
})
|
|
128
|
+
.addBatch({
|
|
129
|
+
"tough-cookie throws exception on malformed URI (GH-32)": {
|
|
130
|
+
topic: function () {
|
|
131
|
+
var url = "http://www.example.com/?test=100%";
|
|
132
|
+
var cj = new CookieJar();
|
|
133
|
+
|
|
134
|
+
cj.setCookieSync("Test=Test", url);
|
|
135
|
+
|
|
136
|
+
return cj.getCookieStringSync(url);
|
|
137
|
+
},
|
|
138
|
+
"cookies are set": function (cookieStr) {
|
|
139
|
+
assert.strictEqual(cookieStr, "Test=Test");
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
})
|
|
128
143
|
.export(module);
|
package/tough-cookie-deps.tsv
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
async (0.1.18) MIT (http://github.com/caolan/async/raw/master/LICENSE) node_modules/async/package.json
|
|
2
|
-
diff (1.0.8) BSD (http://github.com/kpdecker/jsdiff/blob/master/LICENSE) node_modules/vows/node_modules/diff/package.json
|
|
3
|
-
eyes (0.1.8) MIT License (https://spdx.org/licenses/MIT) node_modules/vows/node_modules/eyes/package.json
|
|
4
|
-
punycode (1.0.0) MIT (http://mths.be/mit) node_modules/punycode/package.json
|
|
5
|
-
tough-cookie (0.12.1) MIT License (https://spdx.org/licenses/MIT) package.json
|
|
6
|
-
vows (0.7.0) MIT License (https://spdx.org/licenses/MIT) node_modules/vows/LICENSE
|