From 7b0eb87685a7d64b550f6cc8e5c8242de44288e6 Mon Sep 17 00:00:00 2001 From: Koen Kanters Date: Sat, 9 Jan 2021 15:13:29 +0100 Subject: [PATCH] Don't allow friendly_name to start with. https://github.com/Koenkk/zigbee2mqtt/commit/d7c74ca3ad65dc8cc0366d321c5494c4f3b7a51b --- lib/util/utils.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/util/utils.js b/lib/util/utils.js index fb51e2b7..7ed39df2 100644 --- a/lib/util/utils.js +++ b/lib/util/utils.js @@ -197,7 +197,7 @@ function validateFriendlyName(name) { } if (name.length === 0) errors.push(`friendly_name shoud atleast be 1 char long`); - if (name.endsWith('/')) errors.push(`friendly_name is not allowed to end with /`); + if (name.endsWith('/') || name.startsWith('/')) errors.push(`friendly_name is not allowed to end or start with /`); if (name.endsWith(String.fromCharCode(0))) errors.push(`friendly_name is not allowed to contain null char`); if (endpointNames.includes(name)) errors.push(`Following friendly_name are not allowed: '${endpointNames}'`); if (name.match(/.*\/\d*$/)) errors.push(`Friendly name cannot end with a "/DIGIT" ('${name}')`);