Skip to content

Commit

Permalink
Merge pull request #609 from casperisfine/handle-wrongly-encoded-strings
Browse files Browse the repository at this point in the history
Restore support for improperly encoded strings
  • Loading branch information
byroot authored Oct 14, 2024
2 parents 7b68800 + c5a6d80 commit 2ad3514
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
9 changes: 9 additions & 0 deletions tests/json_generator_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,15 @@ def test_invalid_encoding_string
end

if defined?(JSON::Ext::Generator) and RUBY_PLATFORM != "java"
def test_valid_utf8_in_different_encoding
utf8_string = "€™"
wrong_encoding_string = utf8_string.b
# This behavior is historical. Not necessary desirable. We should deprecated it.
# The pure and java version of the gem already don't behave this way.
assert_equal utf8_string.to_json, wrong_encoding_string.to_json
assert_equal JSON.dump(utf8_string), JSON.dump(wrong_encoding_string)
end

def test_string_ext_included_calls_super
included = false

Expand Down
2 changes: 1 addition & 1 deletion tests/ractor_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

class JSONInRactorTest < Test::Unit::TestCase
def test_generate
assert_separately([], "#{<<~"begin;"}\n#{<<~'end;'}")
assert_separately([], "#{<<~"begin;"}\n#{<<~'end;'}", ignore_stderr: true)
begin;
$VERBOSE = nil
require "json"
Expand Down

0 comments on commit 2ad3514

Please sign in to comment.