diff --git a/src/WebApi_mqtt.cpp b/src/WebApi_mqtt.cpp index 08bc913..92eb789 100644 --- a/src/WebApi_mqtt.cpp +++ b/src/WebApi_mqtt.cpp @@ -141,6 +141,13 @@ void WebApiMqttClass::onMqttAdminPost(AsyncWebServerRequest* request) return; } + if (root[F("mqtt_topic")].as().indexOf(' ') != -1) { + retMsg[F("message")] = F("Topic must not contain space characters!"); + response->setLength(); + request->send(response); + return; + } + if (root[F("mqtt_port")].as() == 0 || root[F("mqtt_port")].as() > 65535) { retMsg[F("message")] = F("Port must be a number between 1 and 65535!"); response->setLength(); @@ -155,6 +162,13 @@ void WebApiMqttClass::onMqttAdminPost(AsyncWebServerRequest* request) return; } + if (root[F("mqtt_lwt_topic")].as().indexOf(' ') != -1) { + retMsg[F("message")] = F("LWT topic must not contain space characters!"); + response->setLength(); + request->send(response); + return; + } + if (root[F("mqtt_lwt_online")].as().length() > MQTT_MAX_LWTVALUE_STRLEN) { retMsg[F("message")] = F("LWT online value must not longer then " STR(MQTT_MAX_LWTVALUE_STRLEN) " characters!"); response->setLength(); @@ -183,6 +197,13 @@ void WebApiMqttClass::onMqttAdminPost(AsyncWebServerRequest* request) request->send(response); return; } + + if (root[F("mqtt_hass_topic")].as().indexOf(' ') != -1) { + retMsg[F("message")] = F("Hass topic must not contain space characters!"); + response->setLength(); + request->send(response); + return; + } } }