uhop / node-re2

node.js bindings for RE2: fast, safe alternative to backtracking regular expression engines.
Other
493 stars 53 forks source link

Fix: infinite loop in matchAll() with empty matches #181

Closed ziyunfei closed 1 year ago

ziyunfei commented 1 year ago

The library's matchAll() method would enter an infinite loop when used with a regular expression that matches empty strings, such as /(?:)/g. This commit fixes the issue by manually incrementing the lastIndex property when an empty match is found.

Additionally, a new test case has been added to the test suite to verify that matchAll() works correctly with empty matches.

uhop commented 1 year ago

Published as 1.19.2.