Enhance property access validation in Struct decoding (#6126)

This commit is contained in:
Tarik Gul
2025-04-11 14:36:32 +03:00
committed by GitHub
parent cf7e2f01ac
commit 311cbe5fee
+5 -3
View File
@@ -43,7 +43,7 @@ function decodeStructFromObject (registry: Registry, [Types, keys]: Definition,
} else if (typeofMap) {
assign = jsonKey && value.get(jsonKey);
} else {
assign = jsonKey && value[jsonKey] as unknown;
assign = jsonKey && Object.prototype.hasOwnProperty.call(value, jsonKey) ? value[jsonKey] as unknown : undefined;
if (isUndefined(assign)) {
if (isUndefined(jsonObj)) {
@@ -52,11 +52,13 @@ function decodeStructFromObject (registry: Registry, [Types, keys]: Definition,
jsonObj = {};
for (let e = 0, ecount = entries.length; e < ecount; e++) {
jsonObj[stringCamelCase(entries[e][0])] = entries[e][1];
if (Object.prototype.hasOwnProperty.call(value, entries[e][0])) {
jsonObj[stringCamelCase(entries[e][0])] = entries[e][1];
}
}
}
assign = jsonKey && jsonObj[jsonKey];
assign = jsonKey && Object.prototype.hasOwnProperty.call(jsonObj, jsonKey) ? jsonObj[jsonKey] : undefined;
}
}