Project

General

Profile

Actions

Bug #22491

closed

The number of captures may change depending on the encoding of the target string

Bug #22491: The number of captures may change depending on the encoding of the target string

Added by mame (Yusuke Endoh) 23 days ago. Updated 9 days ago.

Status:
Closed
Assignee:
-
Target version:
-
[ruby-core:127292]

Description

The number of captures of a Regexp may change depending on the encoding of the target string.

E = "stateless-ISO-2022-JP"
a = "あ".encode("EUC-JP").encode(E)
re = Regexp.new("()()#".encode(E) + a + "()()".encode(E), Regexp::EXTENDED)
p re.match("ab".encode(E)).size  #=> 3
p re.match(a).size               #=> 5 (expected: 3)

Updated by mame (Yusuke Endoh) 23 days ago Actions #2

  • Backport changed from 3.3: UNKNOWN, 3.4: UNKNOWN, 4.0: UNKNOWN to 3.3: REQUIRED, 3.4: REQUIRED, 4.0: REQUIRED

Updated by make_now_just (Hiroya Fujinami) 23 days ago Actions #3

  • Status changed from Open to Closed

Applied in changeset git|b4e5cb26164848f4d5b775a624533c4583a73264.


Keep the groups of a regexp compiled again for a string

When a regexp is compiled again for the encoding of a string, pass its
options to the preprocessor so that the comments of extended mode are
dropped as in the first compilation. Also make is_code_ctype of
Emacs-Mule return false for non-ASCII characters except for the word,
graph and print types, so that they are not treated as newlines.

[Bug #22491]

Co-Authored-By: Claude Opus 5.5

Updated by nagachika (Tomoyuki Chikanaga) 17 days ago Actions #4 [ruby-core:127356]

  • Backport changed from 3.3: REQUIRED, 3.4: REQUIRED, 4.0: REQUIRED to 3.3: REQUIRED, 3.4: DONE, 4.0: REQUIRED

Updated by k0kubun (Takashi Kokubun) 9 days ago Actions #5 [ruby-core:127514]

  • Backport changed from 3.3: REQUIRED, 3.4: DONE, 4.0: REQUIRED to 3.3: REQUIRED, 3.4: DONE, 4.0: DONE
Actions

Also available in: PDF Atom