Bug #9903
closed
Regexp#[] doesn't consider capture name encoding
Added by nobu (Nobuyoshi Nakada) over 10 years ago.
Updated about 10 years ago.
Description
Regexp#[]が引数の文字列やシンボルを考慮していません。
key = "\xb1\xb2".force_encoding(Encoding::EUC_JP)
m = /(?<#{key}>.*)/.match("xxx")
p m[key.dup.force_encoding(Encoding::Shift_JIS)]
# => "xxx"
- Status changed from Open to Closed
- % Done changed from 0 to 100
Applied in changeset r46346.
re.c: consider name encoding
- re.c (match_aref, rb_reg_regsub): consider encoding of captured
names, encoding-incompatible should not match.
[ruby-dev:48278] [Bug #9903]
- 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 r47052.
- 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 r47364.
note that it needed r42251.
Also available in: Atom
PDF
Like0
Like0Like0Like0