mirror of https://github.com/arendst/Tasmota.git
Shrink HtmlEscape code size
Shrink HtmlEscape code size by 200 bytes
This commit is contained in:
parent
22663fc10c
commit
0c2d1323e7
|
@ -1294,15 +1294,23 @@ void ModuleSaveSettings(void)
|
|||
|
||||
/*-------------------------------------------------------------------------------------------*/
|
||||
|
||||
String htmlEscape(String s)
|
||||
{
|
||||
s.replace("&", "&");
|
||||
s.replace("<", "<");
|
||||
s.replace(">", ">");
|
||||
s.replace("\"", """);
|
||||
s.replace("'", "'");
|
||||
s.replace("/", "/");
|
||||
return s;
|
||||
const char kUnescapeCode[] = "&><\"\'";
|
||||
const char kEscapeCode[] PROGMEM = "&|>|<|"|'";
|
||||
|
||||
String HtmlEscape(const String unescaped) {
|
||||
char escaped[10];
|
||||
uint16_t ulen = unescaped.length();
|
||||
String result = "";
|
||||
for (size_t i = 0; i < ulen; i++) {
|
||||
char c = unescaped[i];
|
||||
char *p = strchr(kUnescapeCode, c);
|
||||
if (p != nullptr) {
|
||||
result += GetTextIndexed(escaped, sizeof(escaped), p - kUnescapeCode, kEscapeCode);
|
||||
} else {
|
||||
result += c;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void HandleWifiConfiguration(void)
|
||||
|
@ -1373,7 +1381,7 @@ void HandleWifiConfiguration(void)
|
|||
if (minimum_signal_quality == -1 || minimum_signal_quality < quality) {
|
||||
uint8_t auth = WiFi.encryptionType(indices[i]);
|
||||
WSContentSend_P(PSTR("<div><a href='#p' onclick='c(this)'>%s</a> (%d) <span class='q'>%s %d%%</span></div>"),
|
||||
htmlEscape(WiFi.SSID(indices[i])).c_str(),
|
||||
HtmlEscape(WiFi.SSID(indices[i])).c_str(),
|
||||
WiFi.channel(indices[i]),
|
||||
(ENC_TYPE_WEP == auth) ? D_WEP : (ENC_TYPE_TKIP == auth) ? D_WPA_PSK : (ENC_TYPE_CCMP == auth) ? D_WPA2_PSK : (ENC_TYPE_AUTO == auth) ? D_AUTO : "",
|
||||
quality
|
||||
|
|
Loading…
Reference in New Issue