From 330c94f4f3437036a50a57f1b3f5ca7e991c2230 Mon Sep 17 00:00:00 2001 From: Pim van den Berg Date: Sat, 27 Aug 2011 18:22:24 +0200 Subject: type: escape colons in filenames used in rrd commandline A colon ':' in a legend argument will mark the end of the legend: http://oss.oetiker.ch/rrdtool/doc/rrdgraph_graph.en.html#INOTES_on_legend_arguments Reported-by: Benjamin Dupuis --- type/Default.class.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'type/Default.class.php') diff --git a/type/Default.class.php b/type/Default.class.php index cc1818a..eaf2e8e 100644 --- a/type/Default.class.php +++ b/type/Default.class.php @@ -98,6 +98,10 @@ class Type_Default { return $c['r'].$c['g'].$c['b']; } + function rrd_escape($value) { + return str_replace(':', '\:', $value); + } + function rrd_files() { $files = $this->get_filenames(); @@ -234,9 +238,9 @@ class Type_Default { $i=0; foreach ($this->tinstances as $tinstance) { foreach ($this->data_sources as $ds) { - $rrdgraph[] = sprintf('DEF:min_%s="%s":%s:MIN', crc32hex($sources[$i]), $this->files[$tinstance], $ds); - $rrdgraph[] = sprintf('DEF:avg_%s="%s":%s:AVERAGE', crc32hex($sources[$i]), $this->files[$tinstance], $ds); - $rrdgraph[] = sprintf('DEF:max_%s="%s":%s:MAX', crc32hex($sources[$i]), $this->files[$tinstance], $ds); + $rrdgraph[] = sprintf('DEF:min_%s="%s":%s:MIN', crc32hex($sources[$i]), $this->rrd_escape($this->files[$tinstance]), $ds); + $rrdgraph[] = sprintf('DEF:avg_%s="%s":%s:AVERAGE', crc32hex($sources[$i]), $this->rrd_escape($this->files[$tinstance]), $ds); + $rrdgraph[] = sprintf('DEF:max_%s="%s":%s:MAX', crc32hex($sources[$i]), $this->rrd_escape($this->files[$tinstance]), $ds); $i++; } } -- cgit v1.1