JRuby (please use github issues at http://bugs.jruby.org)
  1. JRuby (please use github issues at http://bugs.jruby.org)
  2. JRUBY-6764

Ascii or UTF-8 Encoding ascii substrings that originated from binary string causes an exception to be thrown.

    Details

    • Type: Bug Bug
    • Status: Resolved Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: JRuby 1.7.0.pre1
    • Fix Version/s: JRuby 1.7.0.pre2
    • Component/s: None
    • Labels:
      None
    • Testcase included:
      yes
    • Patch Submitted:
      Yes
    • Number of attachments :
      0

      Description

      There are two pull requests that address this issue:

      https://github.com/jruby/jruby/pull/223 (fix for the issue)
      https://github.com/rubyspec/rubyspec/pull/146 (add the spec to rubyspec)

      just to make it convenient, here's the failing test case, that demonstrate the issue:

      
          it "an ascii substring of a binary string should be encoded UTF-8 without raising an exception" do
            binary_string = "\x82foo"
            ascii_string  = binary_string.bytes.to_a.pack('c*')[1..-1]
            ascii_string.should == "foo"
            ascii_string.encoding.name.should == "ASCII-8BIT"
            utf8_string   = ascii_string.encode("UTF-8")
            utf8_string.should == "foo"
            utf8_string.encoding.name.should == "UTF-8"
          end
      

        Activity

        Hide
        Charles Oliver Nutter added a comment -

        Tom Enebo already applied the fix, so I'm resolving this.

        John: It might be best if you reformulated your test case as a test/unit test and submitted it to MRI; RubySpec has not been very responsive to pull requests recently, and we run MRI tests as well. Thanks for the fix!

        Show
        Charles Oliver Nutter added a comment - Tom Enebo already applied the fix, so I'm resolving this. John: It might be best if you reformulated your test case as a test/unit test and submitted it to MRI; RubySpec has not been very responsive to pull requests recently, and we run MRI tests as well. Thanks for the fix!
        Hide
        John Shahid added a comment -

        I did, and the core commiters refused to merge it and the PR was closed. It's really frustrating and I don't know what to do about it.

        https://github.com/ruby/ruby/pull/148

        Show
        John Shahid added a comment - I did, and the core commiters refused to merge it and the PR was closed. It's really frustrating and I don't know what to do about it. https://github.com/ruby/ruby/pull/148
        Hide
        Charles Oliver Nutter added a comment -

        I talked with Aaron Patterson and he doesn't see a reason to reject the tests either. There may be a communication breakdown here, but he's going to try to massage both the patch and ruby-core folks to make it acceptable.

        Show
        Charles Oliver Nutter added a comment - I talked with Aaron Patterson and he doesn't see a reason to reject the tests either. There may be a communication breakdown here, but he's going to try to massage both the patch and ruby-core folks to make it acceptable.
        Hide
        John Shahid added a comment -

        Thanks, sorry to make you go through all this trouble.

        Show
        John Shahid added a comment - Thanks, sorry to make you go through all this trouble.

          People

          • Assignee:
            Charles Oliver Nutter
            Reporter:
            John Shahid
          • Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: