Skip to content

Commit 847aca6

Browse files
Merge pull request #32 from magento-obsessive-owls/PB-718-1.3-develop
[1.3-develop] Update object-path
2 parents 26aace9 + 60d28a5 commit 847aca6

File tree

1 file changed

+13
-2
lines changed
  • app/code/Magento/PageBuilder/view/adminhtml/web/js/resource

1 file changed

+13
-2
lines changed

app/code/Magento/PageBuilder/view/adminhtml/web/js/resource/object-path.js

+13-2
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,15 @@
8383
}, {});
8484
};
8585

86-
function hasShallowProperty(obj, prop) {
87-
return (options.includeInheritedProps || (typeof prop === 'number' && Array.isArray(obj)) || hasOwnProperty(obj, prop))
86+
var hasShallowProperty
87+
if (options.includeInheritedProps) {
88+
hasShallowProperty = function () {
89+
return true
90+
}
91+
} else {
92+
hasShallowProperty = function (obj, prop) {
93+
return (typeof prop === 'number' && Array.isArray(obj)) || hasOwnProperty(obj, prop)
94+
}
8895
}
8996

9097
function getShallowProperty(obj, prop) {
@@ -105,6 +112,10 @@
105112
}
106113
var currentPath = path[0];
107114
var currentValue = getShallowProperty(obj, currentPath);
115+
if (options.includeInheritedProps && (currentPath === '__proto__' ||
116+
(currentPath === 'constructor' && typeof currentValue === 'function'))) {
117+
throw new Error('For security reasons, object\'s magic properties cannot be set')
118+
}
108119
if (path.length === 1) {
109120
if (currentValue === void 0 || !doNotReplace) {
110121
obj[currentPath] = value;

0 commit comments

Comments
 (0)