]> git.ipfire.org Git - thirdparty/vuejs/router.git/commitdiff
fix(query): allow arbitrary keys in queries
authorEduardo San Martin Morote <posva13@gmail.com>
Thu, 27 May 2021 13:14:24 +0000 (15:14 +0200)
committerEduardo San Martin Morote <posva13@gmail.com>
Thu, 27 May 2021 13:14:24 +0000 (15:14 +0200)
Revert "fix: do not allow invalid hazardous keys in query (#880)"
This reverts commit ecd52e017ac30fa996d4796974371374f65640d1.

__tests__/parseQuery.spec.ts
src/query.ts

index 7c849bbdf1b9d56a9355596da9938d2ad9123d33..b16c86245e3309843669915f19a28dd6aea649ce 100644 (file)
@@ -85,15 +85,4 @@ describe('parseQuery', () => {
 
     expect('decoding "%"').toHaveBeenWarnedTimes(1)
   })
-
-  it('ignores __proto__', () => {
-    const query = parseQuery('__proto__=1')
-    expect(query.__proto__).toEqual(Object.prototype)
-    expect(query.constructor).toEqual(Object)
-  })
-
-  it('ignores build-in methods', () => {
-    const query = parseQuery('toString=1')
-    expect(query.toString).toEqual(Object.prototype.toString)
-  })
 })
index db951c75e50f4e0e2288c0258f76ce945a8f74e5..357e40da16895b90b70b17a0d706230ba18db11d 100644 (file)
@@ -57,12 +57,6 @@ export function parseQuery(search: string): LocationQuery {
     // allow the = character
     let eqPos = searchParam.indexOf('=')
     let key = decode(eqPos < 0 ? searchParam : searchParam.slice(0, eqPos))
-
-    // this ignores ?__proto__&toString
-    if (Object.prototype.hasOwnProperty(key)) {
-      continue
-    }
-
     let value = eqPos < 0 ? null : decode(searchParam.slice(eqPos + 1))
 
     if (key in query) {