Permalink
Browse files

Added a quick test to show the failing text escaping and a hackish pa…

…tch just for legends

Signed-off-by: Matt Aimonetti <mattaimonetti@gmail.com>
  • Loading branch information...
1 parent 9bbcff3 commit caa337888394c2d17f321c5edeb6d198e200af10 @der-flo der-flo committed with mattetti Apr 22, 2009
Showing with 9 additions and 1 deletion.
  1. +2 −1 lib/gchart.rb
  2. +7 −0 spec/gchart_spec.rb
View
3 lib/gchart.rb
@@ -3,6 +3,7 @@
require 'gchart/theme'
require "open-uri"
require "uri"
+require "cgi"
class Gchart
@@ -238,7 +239,7 @@ def set_legend
return set_labels if @type == :pie || @type == :pie_3d || @type == :meter
if @legend.is_a?(Array)
- "chdl=#{@legend.map{|label| "#{label}"}.join('|')}"
+ "chdl=#{@legend.map{|label| "#{CGI::escape(label)}"}.join('|')}"
else
"chdl=#{@legend}"
end
View
7 spec/gchart_spec.rb
@@ -227,6 +227,13 @@
@chart.include?(Gchart.jstize("chdl=first+data+set+label|n+data+set+label")).should be_true
end
+ it "should escape text values in url" do
+ title = 'Chart & Title'
+ legend = ['first data & set label', 'n data set label']
+ chart = Gchart.line(:title => title, :legend => legend)
+ chart.include?(Gchart.jstize("chdl=first+data+%26+set+label|n+data+set+label")).should be_true
+ end
+
it "should be able to have one legend" do
chart = Gchart.line(:legend => 'legend label')
chart.include?("chdl=legend+label").should be_true

0 comments on commit caa3378

Please sign in to comment.