Closed ghazel closed 14 years ago
This is a mixing of concerns / an MVC violation, the strings returned by to_json shouldn't know anything about the existence of the rails_xss output buffers or how they work.
If you want this to work you'll have to do:
<% javascript_tag do %>
var foo = <%= raw "foo".to_json %>;
<% end %>
This is expected behaviour
produces:
in the javascript tag.
I believe all json is html safe, no? json escapes:
'&' => '\u0026', '>' => '\u003E', '<' => '\u003C'
. Although I suppose there should be .json_safe? etc, just marking it as html_safe! would avoid this bug.