Fix [Bug #20246]: Don't set next_head_exact if a capture is called (#9897)

This commit is contained in:
Hiroya Fujinami 2024-02-13 09:53:03 +09:00 committed by GitHub
parent 8a345860d3
commit 4a6384ed93
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 1 deletions

View File

@ -3395,7 +3395,7 @@ next_setup(Node* node, Node* next_node, regex_t* reg)
}
else if (type == NT_ENCLOSE) {
EncloseNode* en = NENCLOSE(node);
if (en->type == ENCLOSE_MEMORY) {
if (en->type == ENCLOSE_MEMORY && !IS_ENCLOSE_CALLED(en)) {
node = en->target;
goto retry;
}

View File

@ -2045,6 +2045,11 @@ class TestRegexp < Test::Unit::TestCase
100.times.each { assert(regex.match?(string)) }
end
def test_bug_20246 # [Bug #20246]
assert_equal '1.2.3', '1.2.3'[/(\d+)(\.\g<1>){2}/]
assert_equal '1.2.3', '1.2.3'[/((?:\d|foo|bar)+)(\.\g<1>){2}/]
end
def test_linear_time_p
assert_send [Regexp, :linear_time?, /a/]
assert_send [Regexp, :linear_time?, 'a']