Skip to content

Commit 4819d51

Browse files
authored
Merge pull request from GHSA-624g-8qjg-8qxf
1 parent 59156d7 commit 4819d51

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

packages/conform-dom/formdata.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,13 @@ export function getPaths(name: string | undefined): Array<string | number> {
3838
return name
3939
.split(/\.|(\[\d*\])/)
4040
.reduce<Array<string | number>>((result, segment) => {
41-
if (typeof segment !== 'undefined' && segment !== '') {
41+
if (
42+
typeof segment !== 'undefined' &&
43+
segment !== '' &&
44+
segment !== '__proto__' &&
45+
segment !== 'constructor' &&
46+
segment !== 'prototype'
47+
) {
4248
if (segment.startsWith('[') && segment.endsWith(']')) {
4349
const index = segment.slice(1, -1);
4450

@@ -114,7 +120,11 @@ export function setValue(
114120
const nextKey = paths[index + 1];
115121
const newValue =
116122
index != lastIndex
117-
? pointer[key] ?? (typeof nextKey === 'number' ? [] : {})
123+
? Object.hasOwn(pointer, key)
124+
? pointer[key]
125+
: typeof nextKey === 'number'
126+
? []
127+
: {}
118128
: valueFn(pointer[key]);
119129

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

146+
if (!Object.hasOwn(pointer, path)) {
147+
return;
148+
}
149+
136150
if (isPlainObject(pointer) && typeof path === 'string') {
137151
pointer = pointer[path];
138152
} else if (Array.isArray(pointer) && typeof path === 'number') {

0 commit comments

Comments
 (0)