Fix #213: Check if topic ends with slash

If this is not the case the subscription to the command topics will fail
This commit is contained in:
Thomas Basler 2022-10-11 22:26:06 +02:00
parent 7ec070f6f9
commit 072a7c7a3d

View File

@ -170,6 +170,13 @@ void WebApiMqttClass::onMqttAdminPost(AsyncWebServerRequest* request)
return; return;
} }
if (!root[F("mqtt_topic")].as<String>().endsWith("/")) {
retMsg[F("message")] = F("Topic must end with slash (/)!");
response->setLength();
request->send(response);
return;
}
if (root[F("mqtt_port")].as<uint>() == 0 || root[F("mqtt_port")].as<uint>() > 65535) { 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!"); retMsg[F("message")] = F("Port must be a number between 1 and 65535!");
response->setLength(); response->setLength();