Merge pull request #1315 from syhan/syhan-patch-1

Fix the wrong cookie split regex
This commit is contained in:
binaryify 2021-08-09 10:52:57 +08:00 committed by GitHub
commit 359ca4c538
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

2
app.js
View File

@ -41,7 +41,7 @@ app.use((req, res, next) => {
app.use((req, res, next) => {
req.cookies = {}
//;(req.headers.cookie || '').split(/\s*;\s*/).forEach((pair) => { // Polynomial regular expression //
;(req.headers.cookie || '').split(/^\s+|(?<!\s)\s+$/g).forEach((pair) => {
(req.headers.cookie || '').split(/;\s+|(?<!\s)\s+$/g).forEach((pair) => {
let crack = pair.indexOf('=')
if (crack < 1 || crack == pair.length - 1) return
req.cookies[decodeURIComponent(pair.slice(0, crack)).trim()] =