diff --git a/activesupport/CHANGELOG.md b/activesupport/CHANGELOG.md index 25667af101..2d934f8bc4 100644 --- a/activesupport/CHANGELOG.md +++ b/activesupport/CHANGELOG.md @@ -1,3 +1,7 @@ +* Calling ActiveSupport::JSON.decode with unsupported options now raises an error. + + *Godfrey Chan* + * Support :unless_exist in FileStore *Michael Grosser* diff --git a/activesupport/lib/active_support/json/decoding.rb b/activesupport/lib/active_support/json/decoding.rb index 21de09c1cc..315c76199a 100644 --- a/activesupport/lib/active_support/json/decoding.rb +++ b/activesupport/lib/active_support/json/decoding.rb @@ -14,7 +14,14 @@ module ActiveSupport # ActiveSupport::JSON.decode("{\"team\":\"rails\",\"players\":\"36\"}") # => {"team" => "rails", "players" => "36"} def decode(json, options = {}) - data = ::JSON.parse(json, options.merge(create_additions: false, quirks_mode: true)) + if options.present? + raise ArgumentError, "In Rails 4.1, ActiveSupport::JSON.decode no longer " \ + "accepts an options hash for MultiJSON. MultiJSON reached its end of life " \ + "and has been removed." + end + + data = ::JSON.parse(json, quirks_mode: true) + if ActiveSupport.parse_json_times convert_dates_from(data) else diff --git a/activesupport/test/json/decoding_test.rb b/activesupport/test/json/decoding_test.rb index e9780b36e4..07d7e530ca 100644 --- a/activesupport/test/json/decoding_test.rb +++ b/activesupport/test/json/decoding_test.rb @@ -98,10 +98,8 @@ class TestJSONDecoding < ActiveSupport::TestCase assert_raise(ActiveSupport::JSON.parse_error) { ActiveSupport::JSON.decode(%()) } end - def test_cannot_force_json_unmarshalling - encodeded = %q({"json_class":"TestJSONDecoding::Foo"}) - decodeded = {"json_class"=>"TestJSONDecoding::Foo"} - assert_equal decodeded, ActiveSupport::JSON.decode(encodeded, create_additions: true) + def test_cannot_pass_unsupported_options + assert_raise(ArgumentError) { ActiveSupport::JSON.decode("", create_additions: true) } end end