Fix #45: Dont allow spaces in MQTT topics
This commit is contained in:
parent
4ff6433b90
commit
3789183ca3
@ -141,6 +141,13 @@ void WebApiMqttClass::onMqttAdminPost(AsyncWebServerRequest* request)
|
||||
return;
|
||||
}
|
||||
|
||||
if (root[F("mqtt_topic")].as<String>().indexOf(' ') != -1) {
|
||||
retMsg[F("message")] = F("Topic must not contain space characters!");
|
||||
response->setLength();
|
||||
request->send(response);
|
||||
return;
|
||||
}
|
||||
|
||||
if (root[F("mqtt_port")].as<uint>() == 0 || root[F("mqtt_port")].as<uint>() > 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<String>().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<String>().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<String>().indexOf(' ') != -1) {
|
||||
retMsg[F("message")] = F("Hass topic must not contain space characters!");
|
||||
response->setLength();
|
||||
request->send(response);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user