From e2c6818d3d064be46373b8ffb82ec9a521b96afb Mon Sep 17 00:00:00 2001 From: universam1 Date: Wed, 14 Feb 2018 22:37:47 +0100 Subject: [PATCH] HTML encode special character in configuration forms #126 --- README.md | 1 + pio/lib/Globals/Globals.h | 2 +- pio/src/iSpindel.cpp | 34 +++++++++++++++++++++++++++++----- 3 files changed, 31 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 3372463c..44130e93 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,7 @@ Check out *IOT DEVICE PULLS ITS WEIGHT IN HOME BREWING* at http://hackaday.com/2 ## News +> 14.02.2018 Firmware 5.8.1: HTML encode special character in configuration forms, allows displaying the passwort correctly > 09.02.2018 Firmware 5.8.0: Transmitting the Wifi strength RSSI to insight of the reception > 07.02.2018 Firmware 5.7.1: Allow longer sleep intervals longer up to 99999s == 27 days > 03.02.2018 Firmware 5.7.0: Introduce Factory Reset feature diff --git a/pio/lib/Globals/Globals.h b/pio/lib/Globals/Globals.h index a12aad51..10a773c1 100644 --- a/pio/lib/Globals/Globals.h +++ b/pio/lib/Globals/Globals.h @@ -21,7 +21,7 @@ extern Ticker flasher; // defines go here -#define FIRMWAREVERSION "5.8.0" +#define FIRMWAREVERSION "5.8.1" #define API_FHEM true diff --git a/pio/src/iSpindel.cpp b/pio/src/iSpindel.cpp index 8060d2d2..9173120d 100644 --- a/pio/src/iSpindel.cpp +++ b/pio/src/iSpindel.cpp @@ -312,6 +312,30 @@ String urlencode(String str) return encodedString; } +String htmlencode(String str) +{ + String encodedstr = ""; + char c; + uint8_t b; + + for (int i = 0; i < str.length(); i++) + { + c = str.charAt(i); + + if (isalnum(c)) + { + encodedstr += c; + } + else + { + encodedstr += "&#"; + encodedstr += String((uint8_t)c); + encodedstr += ';'; + } + } + return encodedstr; +} + bool startConfiguration() { @@ -325,11 +349,11 @@ bool startConfiguration() WiFiManagerParameter custom_api("selAPI", "selAPI", String(my_api).c_str(), 20, TYPE_HIDDEN, WFM_NO_LABEL); - WiFiManagerParameter custom_name("name", "iSpindel Name", my_name, + WiFiManagerParameter custom_name("name", "iSpindel Name", htmlencode(my_name).c_str(), TKIDSIZE); WiFiManagerParameter custom_sleep("sleep", "Update Intervall (s)", String(my_sleeptime).c_str(), 6, TYPE_NUMBER); - WiFiManagerParameter custom_token("token", "Token", my_token, + WiFiManagerParameter custom_token("token", "Token", htmlencode(my_token).c_str(), TKIDSIZE); WiFiManagerParameter custom_server("server", "Server Address", my_server, TKIDSIZE); @@ -356,11 +380,11 @@ bool startConfiguration() wifiManager.addParameter(&custom_url); WiFiManagerParameter custom_polynom_lbl("
"); wifiManager.addParameter(&custom_polynom_lbl); - WiFiManagerParameter custom_polynom("POLYN", "Polynominal", my_polynominal, 70, WFM_NO_LABEL); + WiFiManagerParameter custom_polynom("POLYN", "Polynominal", htmlencode(my_polynominal).c_str(), 70, WFM_NO_LABEL); wifiManager.addParameter(&custom_polynom); - wifiManager.setConfSSID(my_ssid); - wifiManager.setConfPSK(urlencode(my_psk)); + wifiManager.setConfSSID(htmlencode(my_ssid)); + wifiManager.setConfPSK(htmlencode(my_psk)); SerialOut(F("started Portal")); wifiManager.startConfigPortal("iSpindel");