This project is archived and is in readonly mode.

#1485 ✓stale
Vlad R

json_escape eats away double quotes

Reported by Vlad R | November 26th, 2008 @ 08:53 PM | in 3.x

json_escape("hello".to_json) will incorrectly produce 'hello' instead of '"hello"'

rails/actionpack/lib/action_view/template_handlers/erb.rb or rails/actionpack/lib/action_view/erb/util.rb

def json_escape(s)
  s.to_s.gsub(/[&"><]/) { |special| JSON_ESCAPE[special] }
end

should probably read:

def json_escape(s)
  s.to_s.gsub(/[&><]/) { |special| JSON_ESCAPE[special] }
end

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Referenced by

Pages