Merge pull request #690 from reasonableJP/fix_escaping_json_control_characters

fix for escaping json control characters in graphql
This commit is contained in:
Grahame Grieve 2021-12-18 05:41:15 +11:00 committed by GitHub
commit 1a713d9b85
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 4 deletions

View File

@ -102,8 +102,8 @@ public class Argument {
public void write(StringBuilder b, int indent) throws EGraphQLException, EGraphEngine {
b.append("\"");
for (char ch : name.toCharArray()) {
if (ch == '"') b.append("\"");
else if (ch == '\\') b.append("\\");
if (ch == '"') b.append("\\\"");
else if (ch == '\\') b.append("\\\\");
else if (ch == '\r') b.append("\\r");
else if (ch == '\n') b.append("\\n");
else if (ch == '\t') b.append("\\t");

View File

@ -56,8 +56,8 @@ public class StringValue extends Value {
public void write(StringBuilder b, int indent) {
b.append("\"");
for (char ch : value.toCharArray()) {
if (ch == '"') b.append("\"");
else if (ch == '\\') b.append("\\");
if (ch == '"') b.append("\\\"");
else if (ch == '\\') b.append("\\\\");
else if (ch == '\r') b.append("\\r");
else if (ch == '\n') b.append("\\n");
else if (ch == '\t') b.append("\\t");