From 9e7be254c2d7b261cb7c84b425884f1f1c899862 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Sun, 6 Jul 2025 15:13:52 +0200 Subject: [PATCH] Revert "Add internal function 'WSContentSendRaw_P' (#23641)" This reverts commit 912cb15beb8015212a80d8369a98332d58b1f05e. --- .../xdrv_01_9_webserver.ino | 29 ++++++++----------- .../xdrv_23_zigbee_7_5_map.ino | 2 +- .../xdrv_50_filesystem.ino | 2 +- .../xdrv_52_3_berry_tasmota.ino | 2 +- .../xdrv_52_3_berry_webserver.ino | 2 +- 5 files changed, 16 insertions(+), 21 deletions(-) diff --git a/tasmota/tasmota_xdrv_driver/xdrv_01_9_webserver.ino b/tasmota/tasmota_xdrv_driver/xdrv_01_9_webserver.ino index 92ec2ace9..dac97866e 100644 --- a/tasmota/tasmota_xdrv_driver/xdrv_01_9_webserver.ino +++ b/tasmota/tasmota_xdrv_driver/xdrv_01_9_webserver.ino @@ -882,7 +882,7 @@ void WSContentFlush(void) { /*-------------------------------------------------------------------------------------------*/ void _WSContentSendBufferChunk(const char* content) { - int len = strlen_P(content); + int len = strlen(content); if (len < CHUNKED_BUFFER_SIZE) { // Append chunk buffer with small content Web.chunk_buffer += content; len = Web.chunk_buffer.length(); @@ -890,9 +890,8 @@ void _WSContentSendBufferChunk(const char* content) { if (len >= CHUNKED_BUFFER_SIZE) { // Either content or chunk buffer is oversize WSContentFlush(); // Send chunk buffer before possible content oversize } - len = strlen_P(content); - if (len >= CHUNKED_BUFFER_SIZE) { // Content is oversize - _WSContentSend(content, len); // Send content + if (strlen(content) >= CHUNKED_BUFFER_SIZE) { // Content is oversize + _WSContentSend(content); // Send content } } @@ -913,19 +912,15 @@ void WSContentSend(const char* content, size_t size) { /*-------------------------------------------------------------------------------------------*/ -void WSContentSendRaw_P(const char* content) { // Content sent without formatting - if (nullptr == content || !strlen_P(content)) { return; } - WSContentSeparator(2); // Print separator on next WSContentSeparator(1) - _WSContentSendBufferChunk(content); -} - -/*-------------------------------------------------------------------------------------------*/ - void _WSContentSendBuffer(bool decimal, const char * formatP, va_list arg) { char* content = ext_vsnprintf_malloc_P(formatP, arg); if (content == nullptr) { return; } // Avoid crash int len = strlen(content); + if (0 == len) { return; } // No content + + WSContentSeparator(2); // Print separator on next WSContentSeparator(1) + if (decimal && (D_DECIMAL_SEPARATOR[0] != '.')) { for (uint32_t i = 0; i < len; i++) { if ('.' == content[i]) { @@ -934,7 +929,7 @@ void _WSContentSendBuffer(bool decimal, const char * formatP, va_list arg) { } } - WSContentSendRaw_P(content); + _WSContentSendBufferChunk(content); free(content); } @@ -1014,14 +1009,14 @@ void WSContentSendStyle_P(const char* formatP, ...) { WebColor(COL_CONSOLE_TEXT) // --c_csltxt ); - WSContentSendRaw_P(HTTP_HEAD_STYLE1); - WSContentSendRaw_P(HTTP_HEAD_STYLE2); + WSContentSend_P(PSTR("%s"), HTTP_HEAD_STYLE1); + WSContentSend_P(PSTR("%s"), HTTP_HEAD_STYLE2); #ifdef USE_WEB_STATUS_LINE_WIFI - WSContentSendRaw_P(HTTP_HEAD_STYLE_WIFI); + WSContentSend_P(PSTR("%s"), HTTP_HEAD_STYLE_WIFI); #endif #if defined(USE_ZIGBEE) || defined(USE_LORAWAN_BRIDGE) - WSContentSendRaw_P(HTTP_HEAD_STYLE_ZIGBEE); + WSContentSend_P(HTTP_HEAD_STYLE_ZIGBEE); #endif // USE_ZIGBEE if (formatP != nullptr) { // This uses char strings. Be aware of sending %% if % is needed diff --git a/tasmota/tasmota_xdrv_driver/xdrv_23_zigbee_7_5_map.ino b/tasmota/tasmota_xdrv_driver/xdrv_23_zigbee_7_5_map.ino index 5ca76e9f4..7320f71e2 100644 --- a/tasmota/tasmota_xdrv_driver/xdrv_23_zigbee_7_5_map.ino +++ b/tasmota/tasmota_xdrv_driver/xdrv_23_zigbee_7_5_map.ino @@ -159,7 +159,7 @@ void Z_Mapper::dumpInternals(void) const { const char *fname = device.friendlyName; if (fname != nullptr) { - WSContentSendRaw_P(EscapeJSONString(fname).c_str()); + WSContentSend_P(PSTR("%s"), EscapeJSONString(fname).c_str()); } else { WSContentSend_P(PSTR("0x%04X"), device.shortaddr); } diff --git a/tasmota/tasmota_xdrv_driver/xdrv_50_filesystem.ino b/tasmota/tasmota_xdrv_driver/xdrv_50_filesystem.ino index b18b1e6a2..ff911f63e 100644 --- a/tasmota/tasmota_xdrv_driver/xdrv_50_filesystem.ino +++ b/tasmota/tasmota_xdrv_driver/xdrv_50_filesystem.ino @@ -1773,7 +1773,7 @@ void UfsEditor(void) { AddLog(LOG_LEVEL_DEBUG_MORE, PSTR(D_LOG_UFS "UfsEditor: read=%d"), l); if (l < 0) { break; } buf[l] = '\0'; - WSContentSendRaw_P(HtmlEscape((char*)buf).c_str()); + WSContentSend_P(PSTR("%s"), HtmlEscape((char*)buf).c_str()); filelen -= l; } fp.close(); diff --git a/tasmota/tasmota_xdrv_driver/xdrv_52_3_berry_tasmota.ino b/tasmota/tasmota_xdrv_driver/xdrv_52_3_berry_tasmota.ino index 934af0c96..0cd9c964c 100644 --- a/tasmota/tasmota_xdrv_driver/xdrv_52_3_berry_tasmota.ino +++ b/tasmota/tasmota_xdrv_driver/xdrv_52_3_berry_tasmota.ino @@ -800,7 +800,7 @@ extern "C" { const char *msg = be_tostring(vm, 2); be_pop(vm, top); // avoid Error be_top is non zero message #ifdef USE_WEBSERVER - WSContentSendRaw_P(msg); + WSContentSend_P(PSTR("%s"), msg); #endif // USE_WEBSERVER be_return_nil(vm); // Return nil when something goes wrong } diff --git a/tasmota/tasmota_xdrv_driver/xdrv_52_3_berry_webserver.ino b/tasmota/tasmota_xdrv_driver/xdrv_52_3_berry_webserver.ino index a931aceca..0853eb75a 100644 --- a/tasmota/tasmota_xdrv_driver/xdrv_52_3_berry_webserver.ino +++ b/tasmota/tasmota_xdrv_driver/xdrv_52_3_berry_webserver.ino @@ -249,7 +249,7 @@ extern "C" { } else { html = (const char*) be_tocomptr(vm, 1); } - WSContentSendRaw_P(html); + WSContentSend_P(PSTR("%s"), html); be_return_nil(vm); } be_raise(vm, kTypeError, nullptr);