Skip to content

Commit e5c9360

Browse files
fix: optimize the cookie parsing logic for incoming cookies
1 parent 8cd073e commit e5c9360

File tree

5 files changed

+46
-38
lines changed

5 files changed

+46
-38
lines changed

lib/build/recipe/oauth2provider/constants.js

Lines changed: 10 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/build/recipe/session/constants.js

Lines changed: 15 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/build/recipe/session/cookieAndHeaders.js

Lines changed: 2 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/build/recipe/webauthn/constants.js

Lines changed: 17 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/ts/recipe/session/cookieAndHeaders.ts

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -286,24 +286,8 @@ function parseCookieStringFromRequestHeaderAllowingDuplicates(cookieString: stri
286286
const cookiePairs = cookieString.split(";");
287287

288288
for (const cookiePair of cookiePairs) {
289-
const [name, value] = cookiePair
290-
.trim()
291-
.split("=")
292-
.map((part) => {
293-
try {
294-
return decodeURIComponent(part);
295-
} catch (e) {
296-
// this is there in case the cookie value is not encoded. This can happe
297-
// if the user has set their own cookie in a different format.
298-
return part;
299-
}
300-
});
301-
302-
if (cookies.hasOwnProperty(name)) {
303-
cookies[name].push(value);
304-
} else {
305-
cookies[name] = [value];
306-
}
289+
const [name, value] = cookiePair.trim().split("=");
290+
cookies.hasOwnProperty(name) ? cookies[name].push(value) : (cookies[name] = [value]);
307291
}
308292

309293
return cookies;

0 commit comments

Comments
 (0)