This project is archived and is in readonly mode.

#2831 ✓resolved
Martin Kleppmann

[PATCH] ActiveSupport::JSON.decode explodes in certain circumstances

Reported by Martin Kleppmann | June 24th, 2009 @ 06:44 PM

ActiveSupport::JSON.decode has problems with JSON strings which include both quoted slashes and dates:

>> ActiveSupport::JSON.decode('{"r":"http:\/\/foo","d":"2004-06-24"}')
IndexError: index 38 out of string
    from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.2/lib/active_support/json/decoding.rb:75:in `[]='
    from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.2/lib/active_support/json/decoding.rb:75:in `convert_json_to_yaml'
    from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.2/lib/active_support/json/decoding.rb:75:in `each'
    from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.2/lib/active_support/json/decoding.rb:75:in `convert_json_to_yaml'
    from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.2/lib/active_support/json/decoding.rb:12:in `decode'

Whether quoted slashes are actually valid JSON is not completely clear, but they are definitely seen in the wild -- the JSON gem's Hash#to_json method produces them, for example.

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