mirror of
https://gitlab.com/Binaryify/neteasecloudmusicapi.git
synced 2025-05-23 22:37:41 +08:00
Polynomial regular expression
A regular expression that can require polynomial time to match may be vulnerable to denial-of-service attacks.
This commit is contained in:
parent
801fc5a7ea
commit
ff5ace990c
3
app.js
3
app.js
@ -40,7 +40,8 @@ app.use((req, res, next) => {
|
||||
// cookie parser
|
||||
app.use((req, res, next) => {
|
||||
req.cookies = {}
|
||||
;(req.headers.cookie || '').split(/\s*;\s*/).forEach((pair) => {
|
||||
//;(req.headers.cookie || '').split(/\s*;\s*/).forEach((pair) => { // Polynomial regular expression //
|
||||
;(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()] =
|
||||
|
Loading…
x
Reference in New Issue
Block a user