Skip to content

Commit

Permalink
Merge pull request from GHSA-624g-8qjg-8qxf
Browse files Browse the repository at this point in the history
  • Loading branch information
edmundhung committed Apr 23, 2024
1 parent 59156d7 commit 4819d51
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions packages/conform-dom/formdata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,13 @@ export function getPaths(name: string | undefined): Array<string | number> {
return name
.split(/\.|(\[\d*\])/)
.reduce<Array<string | number>>((result, segment) => {
if (typeof segment !== 'undefined' && segment !== '') {
if (
typeof segment !== 'undefined' &&
segment !== '' &&
segment !== '__proto__' &&
segment !== 'constructor' &&
segment !== 'prototype'
) {
if (segment.startsWith('[') && segment.endsWith(']')) {
const index = segment.slice(1, -1);

Expand Down Expand Up @@ -114,7 +120,11 @@ export function setValue(
const nextKey = paths[index + 1];
const newValue =
index != lastIndex
? pointer[key] ?? (typeof nextKey === 'number' ? [] : {})
? Object.hasOwn(pointer, key)
? pointer[key]
: typeof nextKey === 'number'
? []
: {}
: valueFn(pointer[key]);

pointer[key] = newValue;
Expand All @@ -133,6 +143,10 @@ export function getValue(target: unknown, name: string): unknown {
break;
}

if (!Object.hasOwn(pointer, path)) {
return;
}

if (isPlainObject(pointer) && typeof path === 'string') {
pointer = pointer[path];
} else if (Array.isArray(pointer) && typeof path === 'number') {
Expand Down

0 comments on commit 4819d51

Please sign in to comment.