ladjs / superagent

Ajax for Node.js and browsers (JS HTTP client). Maintained for @forwardemail, @ladjs, @spamscanner, @breejs, @cabinjs, and @lassjs.
https://ladjs.github.io/superagent/
MIT License
16.57k stars 1.33k forks source link

fix(cookies): parse header correctly when merging cookies #1762

Closed wilsonjackson closed 1 year ago

wilsonjackson commented 1 year ago

Fixes a parsing error introduced by an upstream fix in cookiejar: bmeck/node-cookiejar#38

Prior to 2.1.3, cookiejar was incorrectly producing cookie headers containing multiple cookies with no spaces after the separating semicolon. That space is explicitly required in the RFC.

When Supertest merges cookies provided with via .set() with cookies from its internal cookiejar instance, it assumes that incorrect, spaceless format. This results in any cookie names after the first in a given header erroneously containing leading spaces.

I added a test for cookie validity and the fix to split on ; instead of just ;.

Found this issue the same way as #1761, but it's actually unrelated. Fun! 😄

Checklist

titanism commented 1 year ago

v8.0.9 released to npm and GitHub releases

https://github.com/ladjs/superagent/releases/tag/v8.0.9