From 9e57509e25a7d750e7113b1d41f1d3af732ff934 Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Tue, 27 Oct 2020 19:40:19 -0400 Subject: Json schema default value improvement (#964) * Ensure value has property before using its value * Add tests --- ext/bg/js/json-schema.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'ext') diff --git a/ext/bg/js/json-schema.js b/ext/bg/js/json-schema.js index adb71fa3..ea1531ab 100644 --- a/ext/bg/js/json-schema.js +++ b/ext/bg/js/json-schema.js @@ -637,7 +637,8 @@ class JsonSchemaValidator { if (propertySchema === null) { continue; } info.valuePush(property, value); info.schemaPush(property, propertySchema); - value[property] = this._getValidValueOrDefault(propertySchema, value[property], info); + const hasValue = Object.prototype.hasOwnProperty.call(value, property); + value[property] = this._getValidValueOrDefault(propertySchema, hasValue ? value[property] : void 0, info); info.schemaPop(); info.valuePop(); } -- cgit v1.2.3