[ruby-dev:48279] [ruby-trunk - Bug #9903] [Closed] Regexp#[] doesn't consider capture name encoding
From:
nobu@...
Date:
2014-06-04 13:10:05 UTC
List:
ruby-dev #48279
Issue #9903 has been updated by Nobuyoshi Nakada.
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]
----------------------------------------
Bug #9903: Regexp#[] doesn't consider capture name encoding
https://bugs.ruby-lang.org/issues/9903#change-47038
* Author: Nobuyoshi Nakada
* Status: Closed
* Priority: Normal
* Assignee:
* Category:
* Target version:
* ruby -v: r46343
* Backport: 2.0.0: REQUIRED, 2.1: REQUIRED
----------------------------------------
Regexp#[]が引数の文字列やシンボルを考慮していません。
~~~ruby
key = "\xb1\xb2".force_encoding(Encoding::EUC_JP)
m = /(?<#{key}>.*)/.match("xxx")
p m[key.dup.force_encoding(Encoding::Shift_JIS)]
# => "xxx"
~~~
--
https://bugs.ruby-lang.org/