From b526cdc5279e6afdf32863d097b8f1e8d2d808ad Mon Sep 17 00:00:00 2001 From: Isaac Post Date: Fri, 31 Mar 2023 11:45:31 -0400 Subject: [PATCH] fix hanging on LF character --- lib/jsonpath.rb | 2 +- test/test_jsonpath.rb | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/jsonpath.rb b/lib/jsonpath.rb index 3b9ed49..fff66e1 100644 --- a/lib/jsonpath.rb +++ b/lib/jsonpath.rb @@ -44,7 +44,7 @@ def initialize(path, opts = {}) nil elsif (token = scanner.scan(/[><=] \d+/)) @path.last << token - elsif (token = scanner.scan(/./)) + elsif (token = scanner.scan(/./m)) begin @path.last << token rescue RuntimeError diff --git a/test/test_jsonpath.rb b/test/test_jsonpath.rb index 91e7026..ec47275 100644 --- a/test/test_jsonpath.rb +++ b/test/test_jsonpath.rb @@ -1178,6 +1178,10 @@ def test_raise_max_nesting_error assert_raises(MultiJson::ParseError) { JsonPath.new('$.a', max_nesting: 1).on(json) } end + def test_linefeed_in_path_error + assert_raises(ArgumentError) { JsonPath.new("$.store\n.book") } + end + def test_with_max_nesting_false json = { a: {