Bug #9903

Regexp#[] doesn't consider capture name encoding

Added by Nobuyoshi Nakada 12 months ago. Updated 9 months ago.

[ruby-dev:48278]
Status:Closed
Priority:Normal
Assignee:-
ruby -v:r46343 Backport:2.0.0: DONE, 2.1: DONE

Description

Regexp#[]が引数の文字列やシンボルを考慮していません。

key = "\xb1\xb2".force_encoding(Encoding::EUC_JP)
m = /(?<#{key}>.*)/.match("xxx")
p m[key.dup.force_encoding(Encoding::Shift_JIS)]
# => "xxx"

Associated revisions

Revision 46346
Added by Nobuyoshi Nakada 12 months ago

re.c: consider name encoding

  • re.c (match_aref, rb_reg_regsub): consider encoding of captured names, encoding-incompatible should not match. [Bug #9903]

Revision 46346
Added by Nobuyoshi Nakada 12 months ago

re.c: consider name encoding

  • re.c (match_aref, rb_reg_regsub): consider encoding of captured names, encoding-incompatible should not match. [Bug #9903]

Revision 47052
Added by Tomoyuki Chikanaga 10 months ago

merge revision(s) r46345,r46346: [Backport #9903]

re.c: reduce new strings

* re.c (match_aref, rb_reg_regsub): reduce new strings creation

for exceptions.
* re.c (match_aref, rb_reg_regsub): consider encoding of captured
names, encoding-incompatible should not match.
[Bug #9903]

Revision 47364
Added by Usaku NAKAMURA 9 months ago

merge revision(s) 42251,46345,46346: [Backport #9903]

* sprintf.c (ruby__sfvextra): add QUOTE flag to escape unprintable
  characters.

* sprintf.c (ruby__sfvextra): add QUOTE flag to escape unprintable
  characters.

* re.c (match_aref, rb_reg_regsub): consider encoding of captured
  names, encoding-incompatible should not match.
   [Bug #9903]

History

#1 Updated by Nobuyoshi Nakada 12 months ago

  • 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. [Bug #9903]

#2 Updated by Tomoyuki Chikanaga 10 months 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 r47052.

#3 Updated by Usaku NAKAMURA 9 months 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 r47364.

note that it needed r42251.

Also available in: Atom PDF