From a20f9b8842c6da6631ae36f62571394053b5c082 Mon Sep 17 00:00:00 2001 From: Timotej Lazar Date: Mon, 24 Aug 2015 12:38:56 +0200 Subject: monkey.graph.graphviz: fix escaping of node labels --- monkey/graph.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/monkey/graph.py b/monkey/graph.py index 20a8a98..a8ad4b0 100644 --- a/monkey/graph.py +++ b/monkey/graph.py @@ -50,7 +50,8 @@ def graphviz(nodes, label=str, pos=None, node_attr=None, edge_attr=None): gv_nodes = {} for node in nodes: gv_nodes[id(node)] = len(gv_nodes) - node_str += '\t{} [label="{}"'.format(gv_nodes[id(node)], label(node).replace('"', '\\"')) + node_label = label(node).replace('\\', '\\\\').replace('"', '\\"') + node_str += '\t{} [label="{}"'.format(gv_nodes[id(node)], node_label) if pos: node_str += ', ' + 'pos="{},{}"'.format(*pos(node)) if node_attr: -- cgit v1.2.1