Project

General

Profile

Bug #9902

Regexp#[] ignores after NUL byte in named capture index

Added by Nobuyoshi Nakada over 2 years ago. Updated over 2 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
ruby -v:
r46343
[ruby-dev:48275]

Description

Regexp#[]に"\0"を含む文字列やシンボルを指定したとき、それ以降が無視されます。

$ ruby -w -e 'p(/(?<a>.*)/.match("foo")["a\0foo"])'
"foo"

$ ruby -w -e 'p Regexp.new("(?<foo\0bar>.*?)").match("xxx")["foo\0bar"]'
-e:1:in `[]': undefined group name reference: foo (IndexError)
    from -e:1:in `<main>'

Associated revisions

Revision 46344
Added by Nobuyoshi Nakada over 2 years ago

re.c: fix name with NUL

  • re.c (match_aref): should not ignore name after NUL byte. [Bug #9902]

Revision 46344
Added by Nobuyoshi Nakada over 2 years ago

re.c: fix name with NUL

  • re.c (match_aref): should not ignore name after NUL byte. [Bug #9902]

Revision 46344
Added by Nobuyoshi Nakada over 2 years ago

re.c: fix name with NUL

  • re.c (match_aref): should not ignore name after NUL byte. [Bug #9902]

Revision 46869
Added by Tomoyuki Chikanaga over 2 years ago

merge revision(s) r46344: [Backport #9902]

* re.c (match_aref): should not ignore name after NUL byte.
   [Bug #9902]

Revision 47334
Added by Usaku NAKAMURA over 2 years ago

merge revision(s) 46344: [Backport #9902]

* re.c (match_aref): should not ignore name after NUL byte.
   [Bug #9902]

History

#1 [ruby-dev:48276] Updated by Nobuyoshi Nakada over 2 years ago

  • % Done changed from 0 to 100
  • Status changed from Open to Closed

Applied in changeset r46344.


re.c: fix name with NUL

  • re.c (match_aref): should not ignore name after NUL byte. [Bug #9902]

#2 [ruby-dev:48277] Updated by Nobuyoshi Nakada over 2 years ago

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

#3 [ruby-dev:48345] Updated by Tomoyuki Chikanaga over 2 years ago

rb_sym2str() doesn't exist in 2.1. Can I use rb_sym_to_s() instead?

#4 [ruby-dev:48346] Updated by Nobuyoshi Nakada over 2 years ago

Yes, or rb_id2str(SYM2ID(idx)).

#5 [ruby-dev:48432] Updated by Tomoyuki Chikanaga over 2 years ago

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

backported into ruby_2_1 branch at r46869.

#6 [ruby-dev:48502] Updated by Usaku NAKAMURA over 2 years ago

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

backported into ruby_2_0_0 at r47334.

Also available in: Atom PDF