Browse Source

Properly escape JSON

pull/34/head
SQ5RWU 12 months ago
parent
commit
9740b33e5b
  1. 9
      src/taskWebServer.cpp

9
src/taskWebServer.cpp

@ -36,8 +36,13 @@ void sendCacheHeader() { server.sendHeader("Cache-Control", "max-age=3600"); }
void sendGzipHeader() { server.sendHeader("Content-Encoding", "gzip"); }
String jsonEscape(String s){
s.replace("\"", "\\\"");
s.replace("\\", "\\\\");
s.replace("\\", "\\\\");
s.replace("\"", "\\\"");
s.replace("\n", "\\n");
s.replace("\b", "\\b");
s.replace("\f", "\\f");
s.replace("\n", "\\n");
s.replace("\t", "\\t");
return s;
}

Loading…
Cancel
Save