Fix passwords that contain =

Fixes #1119.

Apparently `split` does not work the way I'd expect.
This commit is contained in:
Asher 2019-10-28 13:44:43 -05:00
parent 3a9b032c72
commit 83ff31b620
No known key found for this signature in database
GPG Key ID: D63C1EF81242354A

View File

@ -440,8 +440,11 @@ export abstract class Server {
const cookies: { [key: string]: string } = {}; const cookies: { [key: string]: string } = {};
if (request.headers.cookie) { if (request.headers.cookie) {
request.headers.cookie.split(";").forEach((keyValue) => { request.headers.cookie.split(";").forEach((keyValue) => {
const [key, value] = keyValue.split("=", 2); // key=value -> { [key]: value } and key -> { [key]: "" }
cookies[key.trim()] = decodeURI(value); const index = keyValue.indexOf("=");
const key = keyValue.substring(0, index).trim();
const value = keyValue.substring(index + 1);
cookies[key || value] = decodeURI(key ? value : "");
}); });
} }
return cookies as T; return cookies as T;