Commit 21f2eb6c authored by bgeron's avatar bgeron Committed by Commit bot

[turbolizer] Also escape backslashes in JSON strings.

BUG=

Review-Url: https://codereview.chromium.org/2255263002
Cr-Commit-Position: refs/heads/master@{#38748}
parent 4598d913
......@@ -85,7 +85,7 @@ static const char* SafeMnemonic(Node* node) {
class Escaped {
public:
explicit Escaped(const std::ostringstream& os,
const char* escaped_chars = "<>|{}")
const char* escaped_chars = "<>|{}\\")
: str_(os.str()), escaped_chars_(escaped_chars) {}
friend std::ostream& operator<<(std::ostream& os, const Escaped& e) {
......@@ -134,11 +134,11 @@ class JSONGraphNodeWriter {
node->op()->PrintTo(label, Operator::PrintVerbosity::kSilent);
node->op()->PrintTo(title, Operator::PrintVerbosity::kVerbose);
node->op()->PrintPropsTo(properties);
os_ << "{\"id\":" << SafeId(node) << ",\"label\":\"" << Escaped(label, "\"")
<< "\""
<< ",\"title\":\"" << Escaped(title, "\"") << "\""
os_ << "{\"id\":" << SafeId(node) << ",\"label\":\""
<< Escaped(label, "\"\\") << "\""
<< ",\"title\":\"" << Escaped(title, "\"\\") << "\""
<< ",\"live\": " << (live_.IsLive(node) ? "true" : "false")
<< ",\"properties\":\"" << Escaped(properties, "\"") << "\"";
<< ",\"properties\":\"" << Escaped(properties, "\"\\") << "\"";
IrOpcode::Value opcode = node->opcode();
if (IrOpcode::IsPhiOpcode(opcode)) {
os_ << ",\"rankInputs\":[0," << NodeProperties::FirstControlIndex(node)
......@@ -170,7 +170,7 @@ class JSONGraphNodeWriter {
Type* type = NodeProperties::GetType(node);
std::ostringstream type_out;
type->PrintTo(type_out);
os_ << ",\"type\":\"" << Escaped(type_out, "\"") << "\"";
os_ << ",\"type\":\"" << Escaped(type_out, "\"\\") << "\"";
}
os_ << "}";
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment