Project

General

Profile

Actions

Bug #9902

closed

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

Added by nobu (Nobuyoshi Nakada) almost 10 years ago. Updated over 9 years ago.

Status:
Closed
Assignee:
-
Target version:
-
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>'

Updated by nobu (Nobuyoshi Nakada) almost 10 years ago

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

Applied in changeset r46344.


re.c: fix name with NUL

Updated by nobu (Nobuyoshi Nakada) almost 10 years ago

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

Updated by nagachika (Tomoyuki Chikanaga) almost 10 years ago

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

Updated by nobu (Nobuyoshi Nakada) almost 10 years ago

Yes, or rb_id2str(SYM2ID(idx)).

Updated by nagachika (Tomoyuki Chikanaga) almost 10 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.

Updated by usa (Usaku NAKAMURA) over 9 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.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0