Skip to content

Commit

Permalink
klass always trusted, but safer pattern
Browse files Browse the repository at this point in the history
  • Loading branch information
ankane committed Jun 4, 2019
1 parent cad8cf9 commit 7d9396c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/chartkick/helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,15 @@ def chartkick_chart(klass, data_source, **options)

# js vars
js_vars = {
type: klass, # don't convert to JSON, but still escape
type: klass.to_json,
id: element_id.to_json,
data: data_source.respond_to?(:chart_json) ? data_source.chart_json : data_source.to_json,
options: options.to_json
}
js_vars.each_key do |k|
js_vars[k] = chartkick_json_escape(js_vars[k])
end
createjs = "new Chartkick.%{type}(%{id}, %{data}, %{options});" % js_vars
createjs = "new Chartkick[%{type}](%{id}, %{data}, %{options});" % js_vars

if defer
js = <<JS
Expand Down

0 comments on commit 7d9396c

Please sign in to comment.