Skip to content

Commit

Permalink
HTML encode special character in configuration forms
Browse files Browse the repository at this point in the history
  • Loading branch information
universam1 committed Feb 14, 2018
1 parent 1d027d6 commit e2c6818
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 6 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pio/lib/Globals/Globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
extern Ticker flasher;

// defines go here
#define FIRMWAREVERSION "5.8.0"
#define FIRMWAREVERSION "5.8.1"


#define API_FHEM true
Expand Down
34 changes: 29 additions & 5 deletions pio/src/iSpindel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{

Expand All @@ -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);
Expand All @@ -356,11 +380,11 @@ bool startConfiguration()
wifiManager.addParameter(&custom_url);
WiFiManagerParameter custom_polynom_lbl("<hr><label for=\"POLYN\">Gravity conversion<br/>ex. \"0.00438*(tilt)*(tilt) + 0.13647*(tilt) - 6.96\"</label>");
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");
Expand Down

0 comments on commit e2c6818

Please sign in to comment.