Subject: | GraphViz doesn't escape double-quotes in strings |
Date: | Fri, 29 Aug 2014 10:37:40 +0100 |
To: | bug-GraphViz [...] rt.cpan.org |
From: | Brian Candler <b.candler [...] pobox.com> |
[Ubuntu 14.04, libgraphviz-perl 2.14-1, graphviz 2.36.0-0ubuntu3]
Passing a label which contains double-quotes causes graphviz to fail. To
replicate the problem:
--------
use GraphViz;
my $g = GraphViz->new();
$g->add_node(
'name' => '10.10.3.0/24',
'fillcolor' => '#ff6666',
'URL' => 'ip.html?id=19',
'label' => '10.10.3.0/24\\n"Router Group 3"',
'shape' => 'record'
);
print $g->as_debug;
$g->as_png("/tmp/out.png");
--------
Results:
digraph test {
ratio="fill";
node1 [URL="ip.html?id=19", fillcolor="#ff6666",
label="10.10.3.0/24\n"Router Group 3"", shape="record"];
}
Warning: <stdin>: syntax error in line 3 near 'Group'
and a zero-byte PNG file is produced.
According to http://www.graphviz.org/content/dot-language, double-quotes
can be escaped by preceding with backslash. I've tested it and it works:
e.g. manually create the following content and feed it to dot:
digraph test {
ratio="fill";
node1 [URL="ip.html?id=19", fillcolor="#ff6666",
label="10.10.3.0/24\n\"Router Group 3\"", shape="record"];
}