SynEdit: mitigate endless loop with regex replace and utf8. (regex does not handle utf-8). Issue #40900

This commit is contained in:
Martin 2024-04-13 22:08:13 +02:00
parent b8ec0ec5b3
commit c4644e5d63

View File

@ -8297,6 +8297,10 @@ begin
//DebugLn(['TCustomSynEdit.SearchReplace FOUND ptStart=',dbgs(ptStart),' ptEnd=',dbgs(ptEnd),' ptFoundStart=',dbgs(ptFoundStart),' ptFoundEnd=',dbgs(ptFoundEnd)]);
// check if found place is entirely in range
ZeroLen := ptFoundStart = ptFoundEnd;
if ssoRegExpr in AOptions then begin
ptFoundStart.X := FTheLinesView.LogicPosAdjustToChar(FTheLinesView[ToIdx(ptFoundStart.Y)], ptFoundStart.X, False);
ptFoundEnd.X := FTheLinesView.LogicPosAdjustToChar(FTheLinesView[ToIdx(ptFoundEnd.Y)], ptFoundEnd.X, True);
end;
if ( (not SelIsColumn) or
( (ptFoundStart.Y=ptFoundEnd.Y) and
(ptFoundStart.X >= ReplaceBlockSelection.ColumnStartBytePos[ptFoundStart.Y]) and
@ -8306,7 +8310,8 @@ begin
not( ZeroLen and (ptStart = ptFoundStart) and
(ssoFindContinue in AOptions) and (not SelAvail)
)
)
) and
( ZeroLen = (ptFoundStart = ptFoundEnd) )
then
begin
// pattern found