From a814cfc3e1a12d4cad452b190228117ecb74d08a Mon Sep 17 00:00:00 2001 From: Vincent LE GOFF Date: Mon, 29 Apr 2019 16:49:50 +0200 Subject: [PATCH] http/cookie: fixing equal character split (denoland/deno_std#368) Original: https://github.com/denoland/deno_std/commit/8503efc8f729cf152a2b03471b3a9d6d93c31197 --- http/cookie.ts | 2 +- http/cookie_test.ts | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/http/cookie.ts b/http/cookie.ts index b7019ae20dccaf..900d2941be2e81 100644 --- a/http/cookie.ts +++ b/http/cookie.ts @@ -79,7 +79,7 @@ export function getCookies(req: ServerRequest): Cookies { for (const kv of c) { const cookieVal = kv.split("="); const key = cookieVal.shift().trim(); - out[key] = cookieVal.join(""); + out[key] = cookieVal.join("="); } return out; } diff --git a/http/cookie_test.ts b/http/cookie_test.ts index ae99b2707b8e80..4b4e2759d4695e 100644 --- a/http/cookie_test.ts +++ b/http/cookie_test.ts @@ -21,6 +21,14 @@ test({ req.headers = new Headers(); req.headers.set("Cookie", "igot=99; problems=but..."); assertEquals(getCookies(req), { igot: "99", problems: "but..." }); + + req.headers = new Headers(); + req.headers.set("Cookie", "PREF=al=en-GB&f1=123; wide=1; SID=123"); + assertEquals(getCookies(req), { + PREF: "al=en-GB&f1=123", + wide: "1", + SID: "123" + }); } });