From 53cfabdbca993ed59d8cb8ac1a3b7d45ff62d6c0 Mon Sep 17 00:00:00 2001 From: Hadinger Date: Mon, 9 Dec 2019 21:43:30 +0100 Subject: [PATCH] Add RemoveAllSpaces() --- tasmota/support.ino | 17 +++++++++++++++++ tasmota/xdrv_02_mqtt.ino | 12 +----------- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/tasmota/support.ino b/tasmota/support.ino index ef3b8d9ee..3ecc9b179 100644 --- a/tasmota/support.ino +++ b/tasmota/support.ino @@ -377,6 +377,23 @@ char* Trim(char* p) return p; } +char* RemoveAllSpaces(char* p) +{ + // remove any white space from the base64 + char *cursor = p; + uint32_t offset = 0; + while (1) { + *cursor = *(cursor + offset); + if ((' ' == *cursor) || ('\t' == *cursor) || ('\n' == *cursor)) { // if space found, remove this char until end of string + offset++; + } else { + if (0 == *cursor) { break; } + cursor++; + } + } + return p; +} + char* NoAlNumToUnderscore(char* dest, const char* source) { char* write = dest; diff --git a/tasmota/xdrv_02_mqtt.ino b/tasmota/xdrv_02_mqtt.ino index b38607ad7..6d68a346e 100644 --- a/tasmota/xdrv_02_mqtt.ino +++ b/tasmota/xdrv_02_mqtt.ino @@ -1078,17 +1078,7 @@ void CmndTlsKey(void) { memcpy_P(spi_buffer, tls_spi_start, tls_spi_len); // remove any white space from the base64 - char *cursor = XdrvMailbox.data; - uint32_t offset = 0; - while (1) { - *cursor = *(cursor + offset); - if ((' ' == *cursor) || ('\t' == *cursor) || ('\n' == *cursor)) { // if space found, remove this char until end of string - offset++; - } else { - if (0 == *cursor) { break; } - cursor++; - } - } + RemoveAllSpaces(XdrvMailbox.data); // allocate buffer for decoded base64 uint32_t bin_len = decode_base64_length((unsigned char*)XdrvMailbox.data);