Skip to content

Commit

Permalink
fix: avoid prototype pollution
Browse files Browse the repository at this point in the history
  • Loading branch information
posva committed Mar 31, 2022
1 parent f23af8e commit e4858f9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/pinia/src/store.ts
Expand Up @@ -59,11 +59,13 @@ function mergeReactiveObjects<T extends StateTree>(
): T {
// no need to go through symbols because they cannot be serialized anyway
for (const key in patchToApply) {
if (!patchToApply.hasOwnProperty(key)) continue
const subPatch = patchToApply[key]
const targetValue = target[key]
if (
isPlainObject(targetValue) &&
isPlainObject(subPatch) &&
target.hasOwnProperty(key) &&
!isRef(subPatch) &&
!isReactive(subPatch)
) {
Expand Down
2 changes: 2 additions & 0 deletions packages/testing/src/testing.ts
Expand Up @@ -139,11 +139,13 @@ function mergeReactiveObjects<T extends StateTree>(
): T {
// no need to go through symbols because they cannot be serialized anyway
for (const key in patchToApply) {
if (!patchToApply.hasOwnProperty(key)) continue
const subPatch = patchToApply[key]
const targetValue = target[key]
if (
isPlainObject(targetValue) &&
isPlainObject(subPatch) &&
target.hasOwnProperty(key) &&
!isRef(subPatch) &&
!isReactive(subPatch)
) {
Expand Down

0 comments on commit e4858f9

Please sign in to comment.