Fix handling of quotes and backslashes in property sheet values

This commit is contained in:
Max Brunsfeld 2018-12-11 13:48:28 -08:00
parent e343c83446
commit 4055a29aa9
2 changed files with 5 additions and 7 deletions

View file

@ -63,11 +63,9 @@ class CodeGenerator {
for (const auto &pair : property_set) {
if (!first) add(",");
first = false;
add("\"");
add(pair.first);
add("\":\"");
add(pair.second);
add("\"");
add_string(pair.first);
add(":");
add_string(pair.second);
}
add("}");
}
@ -94,7 +92,7 @@ class CodeGenerator {
void add_string(const string &s) {
add("\"");
for (const char c : s) {
if (c == '"') add("\\");
if (c == '"' || c == '\\') add("\\");
add(c);
}
add("\"");

View file

@ -162,7 +162,7 @@ pair<SyntaxGrammar, CompileError> flatten_grammar(const InitialSyntaxGrammar &gr
}
result.word_token = grammar.word_token;
return {result, CompileError::none()};
}