DevTools: Replaced unsafe hasOwnProperty() calls (#17768)

DevTools previously called  in several places with user-defined values. This could lead to runtime errors if those values had an overriden  attribute. This commit replaces those callse with  instead.

New test cases have been added.
This commit is contained in:
Brian Vaughn
2020-01-03 09:34:12 -08:00
committed by GitHub
parent 5d3d71b1dd
commit 7e2ab87a61
10 changed files with 266 additions and 45 deletions
@@ -78,7 +78,7 @@ export default function KeyValue({
type:
value !== null &&
typeof value === 'object' &&
value.hasOwnProperty(meta.type)
hasOwnProperty.call(value, meta.type)
? value[meta.type]
: typeof value,
},
@@ -136,8 +136,8 @@ export default function KeyValue({
</div>
);
} else if (
value.hasOwnProperty(meta.type) &&
!value.hasOwnProperty(meta.unserializable)
hasOwnProperty.call(value, meta.type) &&
!hasOwnProperty.call(value, meta.unserializable)
) {
children = (
<div
+1 -1
View File
@@ -93,7 +93,7 @@ export function createRegExp(string: string): RegExp {
}
export function getMetaValueLabel(data: Object): string | null {
if (data.hasOwnProperty(meta.preview_long)) {
if (hasOwnProperty.call(data, meta.preview_long)) {
return data[meta.preview_long];
} else {
return formatDataForPreview(data, true);