Skip to content

doesn't fail when parsing "f" or "n" #58

@jmettraux

Description

@jmettraux

when parsing "f" and "n", yajl-ruby returns nil (instead of emitting an error).

(https://gist.github.com/949695)

require 'rubygems'
require 'yajl'
require 'yajl/version'
require 'json'

puts `uname -a`
p [ :ruby, RUBY_VERSION ]
p [ :json, JSON::VERSION ]
p [ :yajl, Yajl::VERSION ]

p begin
  JSON.parse('f')
rescue
  :json_error
end
p begin
  JSON.parse('n')
rescue
  :json_error
end

p begin
  Yajl::Parser.parse('f')
rescue
  :yajl_error
end
p begin
  Yajl::Parser.parse('n')
rescue
  :yajl_error
end

emits

Darwin sanma.local 10.7.0 Darwin Kernel Version 10.7.0: Sat Jan 29 15:17:16 PST 2011; root:xnu-1504.9.37~1/RELEASE_I386 i386
[:ruby, "1.9.2"]
[:json, "1.4.2"]
[:yajl, "0.8.2"]
:json_error
:json_error
nil
nil

Tested with 1.8.7-p249 and 1.9.2-p180 on Snow Leopard. Using vanilla RVM.

Same thing on a Debian system (vanilla RVM) :

Linux li162-226 #1 SMP Sun Jul 25 21:32:42 UTC 2010 i686 GNU/Linux
[:ruby, "1.8.7"]
[:json, "1.5.1"]
[:yajl, "0.8.2"]
:json_error
:json_error
nil
nil

Kind regards.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions