Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
urlencode quotes in value Strings before sending
- replace " with %22 - decoding is done browser side Saving Strings from the config pages with quotes to EEPROM is not a problem nor using them in your Sketch. However when sending them with other values in a json String to the browser(config pages) these extra quotes break the json format. This is why we now urlencode the quotes before sending. The config page js scripts take care of decoding.
- Loading branch information
c42ab03
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested the change and it does fix the problem with double quotes in the value. However in the process of testing I found the both line breaks and tabs were also causing problems. Looking at the code, the value is being embedding in a JSON object as a string value. Based on this I was able modify your change slightly to escape the value as a JSON string and now double quotes, line breaks and tabs are working properly.
// urlencode " in value | replace " with %22
String value = (*fieldStruct[i].varPointer);
// value.replace("\"", "%22");
value.replace("\\", "\\\\");
value.replace("\"", "\\\"");
value.replace("\n", "\\n");
value.replace("\r", "\\r");
value.replace("\t", "\\t");
value.replace("\b", "\\b");
value.replace("\f", "\\f");
c42ab03
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes like it!
On devices like the esp it's always a challange(memory wise) to balance how far to go. These additions make sense. I beleave @CwlBroeders is prepairing a pull request as we type.