This project is archived and is in readonly mode.
[PATCH] ActiveSupport::JSON.decode explodes in certain circumstances
-
Yehuda Katz (wycats)
- State changed from new to open
-
Bas van Klinkenberg
- Title changed from ActiveSupport::JSON.decode explodes in certain circumstances to [PATCH] ActiveSupport::JSON.decode explodes in certain circumstances
Here is a patch for this bug. I also believe this solves bug #2273.
The cause of the bug is that between the moment when the position of the quotes around dates are tracked, and the moment those quotes are removed, the output string has changed size due to removing backslashes and/or decoding unicode sequences. Due to this wrong characters in the string are overwritten, causing Yaml to fail consequently, which causes a ParseError exception.
This patch moves the code that replaces the quotes above the code that handles the backslashes and unicode sequences, before the string size changes.
-
CancelProfileIsBroken
- Tag changed from 2.3.2, activesupport, json to 2.3.2, activesupport, bugmash, json
-
Nikolay Petrachkov
- Assigned user set to Pratik
Patch is verified for above code.
Before:
ActiveSupport::JSON.decode('{"r":"http:\/\/foo","d":"2004-06-24"}') IndexError: index 38 out of string from /opt/rubyee/lib/ruby/gems/1.8/gems/activesupport-2.3.3/lib/active_support/json/backends/yaml.rb:77:in `[]=' from /opt/rubyee/lib/ruby/gems/1.8/gems/activesupport-2.3.3/lib/active_support/json/backends/yaml.rb:77:in `convert_json_to_yaml' from /opt/rubyee/lib/ruby/gems/1.8/gems/activesupport-2.3.3/lib/active_support/json/backends/yaml.rb:77:in `each' from /opt/rubyee/lib/ruby/gems/1.8/gems/activesupport-2.3.3/lib/active_support/json/backends/yaml.rb:77:in `convert_json_to_yaml' from /opt/rubyee/lib/ruby/gems/1.8/gems/activesupport-2.3.3/lib/active_support/json/backends/yaml.rb:16:in `decode' from /opt/rubyee/lib/ruby/gems/1.8/gems/activesupport-2.3.3/lib/active_support/json/decoding.rb:11:in `__send__' from /opt/rubyee/lib/ruby/gems/1.8/gems/activesupport-2.3.3/lib/active_support/json/decoding.rb:11:in `decode' from (irb):1After patch:
ActiveSupport::JSON.decode('{"r":"http:\/\/foo","d":"2004-06-24"}') => {"d"=>Thu, 24 Jun 2004, "r"=>"http://foo"} -
Rizwan Reza
verified
+1 This patch works perfectly. All tests pass.
-
Repository
- State changed from open to resolved
(from [0fbeaa98e4e60ca0949be298dae8545807407e1d]) Fixed a bug in JSON decoding with Yaml backend, where a combination of dates, escaped or unicode encoded data and arrays would make the parser fail with a ParseError exception. [#2831 state:resolved]
Signed-off-by: Yehuda Katz wycats@gmail.com
http://github.com/rails/rails/commit/0fbeaa98e4e60ca0949be298dae854... -
CancelProfileIsBroken
- Assigned user cleared.
- Tag changed from 2.3.2, activesupport, bugmash, json to 2.3.2, activesupport, json
- Milestone cleared.
-
Nathan Beyer
This issue is present in the 2.3.5 release. It looks like the patch was only applied to the 2.3.2 branch and didn't make it beyond that.
Should a new bug be opened?
-
gregpyp
this bug is in the 2.3.5 too
-
Nathan Beyer
I created a new ticket with the patch ported to the 2-3-stable branch - https://rails.lighthouseapp.com/projects/8994/tickets/4102-ticket-2... .
-
Repository
(from [b99914cc3e58e6444f66006cd4b9b4fa7368afe2]) Fixed a bug in JSON decoding with Yaml backend, where a combination of dates, escaped or unicode encoded data and arrays would make the parser fail with a ParseError exception.
[#2831]
Signed-off-by: Yehuda Katz wycats@gmail.com
Signed-off-by: Jeremy Kemper jeremy@bitsweat.net
http://github.com/rails/rails/commit/b99914cc3e58e6444f66006cd4b9b4... -
ssupreme11
- Importance changed from to
Its my first time to visit this site and as I was exploring I cant believe that this site was made up of a very informative articles that you should try to have compliment with so as what I am doing now I really love to look forward with more interesting information on this site. Dissertation Writing
.
