From 092bfd872429ab3279f90eb7e724e36ccb6b35ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20B=C3=B6sch-Plepelits?= Date: Thu, 18 Aug 2022 21:20:57 +0100 Subject: [PATCH] CustomCategory: check that category can be parsed as object --- src/customCategory.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/customCategory.js b/src/customCategory.js index ae37c21f..2fe6fc7b 100644 --- a/src/customCategory.js +++ b/src/customCategory.js @@ -46,7 +46,11 @@ class CustomCategoryRepository { return global.alert(e) } - if (Object.is(data) && !('name' in data)) { + if (data && typeof data !== 'object') { + callback(new Error('Data can not be parsed into an object')) + } + + if (!data.name) { data.name = 'Custom ' + id.substr(0, 6) } @@ -358,6 +362,10 @@ function customCategoryTest (value) { return e } + if (!data || typeof data !== 'object') { + return new Error('Data can not be parsed into an object') + } + const fields = ['feature', 'memberFeature'] for (let i1 = 0; i1 < fields.length; i1++) { const k1 = fields[i1]