Project

General

Profile

Actions

Bug #11488

closed

String#index and #include? broken for wide encodings

Added by tomstuart (Tom Stuart) over 8 years ago. Updated over 8 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 2.2.3p173 (2015-08-18 revision 51636) [x86_64-darwin14]
[ruby-core:<unknown>]

Description

In Ruby 2.2.2, String#index and #include? work as expected for all encodings:

>> Encoding.list.reject(&:dummy?).
     reject { |e| 'abcdef'.encode(e).include?('def'.encode(e)) }.
     map(&:name)
=> []

But in Ruby 2.2.3 and trunk, they have become broken for wide encodings:

>> Encoding.list.reject(&:dummy?).
     reject { |e| 'abcdef'.encode(e).include?('def'.encode(e)) }.
     map(&:name)
=> ["UTF-16BE", "UTF-16LE", "UTF-32BE", "UTF-32LE"]

This broke as a result of revision 51470 (trunk) / 51590 (2.2.3). I attach a test.


Files

string-index-include-wide-bug.patch (1.18 KB) string-index-include-wide-bug.patch tomstuart (Tom Stuart), 08/25/2015 04:07 PM

Related issues 1 (0 open1 closed)

Related to Ruby master - Bug #11413: String#split with wchar stringClosedActions
Actions #1

Updated by nobu (Nobuyoshi Nakada) over 8 years ago

  • Related to Bug #11413: String#split with wchar string added
Actions #2

Updated by nobu (Nobuyoshi Nakada) over 8 years ago

  • Status changed from Open to Closed

Applied in changeset r51685.


re.c: fix wchar match at EOS

  • re.c (rb_memsearch_wchar, rb_memsearch_qchar): test matching
    till the end of string. [ruby-core:70592] [Bug #11488]
  • test/ruby/test_m17n.rb (test_include?, tet_index): add tests by
    Tom Stuart.
Actions #3

Updated by nagachika (Tomoyuki Chikanaga) over 8 years ago

  • Backport changed from 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN to 2.0.0: UNKNOWN, 2.1: REQUIRED, 2.2: REQUIRED

This is introduced at r51470 for #11413 and it's backported into ruby_2_1 and ruby_2_2.

Actions #4

Updated by usa (Usaku NAKAMURA) over 8 years ago

  • Backport changed from 2.0.0: UNKNOWN, 2.1: REQUIRED, 2.2: REQUIRED to 2.0.0: UNKNOWN, 2.1: DONE, 2.2: REQUIRED

ruby_2_1 r51976 merged revision(s) 51685.

Actions #5

Updated by nagachika (Tomoyuki Chikanaga) over 8 years ago

  • Backport changed from 2.0.0: UNKNOWN, 2.1: DONE, 2.2: REQUIRED to 2.0.0: UNKNOWN, 2.1: DONE, 2.2: DONE

Backported into ruby_2_2 branch at r51986.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0