Skip to content

Commit

Permalink
fix(parseQuery): prevent possible prototype pollution
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed May 11, 2021
1 parent 7655066 commit f4be854
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ export function parseQuery (paramsStr: string = ''): QueryObject {
const s = (param.match(/([^=]+)=?(.*)/) || [])
if (s.length < 2) { continue }
const key = decode(s[1])
if (key === '__proto__' || key === 'constructor') {
continue
}
const value = decodeQueryValue(s[2] || '')
if (obj[key]) {
if (Array.isArray(obj[key])) {
Expand Down

0 comments on commit f4be854

Please sign in to comment.