Subject: | Error: bad label format when quotes in label |
The attached test script reproduces an error encountered when using
GraphViz::DBI. It uses quotes in the label of a node which causes and
error.
Output of the attached script:
Error: bad label format {
digraph test {
graph [ratio=fill];
node [label="\N"];
graph [bb="0,0,54,36"];
test [label="{", table=true, "|field1\lfield2\l}"=true,
shape=record, pos="27,18", rects="0,0,54,36", width="0.75",
height="0.50"];
}
This can be fixed by the following patch:
# diff -u GraphViz.pm.orig GraphViz.pm
--- GraphViz.pm.orig 2008-12-17 10:14:34.000000000 +1300
+++ GraphViz.pm 2008-12-17 10:53:06.000000000 +1300
@@ -1239,7 +1239,7 @@
next if $key =~ /^(to|from|name|cluster|from_port|to_port)$/;
my $value = $thing->{$key};
- $value =~ s|"|\"|g;
+ $value =~ s|"|\\"|g;
$value = '"' . $value . '"'
unless ( $key eq 'label' && $value =~ /^<</ );
$value =~ s|\n|\\n|g;
With this patch applied, output of the test script is:
digraph test {
graph [ratio=fill];
node [label="\N"];
graph [bb="0,0,56,64"];
test [label="{\"table\"|field1\lfield2\l}", shape=record,
pos="28,32", rects="0,40,56,64 0,0,56,40", width="0.78", height="0.89"];
}
Subject: | test.pl |
#!/usr/bin/perl
use strict;
use warnings;
use GraphViz;
my $g = GraphViz->new();
$g->add_node(
name => "test",
shape => 'record',
label => '{"table"|field1\lfield2\l}',
);
print $g->as_text;