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

JSON::Parser issues with encodings #4281

Closed
headius opened this Issue Nov 14, 2016 · 2 comments

Comments

Projects
None yet
1 participant
@headius
Copy link
Member

headius commented Nov 14, 2016

Environment

JRuby master running updated Ruby 2.3.x tests.

Expected Behavior

The following tests were added with a large update of json tests:

  def test_argument_encoding
    source = "{}".force_encoding("ascii-8bit")
    JSON::Parser.new(source)
    assert_equal Encoding::ASCII_8BIT, source.encoding
  end if defined?(Encoding::ASCII_8BIT)

  def test_error_message_encoding
    bug10705 = '[ruby-core:67386] [Bug #10705]'
    json = "\"\xE2\x88\x9A\"".force_encoding(Encoding::UTF_8)
    e = assert_raise(JSON::ParserError) {
      JSON.parse(json)
    }
    assert_equal(Encoding::UTF_8, e.message.encoding, bug10705)
    assert_include(e.message, json, bug10705)
  end if defined?(Encoding::UTF_8)
...

Actual Behavior

They fail. In the first case, the encoding of the source appears to change to UTF-8. The second does not raise an error for improperly-encoded content.

  5) Failure:
TestJSON#test_argument_encoding [/Users/headius/projects/jruby/test/mri/json/test_json.rb:552]:
<#<Encoding:ASCII-8BIT>> expected but was
<#<Encoding:UTF-8>>.

  6) Failure:
TestJSON#test_error_message_encoding [/Users/headius/projects/jruby/test/mri/json/test_json.rb:558]:
JSON::ParserError expected but nothing was raised.

@headius headius added this to the JRuby 9.1.7.0 milestone Nov 14, 2016

@headius headius changed the title JSON::Parser does not preserve binary encoding JSON::Parser issues with encodings Nov 14, 2016

@headius headius modified the milestones: JRuby 9.2.0.0, JRuby 9.1.7.0 Dec 13, 2016

@headius

This comment has been minimized.

Copy link
Member Author

headius commented Dec 13, 2016

Copy @flori since he still maintains the json library.

@headius headius modified the milestones: JRuby 9.2.0.0, JRuby 9.2.1.0 May 15, 2018

@headius

This comment has been minimized.

Copy link
Member Author

headius commented May 15, 2018

Updated json gem + tests no longer has this issue.

@headius headius closed this May 15, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.