summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorHiroshi SHIBATA <hsbt@ruby-lang.org>2020-08-14 14:03:43 +0900
committerGitHub <noreply@github.com>2020-08-14 14:03:43 +0900
commit09b0bcb93bb0eb4b7c8c84eb5a7bb8fa98545ba9 (patch)
tree31d1e4ff79508ec209dc8612bae5e7058698de86 /lib
parent03f1699ec4127bf4d8282dbe90c683a5716413a3 (diff)
parent5b4f1baef055d2a7be58cdfe7329b1b2f5b748c9 (diff)
downloadjson-09b0bcb93bb0eb4b7c8c84eb5a7bb8fa98545ba9.tar.gz
Merge pull request #425 from marcandre/fix_pure_parser
Fix pure parser with unclosed arrays / objects [Fix #314]
Diffstat (limited to 'lib')
-rw-r--r--lib/json/pure/parser.rb8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/json/pure/parser.rb b/lib/json/pure/parser.rb
index 5db244c..6f37e0c 100644
--- a/lib/json/pure/parser.rb
+++ b/lib/json/pure/parser.rb
@@ -242,8 +242,10 @@ module JSON
@max_nesting.nonzero? && @current_nesting > @max_nesting
result = @array_class.new
delim = false
- until eos?
+ loop do
case
+ when eos?
+ raise ParserError, "unexpected end of string while parsing array"
when !UNPARSED.equal?(value = parse_value)
delim = false
result << value
@@ -274,8 +276,10 @@ module JSON
@max_nesting.nonzero? && @current_nesting > @max_nesting
result = @object_class.new
delim = false
- until eos?
+ loop do
case
+ when eos?
+ raise ParserError, "unexpected end of string while parsing object"
when !UNPARSED.equal?(string = parse_string)
skip(IGNORE)
unless scan(PAIR_DELIMITER)