Skip to content

Commit

Permalink
Fix ruby 1.8 compatibility, and beef up the javascript escaping
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremyolliver committed Nov 11, 2012
1 parent ab6f161 commit 9f40d90
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/google_visualization.rb
Expand Up @@ -145,13 +145,15 @@ def debugging?

def escape(s)
if s
s.gsub(/(?<!\\)'/, "\\'")
ERB::Util.json_escape(s)
end
end

def escape_id(id)
if id
id.gsub(/["'\s]/, "_")
# Let's be extra strict and validate for characters allowed in HTML id attribute.
# Allow word characters (letters and underscores), digits, dashes, colons and periods.
id.gsub(/[^\w\d-\:\.]/, "_")
end
end

Expand Down

0 comments on commit 9f40d90

Please sign in to comment.