diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2014-06-15 10:52:33 -0700 |
---|---|---|
committer | Lamont Granquist <lamont@scriptkiddie.org> | 2014-06-15 10:52:33 -0700 |
commit | aa71fe4777d2667696e420f7ea15326cfbb45aa8 (patch) | |
tree | 0f6ee5a4f7665ed2bfedf07640552f5b2810528b | |
parent | 8f640b6d665926c6687d6138c8f6485b43c3a857 (diff) | |
download | ffi-yajl-aa71fe4777d2667696e420f7ea15326cfbb45aa8.tar.gz |
fix very large floats in ffi
-rw-r--r-- | lib/ffi_yajl/ffi/parser.rb | 2 | ||||
-rw-r--r-- | spec/ffi_yajl/parser_spec.rb | 1 |
2 files changed, 1 insertions, 2 deletions
diff --git a/lib/ffi_yajl/ffi/parser.rb b/lib/ffi_yajl/ffi/parser.rb index 7c1dbbc..11682dc 100644 --- a/lib/ffi_yajl/ffi/parser.rb +++ b/lib/ffi_yajl/ffi/parser.rb @@ -51,7 +51,7 @@ module FFI_Yajl s = stringval.slice(0,stringlen) s.force_encoding('UTF-8') if defined? Encoding # XXX: I can't think of a better way to do this right now. need to call to_f if and only if its a float. - v = ( s =~ /\./ ) ? s.to_f : s.to_i + v = ( s =~ /[\.eE]/ ) ? s.to_f : s.to_i set_value(v) 1 end diff --git a/spec/ffi_yajl/parser_spec.rb b/spec/ffi_yajl/parser_spec.rb index 4f6186e..c3424ef 100644 --- a/spec/ffi_yajl/parser_spec.rb +++ b/spec/ffi_yajl/parser_spec.rb @@ -9,7 +9,6 @@ describe "FFI_Yajl::Parser" do let(:json) { '{"key": 23456789012E666}' } it "should return infinity" do - skip "handle infinity properly" infinity = (1.0/0) expect(parser).to eq({"key" => infinity}) end |