Subject: | Double-quote escaping for HTML labels |
Hello,
GraphViz2 v1.10 escapes double-quotes in HTML labels, where they are
valid characters needed for specifying attributes. Attached is a failing
test case for scripts/html.labels.pl and a patch for GraphViz2.pm that
only escapes double quotes if the label is not an HTML label.
Thank you for your work on this module!
Cheers,
Fitz Elliott
Subject: | dont-escape-html-dquotes.patch |
diff --git a/lib/GraphViz2.pm b/lib/GraphViz2.pm
index 9847624..1fe085f 100644
--- a/lib/GraphViz2.pm
+++ b/lib/GraphViz2.pm
@@ -131,7 +131,12 @@ sub add_node
{
# HTML labels affect this code.
- $arg{label} =~ s#([[\]{}"])#\\$1#g;
+ $arg{label} =~ s#([[\]{}])#\\$1#g;
+
+ if ($arg{label} !~ m/^</) # if not an HTML label
+ {
+ $arg{label} =~ s/"/\\"/g;
+ }
}
$$node{$name}{attributes} = {%arg};
diff --git a/scripts/html.labels.pl b/scripts/html.labels.pl
index 9371a92..c210563 100644
--- a/scripts/html.labels.pl
+++ b/scripts/html.labels.pl
@@ -43,7 +43,7 @@ $graph -> add_node(name => 'Carnegie', color => 'red');
$graph -> default_node(style => 'rounded');
-$graph -> add_node(name => 'Murrumbeena', shape => 'box', color => 'green', label => '<Murrumbeena<br/>Victoria<br/>Australia>');
+$graph -> add_node(name => 'Murrumbeena', shape => 'box', color => 'green', label => '<Murrumbeena<br/><FONT COLOR="#99999">Victoria</FONT><br/>Australia>');
$graph -> add_node(name => 'Oakleigh', shape => 'record', color => 'blue', label => ['West Oakleigh', 'East Oakleigh']);
$graph -> add_edge(from => 'Murrumbeena', to => 'Carnegie', arrowsize => 2, label => '<Bike<br/>Train<br/>Stroll>');