From d76588541a65fd7c56e5c990fb7ba39eabeef277 Mon Sep 17 00:00:00 2001 From: Florian Frank Date: Fri, 1 Jun 2012 14:16:36 +0200 Subject: Always raise an error on invalid UTF-8 This concerns strings that were tagged as UTF-8, but actually aren't. --- tests/test_json_unicode.rb | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'tests') diff --git a/tests/test_json_unicode.rb b/tests/test_json_unicode.rb index c328811..66a87d0 100755 --- a/tests/test_json_unicode.rb +++ b/tests/test_json_unicode.rb @@ -69,4 +69,11 @@ class TestJSONUnicode < Test::Unit::TestCase end assert_equal "\302\200", JSON.parse('["\u0080"]').first end + + def test_parsing_invalid_utf8 + assert_raise ArgumentError do + JSON.parse "[\"\xCE\"]", :quirks_mode => true + JSON.parse "[\"\xCE\"]" + end + end end -- cgit v1.2.1