diff options
author | Florian Frank <flori@ping.de> | 2013-02-04 23:28:30 +0100 |
---|---|---|
committer | Florian Frank <flori@ping.de> | 2013-02-10 18:28:05 +0100 |
commit | 3ce359bbf308354b86e94248fc13dfd4b23c792e (patch) | |
tree | 296aebe8360d331cb47c1806a72cc420adc2a972 /lib/json/common.rb | |
parent | 93b31b8b588461901ed5ae0dc4e961ea3adbc55e (diff) | |
download | json-fix-additions-problem-v1.6.8.tar.gz |
Security fix for create_additions problem 1.6.8v1.6.8fix-additions-problem-v1.6.8
Diffstat (limited to 'lib/json/common.rb')
-rw-r--r-- | lib/json/common.rb | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/lib/json/common.rb b/lib/json/common.rb index e8e76b6..7fd2db3 100644 --- a/lib/json/common.rb +++ b/lib/json/common.rb @@ -293,21 +293,28 @@ module JSON attr_accessor :load_default_options end self.load_default_options = { - :max_nesting => false, - :allow_nan => true, - :quirks_mode => true, + :max_nesting => false, + :allow_nan => true, + :quirks_mode => true, + :create_additions => true, } # Load a ruby data structure from a JSON _source_ and return it. A source can # either be a string-like object, an IO-like object, or an object responding # to the read method. If _proc_ was given, it will be called with any nested - # Ruby object as an argument recursively in depth first order. The default - # options for the parser can be changed via the load_default_options method. + # Ruby object as an argument recursively in depth first order. To modify the + # default options pass in the optional _options_ argument as well. + # + # BEWARE: This method is meant to serialise data from trusted user input, + # like from your own database server or clients under your control, it could + # be dangerous to allow untrusted users to pass JSON sources into it. The + # default options for the parser can be changed via the load_default_options + # method. # # This method is part of the implementation of the load/dump interface of # Marshal and YAML. - def load(source, proc = nil) - opts = load_default_options + def load(source, proc = nil, options = {}) + opts = load_default_options.merge options if source.respond_to? :to_str source = source.to_str elsif source.respond_to? :to_io |