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

(cherry picked from commit c4644e5d63)
This commit is contained in:
Martin 2024-04-13 22:08:13 +02:00
parent e964bd179b
commit c41a93243a

View File

@ -8279,6 +8279,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
@ -8288,7 +8292,8 @@ begin
not( ZeroLen and (ptStart = ptFoundStart) and
(ssoFindContinue in AOptions) and (not SelAvail)
)
)
) and
( ZeroLen = (ptFoundStart = ptFoundEnd) )
then
begin
// pattern found