lib/multi_json/vendor/okjson.rb in multi_json-1.11.2 vs lib/multi_json/vendor/okjson.rb in multi_json-1.11.3

- old
+ new

@@ -24,14 +24,14 @@ require 'stringio' module MultiJson # Some parts adapted from - # http://golang.org/src/pkg/json/decode.go and - # http://golang.org/src/pkg/utf8/utf8.go + # https://golang.org/src/encoding/json/decode.go and + # https://golang.org/src/unicode/utf8/utf8.go module OkJson - Upstream = '43' + Upstream = '45' extend self # Decodes a json document in string s and # returns the corresponding ruby value. @@ -264,17 +264,17 @@ def truetok(s); s[0,4] == 'true' ? [:val, 'true', true] : [] end def falsetok(s); s[0,5] == 'false' ? [:val, 'false', false] : [] end def numtok(s) - m = /-?([1-9][0-9]+|[0-9])([.][0-9]+)?([eE][+-]?[0-9]+)?/.match(s) + m = /(-?(?:[1-9][0-9]+|[0-9]))([.][0-9]+)?([eE][+-]?[0-9]+)?/.match(s) if m && m.begin(0) == 0 if !m[2] && !m[3] [:val, m[0], Integer(m[0])] elsif m[2] [:val, m[0], Float(m[0])] else - [:val, m[0], Integer(m[1])*(10**Integer(m[3][1..-1]))] + [:val, m[0], Integer(m[1])*(10**m[3][1..-1].to_i(10))] end else [] end end