[turbolizer] Also escape backslashes in JSON strings.
BUG= Review-Url: https://codereview.chromium.org/2255263002 Cr-Commit-Position: refs/heads/master@{#38748}
This commit is contained in:
parent
4598d9139e
commit
21f2eb6c48
@ -85,7 +85,7 @@ static const char* SafeMnemonic(Node* node) {
|
|||||||
class Escaped {
|
class Escaped {
|
||||||
public:
|
public:
|
||||||
explicit Escaped(const std::ostringstream& os,
|
explicit Escaped(const std::ostringstream& os,
|
||||||
const char* escaped_chars = "<>|{}")
|
const char* escaped_chars = "<>|{}\\")
|
||||||
: str_(os.str()), escaped_chars_(escaped_chars) {}
|
: str_(os.str()), escaped_chars_(escaped_chars) {}
|
||||||
|
|
||||||
friend std::ostream& operator<<(std::ostream& os, const Escaped& e) {
|
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(label, Operator::PrintVerbosity::kSilent);
|
||||||
node->op()->PrintTo(title, Operator::PrintVerbosity::kVerbose);
|
node->op()->PrintTo(title, Operator::PrintVerbosity::kVerbose);
|
||||||
node->op()->PrintPropsTo(properties);
|
node->op()->PrintPropsTo(properties);
|
||||||
os_ << "{\"id\":" << SafeId(node) << ",\"label\":\"" << Escaped(label, "\"")
|
os_ << "{\"id\":" << SafeId(node) << ",\"label\":\""
|
||||||
<< "\""
|
<< Escaped(label, "\"\\") << "\""
|
||||||
<< ",\"title\":\"" << Escaped(title, "\"") << "\""
|
<< ",\"title\":\"" << Escaped(title, "\"\\") << "\""
|
||||||
<< ",\"live\": " << (live_.IsLive(node) ? "true" : "false")
|
<< ",\"live\": " << (live_.IsLive(node) ? "true" : "false")
|
||||||
<< ",\"properties\":\"" << Escaped(properties, "\"") << "\"";
|
<< ",\"properties\":\"" << Escaped(properties, "\"\\") << "\"";
|
||||||
IrOpcode::Value opcode = node->opcode();
|
IrOpcode::Value opcode = node->opcode();
|
||||||
if (IrOpcode::IsPhiOpcode(opcode)) {
|
if (IrOpcode::IsPhiOpcode(opcode)) {
|
||||||
os_ << ",\"rankInputs\":[0," << NodeProperties::FirstControlIndex(node)
|
os_ << ",\"rankInputs\":[0," << NodeProperties::FirstControlIndex(node)
|
||||||
@ -170,7 +170,7 @@ class JSONGraphNodeWriter {
|
|||||||
Type* type = NodeProperties::GetType(node);
|
Type* type = NodeProperties::GetType(node);
|
||||||
std::ostringstream type_out;
|
std::ostringstream type_out;
|
||||||
type->PrintTo(type_out);
|
type->PrintTo(type_out);
|
||||||
os_ << ",\"type\":\"" << Escaped(type_out, "\"") << "\"";
|
os_ << ",\"type\":\"" << Escaped(type_out, "\"\\") << "\"";
|
||||||
}
|
}
|
||||||
os_ << "}";
|
os_ << "}";
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user