Browse Source

Properly escape JSON

pull/34/head
SQ5RWU 12 months ago
parent
commit
151571e15a
  1. 10
      src/taskWebServer.cpp

10
src/taskWebServer.cpp

@ -38,12 +38,10 @@ void sendGzipHeader() { server.sendHeader("Content-Encoding", "gzip"); }
String jsonEscape(String s){
s.replace("\\", "\\\\");
s.replace("\"", "\\\"");
s.replace("\n", "\\n");
s.replace("\r", "\\r");
s.replace("\b", "\\b");
s.replace("\f", "\\f");
s.replace("\n", "\\n");
s.replace("\t", "\\t");
s.replace("\x7f", "\\\x7f");
for(char i = 0; i < 0x1f; i++){
s.replace(String(i), "\\" + String((char)i));
}
return s;
}

Loading…
Cancel
Save