spire-io/shred — Issue #17: Cannot handle malformed cookies
Author: thelastnode
Created: 2012-01-29 13:04:39+00:00
State: open

I'm getting an exception when using shred, on [line 40](https://github.com/spire-io/shred/blob/master/lib/shred/response.js#L40):

/app/node_modules/shred/node_modules/cookiejar/cookiejar.js:72
, key=pair[1].trim().toLowerCase()
TypeError: Cannot read property '1' of null
at Cookie.parse (/app/node_modules/shred/node_modules/cookiejar/cookiejar.js:72:17)
at new Cookie (/app/node_modules/shred/node_modules/cookiejar/cookiejar.js:28:16)
at Cookie (/app/node_modules/shred/node_modules/cookiejar/cookiejar.js:32:16)
at CookieJar.setCookies (/app/node_modules/shred/node_modules/cookiejar/cookiejar.js:217:16)
at Object. (/app/node_modules/shred/lib/shred/response.js:40:23)
at ClientRequest. (/app/node_modules/shred/lib/shred/request.js:340:16)
at ClientRequest.emit (events.js:67:17)
at HTTPParser.onIncoming (http.js:1225:11)
at HTTPParser.onHeadersComplete (http.js:102:31)
at Socket.ondata (http.js:1124:24)

It's running in a script with thousands of URLs, so I couldn't tell you the URL unfortunately.

The exception occurs because [the pattern the cookie is looking](https://github.com/bmeck/node-cookiejar/blob/master/cookiejar.js#L64) for isn't matched, which means the cookie must be malformed.