Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #9579 (closed defect: fixed)

Opened 1 year ago

Last modified 1 year ago

ActiveSupport::JSON.decode fails with nested quotes and commas

Reported by: zdennis Assigned to: core
Priority: normal Milestone: 1.x
Component: ActiveSupport Version: edge
Severity: normal Keywords:
Cc:

Description

ActiveSupport::JSON.decode fails with nested quotes and also commas. The problem can be reproduce by running this in script/console:

>> ActiveSupport::JSON.decode('{a: "It\'s a boy", b: "5,000"}')
=> {"a"=>"It's a boy", "b"=>"5, 000"}

If you notice there is a space after the comma in "5, 000" when the string is decoded, but there isn't one in the actual json string. it fails because it does not currently handle quoting properly while decoding.

Attached is a patch which fixes this issue.

Attachments

active_support_json_decode.patch (1.7 kB) - added by zdennis on 09/17/07 21:18:44.
updated activesupport json decode patch

Change History

09/17/07 21:18:03 changed by zdennis

  • component changed from ActiveRecord to ActiveSupport.

Attached is a different patch which doesn't screw up spacing.

09/17/07 21:18:44 changed by zdennis

  • attachment active_support_json_decode.patch added.

updated activesupport json decode patch

09/17/07 21:19:31 changed by zdennis

To run the patch apply it from the top level activesupport directory.

09/17/07 21:37:56 changed by bitsweat

  • status changed from new to closed.
  • resolution set to fixed.

(In [7506]) Fix JSON decoder with nested quotes and commas. Closes #9579.