From e830fa26e3dbd68e4ac9de695c433d07741d7d91 Mon Sep 17 00:00:00 2001 From: tablatronix <807787+tablatronix@users.noreply.github.com> Date: Fri, 11 Mar 2022 00:04:21 -0600 Subject: [PATCH] Adding a data attribute for ssid for input value so it has nothing to do with the html , and can have different encoding, we could also just use IDs but scan cannot change, or use bssid #1370 --- WiFiManager.cpp | 7 ++++--- WiFiManager.h | 2 +- strings_en.h | 6 ++++-- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/WiFiManager.cpp b/WiFiManager.cpp index 4b15506..8f5d49d 100644 --- a/WiFiManager.cpp +++ b/WiFiManager.cpp @@ -1562,7 +1562,8 @@ String WiFiManager::WiFiManager::getScanItemOut(){ // Serial.println(WiFi.BSSIDstr(indices[i])); continue; // No idea why I am seeing these, lets just skip them for now } - item.replace(FPSTR(T_v), htmlEntities(WiFi.SSID(indices[i]))); // ssid no encoding + item.replace(FPSTR(T_V), htmlEntities(WiFi.SSID(indices[i]))); // ssid no encoding + item.replace(FPSTR(T_v), htmlEntities(WiFi.SSID(indices[i]),true)); // ssid no encoding if(tok_e) item.replace(FPSTR(T_e), encryptionTypeStr(enc_type)); if(tok_r) item.replace(FPSTR(T_r), (String)rssiperc); // rssi percentage 0-100 if(tok_R) item.replace(FPSTR(T_R), (String)WiFi.RSSI(indices[i])); // rssi db @@ -3298,11 +3299,11 @@ boolean WiFiManager::validApPassword(){ * @param string str string to replace entities * @return string encoded string */ -String WiFiManager::htmlEntities(String str) { - // str.replace(" "," "); +String WiFiManager::htmlEntities(String str, bool whitespace) { str.replace("&","&"); str.replace("<","<"); str.replace(">",">"); + if(whitespace) str.replace(" "," "); // str.replace("-","–"); // str.replace("\"","""); // str.replace("/": "/"); diff --git a/WiFiManager.h b/WiFiManager.h index 641f88e..4d5b948 100644 --- a/WiFiManager.h +++ b/WiFiManager.h @@ -384,7 +384,7 @@ class WiFiManager void debugPlatformInfo(); // helper for html - String htmlEntities(String str); + String htmlEntities(String str, bool whitespace = false); // set the country code for wifi settings, CN void setCountry(String cc); diff --git a/strings_en.h b/strings_en.h index 09ab44a..bd71d58 100644 --- a/strings_en.h +++ b/strings_en.h @@ -24,7 +24,7 @@ const char HTTP_HEAD_START[] PROGMEM = "" "{v}"; const char HTTP_SCRIPT[] PROGMEM = ""; // @todo add button states, disable on click , show ack , spinner etc @@ -33,6 +33,7 @@ const char HTTP_HEAD_END[] PROGMEM = "

\n", // MENU_WIFI "

\n", // MENU_WIFINOSCAN @@ -50,7 +51,7 @@ const char * const HTTP_PORTAL_MENU[] PROGMEM = { const char HTTP_PORTAL_OPTIONS[] PROGMEM = ""; const char HTTP_ITEM_QI[] PROGMEM = ""; // rssi icons const char HTTP_ITEM_QP[] PROGMEM = "
{r}%
"; // rssi percentage {h} = hidden showperc pref -const char HTTP_ITEM[] PROGMEM = "
{v}{qi}{qp}
"; // {q} = HTTP_ITEM_QI, {r} = HTTP_ITEM_QP +const char HTTP_ITEM[] PROGMEM = "
{v}{qi}{qp}
"; // {q} = HTTP_ITEM_QI, {r} = HTTP_ITEM_QP // const char HTTP_ITEM[] PROGMEM = "
{v} {R} {r}% {q} {e}
"; // test all tokens const char HTTP_FORM_START[] PROGMEM = "
"; @@ -301,6 +302,7 @@ const char T_1[] PROGMEM = "{1}"; // @token 1 const char T_2[] PROGMEM = "{2}"; // @token 2 const char T_3[] PROGMEM = "{3}"; // @token 2 const char T_v[] PROGMEM = "{v}"; // @token v +const char T_V[] PROGMEM = "{V}"; // @token v const char T_I[] PROGMEM = "{I}"; // @token I const char T_i[] PROGMEM = "{i}"; // @token i const char T_n[] PROGMEM = "{n}"; // @token n