diff --git a/tasmota/xdrv_01_webserver.ino b/tasmota/xdrv_01_webserver.ino index 9be6e28c3..68d53d588 100644 --- a/tasmota/xdrv_01_webserver.ino +++ b/tasmota/xdrv_01_webserver.ino @@ -2843,15 +2843,15 @@ void HandleHttpCommand(void) uint32_t index = curridx; char* line; size_t len; + WSContentFlush(); while (GetLog(TasmotaGlobal.templog_level, &index, &line, &len)) { // [14:49:36.123 MQTT: stat/wemos5/RESULT = {"POWER":"OFF"}] > [{"POWER":"OFF"}] char* JSON = (char*)memchr(line, '{', len); if (JSON) { // Is it a JSON message (and not only [15:26:08 MQT: stat/wemos5/POWER = O]) size_t JSONlen = len - (JSON - line); - if (JSONlen > sizeof(TasmotaGlobal.mqtt_data)) { JSONlen = sizeof(TasmotaGlobal.mqtt_data); } - char stemp[JSONlen]; - strlcpy(stemp, JSON +1, JSONlen -2); - WSContentSend_P(PSTR("%s%s"), (cflg) ? "," : "", stemp); + String stemp = (cflg) ? "," : ""; // Add a comma + stemp.concat(JSON +1, JSONlen -3); // Add a terminating '\0' + Webserver->sendContent(stemp); cflg = true; } } @@ -2928,11 +2928,11 @@ void HandleConsoleRefresh(void) bool cflg = (index); char* line; size_t len; + WSContentFlush(); while (GetLog(Settings.weblog_level, &index, &line, &len)) { - if (len > sizeof(TasmotaGlobal.mqtt_data) -2) { len = sizeof(TasmotaGlobal.mqtt_data); } - char stemp[len +1]; - strlcpy(stemp, line, len); - WSContentSend_P(PSTR("%s%s"), (cflg) ? PSTR("\n") : "", stemp); + String stemp = (cflg) ? "\n" : ""; // Add a newline + stemp.concat(line, len -1); // Add a terminating '\0' + Webserver->sendContent(stemp); cflg = true; } WSContentSend_P(PSTR("}1")); diff --git a/tasmota/xdrv_40_telegram.ino b/tasmota/xdrv_40_telegram.ino index 8abde2d60..5a4ce7545 100644 --- a/tasmota/xdrv_40_telegram.ino +++ b/tasmota/xdrv_40_telegram.ino @@ -299,11 +299,8 @@ String TelegramExecuteCommand(const char *svalue) { char* JSON = (char*)memchr(line, '{', len); if (JSON) { // Is it a JSON message (and not only [15:26:08 MQT: stat/wemos5/POWER = O]) size_t JSONlen = len - (JSON - line); - if (JSONlen > ResponseSize()) { JSONlen = ResponseSize(); } - char stemp[JSONlen]; - strlcpy(stemp, JSON +1, JSONlen -2); if (cflg) { response += F(","); } - response += stemp; + response.concat(JSON +1, JSONlen -3); cflg = true; } } diff --git a/tasmota/xdrv_52_9_berry.ino b/tasmota/xdrv_52_9_berry.ino index f97e5b538..5c6ccca7e 100644 --- a/tasmota/xdrv_52_9_berry.ino +++ b/tasmota/xdrv_52_9_berry.ino @@ -673,11 +673,11 @@ void HandleBerryConsole(void) // bool cflg = (index); // char* line; // size_t len; +// WSContentFlush(); // while (GetLog(Settings.weblog_level, &index, &line, &len)) { -// if (len > sizeof(TasmotaGlobal.mqtt_data) -2) { len = sizeof(TasmotaGlobal.mqtt_data); } -// char stemp[len +1]; -// strlcpy(stemp, line, len); -// WSContentSend_P(PSTR("%s%s"), (cflg) ? PSTR("\n") : "", stemp); +// String stemp = (cflg) ? "\n" : ""; // Add a newline +// stemp.concat(line, len -1); // Add a terminating '\0' +// Webserver->sendContent(stemp); // cflg = true; // } // WSContentSend_P(PSTR("}1"));