Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test for unecaped control characters in strings #953

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions test/test_parser_usual.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,16 @@ def test_strings
assert_equal({'ぴ' => '', 'ぴ ' => 'x', 'c' => 'ぴーたー', 'd' => ' ぴーたー '}, doc)
end

def test_unescaped_ASCII_control_characters
p = Oj::Parser.new(:usual)

(0..31).each do |control_ord|
assert_raises(Oj::ParseError) do
p.parse(%{"invalid character: #{control_ord.chr}"})
end
end
end

def test_capacity
p = Oj::Parser.new(:usual, capacity: 1000)
assert_equal(4096, p.capacity)
Expand Down
8 changes: 8 additions & 0 deletions test/test_strict.rb
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,14 @@ def test_encode
Oj.default_options = opts
end

def test_unescaped_ASCII_control_characters
(0..31).each do |control_ord|
assert_raises(Oj::ParseError) do
Oj.load(%{"invalid character: #{control_ord.chr}"})
end
end
end

def test_unicode
# hits the 3 normal ranges and one extended surrogate pair
json = %{"\\u019f\\u05e9\\u3074\\ud834\\udd1e"}
Expand Down
Loading