notepad4 icon indicating copy to clipboard operation
notepad4 copied to clipboard

Hangs when doing a regex search & replace for $

Open haqk opened this issue 5 years ago • 2 comments

For example, the following will cause Notepad2 to hang:

Mode: Regular Expression Search Search String: $ Replace With: test

Notepad2 (64-bit) 4.20.02 r2652 (fd22bee) on Windows 7

haqk avatar Feb 20 '20 14:02 haqk

This is caused by changes in Scintilla 4.0.5, from the changelog: https://www.scintilla.org/ScintillaHistory.html

Bugs fixed in regular expression searches in Scintilla where some matches did not occur in an effort to avoid infinite loops when replacing on empty matches like "^" and "$". Applications should always handle empty matches in a way that avoids infinite loops, commonly by incrementing the search position after replacing an empty match. SciTE fixes a bug where replacing "^" always matched on the first line even when it was an "in selection" replace and the selection started after the line start.

A fix for the empty matches is done, I will push it after some testing.

zufuliu avatar Feb 21 '20 00:02 zufuliu

Fixed in e8649d672bf16cc2f21a82c1fbb2e94807da8511, fell free to test whether there are other regex that will cause infinite loops. a similar bug is added on Scintilla at https://sourceforge.net/p/scintilla/bugs/2157/

zufuliu avatar Feb 21 '20 11:02 zufuliu

Full fixed by 1bfaf31d6e05b99a1dd441854cfb82c3cf6f601e.

zufuliu avatar Oct 13 '23 10:10 zufuliu