From 6bf2b59c0e12c80a76f505536537ec06cd07c061 Mon Sep 17 00:00:00 2001 From: Matthias Pfeil Date: Fri, 27 Oct 2023 17:34:47 +0200 Subject: [PATCH] fix(edit): validate MQTT Integration url (#477) Correctly validate MQTT integration Url --- app/scripts/controllers/account.box.edit.mqtt.js | 5 +++-- app/views/account.box.edit.mqtt.html | 10 +++++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/app/scripts/controllers/account.box.edit.mqtt.js b/app/scripts/controllers/account.box.edit.mqtt.js index d86c459c..d6c383e9 100644 --- a/app/scripts/controllers/account.box.edit.mqtt.js +++ b/app/scripts/controllers/account.box.edit.mqtt.js @@ -16,11 +16,12 @@ topic: '', messageFormat: '', decodeOptions: '', - connectionOptions: '' + connectionOptions: '', }; vm.save = save; - + // Inspired by https://regex101.com/r/mIA28O/1 + vm.urlRegEx = /^((mqtt|ws)s?:\/\/)(([^:\s]+):([^:\s]+)@)?([a-zA-Z0-9.-]+)(:\d{1,5})?(\/[^?#\s]*)?$/; activate(); //// diff --git a/app/views/account.box.edit.mqtt.html b/app/views/account.box.edit.mqtt.html index 8d09d144..7dc02ccf 100644 --- a/app/views/account.box.edit.mqtt.html +++ b/app/views/account.box.edit.mqtt.html @@ -22,7 +22,15 @@

{{'EDIT_MQTTOPTIONS'|translate}}
- +