#24953 [Bgs]: Image_GraphViz nonstandard label chars

From: Date: Wed, 06 Aug 2003 16:39:52 +0000
Subject: #24953 [Bgs]: Image_GraphViz nonstandard label chars
References: 1  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-19329@lists.php.net to get a copy of this message
ID: 24953 User updated by: php-bug-NOSPAM-2003-aug-05 at ryandesign dot de -Summary: Linux and windows -Reported By: nicos@php.net +Reported By: php-bug-NOSPAM-2003-aug-05 at ryandesign dot de Status: Bogus Bug Type: PEAR related Operating System: Irrevelant PHP Version: Irrelevant New Comment: Ok, perhaps I, the programmer, know about the escaping rules, but my users entering data into MySQL tables don't know them. I don't plan to store the node and edge labels in my database in escaped form; this means I'd have to call some escaping function on the data before passing it to addNode et al. Perhaps the Image_GraphViz class could provide a function to properly escape the string? But I really do disagree with your decision. Consider the case that I pass a label with a quote to addNode. I pass the quote so that it is not escaped. Image_GraphViz blindly adds it to the graph without escaping it, which causes that quote to end the label right there and proceed with the rest of the label as if it were commands. This is a Bad Thing. And since there is never a time when you will want to do it, why make the programmer jump through additional hoops to do the Right Thing when it could be done automatically by the class? Previous Comments: ------------------------------------------------------------------------ [2003-08-06 11:26:45] nicos@php.net It looks bogus to me. The class can't know you want to escape. Use \n. and yes you *should* know. ------------------------------------------------------------------------ [2003-08-05 12:04:37] php-bug-NOSPAM-2003-aug-05 at ryandesign dot de Description: ------------ If I use the chars quote, backslash, or newline in labels passed to Image_GraphViz's functions addNode et al, the resulting GraphViz markup is syntactically invalid and the graph it produces does not look visually like what I intended it to look like. Reproduce code: --------------- <?php require "Image/GraphViz.php"; $g = new Image_GraphViz(); $g->addNode(1, array('label' => 'Node "One" 2nd line')); $g->image('png'); ?> Expected result: ---------------- Expected: graph with one node whose label spans 2 lines and looks like this: Node "One" 2nd line Actual result: -------------- Actual: graph with one node whose label spans only one line and looks like this: Node I can get the desired result by instead writing... $g->addNode(1, array('label' => 'Node \"One\"\n2nd line')); ...but as the user of the Image_GraphViz class I shouldn't have to know GraphViz's escaping rules. The class should handle this for me -- probably in its parse() function. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=24953&edit=1

« previous php.pear.dev (#19329) next »