assaf/zombie — Issue #225: Invalid "set-cookie" header crashes zombie.js
Author: jasonlfunk
Created: 2011-12-13 03:03:39+00:00
State: open

When visiting a certian website, it is passing me an invalid cookie in the "set-cookies" response cookie. This is causing zombie.js to choke and die.

```
['HttpOnly',
'COOKIE_SID=T0cfTm1NtGTWP8tP168nyxbWQG8NDfZZQZ3xNR201mP31lDBMQHr!314216265;secure;path=/;domain=.wellsfargo.com;',
'HttpOnly=;path=;domain=;',
'OB_SO_ORIGIN=source=alternate;path=/;domain=.wellsfargo.com;',
'wfacookie=O12122011065853674097981;expires=Mon, 12-Dec-2016 10:58:53 GMT;path=/;domain=.wellsfargo.com;',
'BRAND_COOKIE=;secure;expires=Thu, 01-Jan-1970 09:00:00 GMT;path=/;domain=.wellsfargo.com;',
'ISD_DAS_COOKIE=70JneMxFlxAXEGZTAQAAAAAAEpgQAGaW9sVGxyNcsD7NH9pJ1ZrGpKFB9J3IhnSXJHtq8GXNrkMteA==;path=/;domain=.wellsfargo.com;' ]
```
As you can see, the first cookie is "HttpOnly" which is not a valid cookie and therefore when zombie.js tries to deserialize it zombie chokes and dies.

```
/Users/jasonlfunk/node_modules/zombie/lib/zombie/cookies.coffee:22
_ref = first.match(/(.*?)=(.*)/), _ = _ref[0], name = _ref[1], value = _re
^
TypeError: Cannot read property '0' of null
at /Users/jasonlfunk/node_modules/zombie/lib/zombie/cookies.coffee:22:47
at Access.update (/Users/jasonlfunk/node_modules/zombie/lib/zombie/cookies.coffee:152:18)
at IncomingMessage. (/Users/jasonlfunk/node_modules/zombie/lib/zombie/resources.coffee:239:19)
at IncomingMessage.emit (events.js:88:20)
at HTTPParser.onMessageComplete (http.js:137:23)
at CleartextStream.ondata (http.js:1125:24)
at CleartextStream._push (tls.js:363:27)
at SecurePair.cycle (tls.js:679:20)
at EncryptedStream.write (tls.js:122:13)
at Socket.ondata (stream.js:38:26)
```