Bug #9902
closed
Regexp#[] ignores after NUL byte in named capture index
Added by nobu (Nobuyoshi Nakada) over 10 years ago.
Updated about 10 years ago.
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>'
- Status changed from Open to Closed
- % Done changed from 0 to 100
Applied in changeset r46344.
re.c: fix name with NUL
- Backport changed from 2.0.0: UNKNOWN, 2.1: UNKNOWN to 2.0.0: REQUIRED, 2.1: REQUIRED
rb_sym2str() doesn't exist in 2.1. Can I use rb_sym_to_s() instead?
Yes, or rb_id2str(SYM2ID(idx))
.
- 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.
- 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
Like0
Like0Like0Like0Like0Like0Like0