diff --git a/tasmota/support.ino b/tasmota/support.ino index 8138e39d9..0d5ce5b94 100644 --- a/tasmota/support.ino +++ b/tasmota/support.ino @@ -58,8 +58,8 @@ void OsWatchTicker(void) // ESP.restart(); // normal reboot // ESP.reset(); // hard reset - // Force an exception to get a stackdump + // ESP32: Guru Meditation Error: Core 0 panic'ed (LoadProhibited). Exception was unhandled. volatile uint32_t dummy; dummy = *((uint32_t*) 0x00000000); (void)dummy; // avoid compiler warning @@ -549,6 +549,38 @@ char* Trim(char* p) return p; } +String UrlEncode(const String& text) { + const char hex[] = "0123456789ABCDEF"; + + String encoded = ""; + int len = text.length(); + int i = 0; + while (i < len) { + char decodedChar = text.charAt(i++); +/* + if (('a' <= decodedChar && decodedChar <= 'z') || + ('A' <= decodedChar && decodedChar <= 'Z') || + ('0' <= decodedChar && decodedChar <= '9') || + ('=' == decodedChar)) { + encoded += decodedChar; + } else { + encoded += '%'; + encoded += hex[decodedChar >> 4]; + encoded += hex[decodedChar & 0xF]; + } +*/ + if ((' ' == decodedChar) || ('+' == decodedChar)) { + encoded += '%'; + encoded += hex[decodedChar >> 4]; + encoded += hex[decodedChar & 0xF]; + } else { + encoded += decodedChar; + } + + } + return encoded; +} + /* char* RemoveAllSpaces(char* p) { diff --git a/tasmota/xdrv_01_webserver.ino b/tasmota/xdrv_01_webserver.ino index 9e55e2ae0..229d9af1d 100644 --- a/tasmota/xdrv_01_webserver.ino +++ b/tasmota/xdrv_01_webserver.ino @@ -2798,40 +2798,6 @@ bool CaptivePortal(void) /*********************************************************************************************/ -String UrlEncode(const String& text) -{ - const char hex[] = "0123456789ABCDEF"; - - String encoded = ""; - int len = text.length(); - int i = 0; - while (i < len) { - char decodedChar = text.charAt(i++); - -/* - if (('a' <= decodedChar && decodedChar <= 'z') || - ('A' <= decodedChar && decodedChar <= 'Z') || - ('0' <= decodedChar && decodedChar <= '9') || - ('=' == decodedChar)) { - encoded += decodedChar; - } else { - encoded += '%'; - encoded += hex[decodedChar >> 4]; - encoded += hex[decodedChar & 0xF]; - } -*/ - if ((' ' == decodedChar) || ('+' == decodedChar)) { - encoded += '%'; - encoded += hex[decodedChar >> 4]; - encoded += hex[decodedChar & 0xF]; - } else { - encoded += decodedChar; - } - - } - return encoded; -} - int WebSend(char *buffer) { // [tasmota] POWER1 ON --> Sends http://tasmota/cm?cmnd=POWER1 ON diff --git a/tasmota/xdrv_40_telegram.ino b/tasmota/xdrv_40_telegram.ino index a96842065..ec230e792 100644 --- a/tasmota/xdrv_40_telegram.ino +++ b/tasmota/xdrv_40_telegram.ino @@ -256,7 +256,7 @@ bool TelegramSendMessage(int32_t chat_id, String text) { bool sent = false; if (text != "") { String _token = SettingsText(SET_TELEGRAM_TOKEN); - String command = "bot" + _token + "/sendMessage?chat_id=" + String(chat_id) + "&text=" + text; + String command = "bot" + _token + "/sendMessage?chat_id=" + String(chat_id) + "&text=" + UrlEncode(text); String response = TelegramConnectToTelegram(command); // AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("TGM: Response %s"), response.c_str());