mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-23 06:40:56 +02:00
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:
parent
e964bd179b
commit
c41a93243a
@ -8279,6 +8279,10 @@ begin
|
|||||||
//DebugLn(['TCustomSynEdit.SearchReplace FOUND ptStart=',dbgs(ptStart),' ptEnd=',dbgs(ptEnd),' ptFoundStart=',dbgs(ptFoundStart),' ptFoundEnd=',dbgs(ptFoundEnd)]);
|
//DebugLn(['TCustomSynEdit.SearchReplace FOUND ptStart=',dbgs(ptStart),' ptEnd=',dbgs(ptEnd),' ptFoundStart=',dbgs(ptFoundStart),' ptFoundEnd=',dbgs(ptFoundEnd)]);
|
||||||
// check if found place is entirely in range
|
// check if found place is entirely in range
|
||||||
ZeroLen := ptFoundStart = ptFoundEnd;
|
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
|
if ( (not SelIsColumn) or
|
||||||
( (ptFoundStart.Y=ptFoundEnd.Y) and
|
( (ptFoundStart.Y=ptFoundEnd.Y) and
|
||||||
(ptFoundStart.X >= ReplaceBlockSelection.ColumnStartBytePos[ptFoundStart.Y]) and
|
(ptFoundStart.X >= ReplaceBlockSelection.ColumnStartBytePos[ptFoundStart.Y]) and
|
||||||
@ -8288,7 +8292,8 @@ begin
|
|||||||
not( ZeroLen and (ptStart = ptFoundStart) and
|
not( ZeroLen and (ptStart = ptFoundStart) and
|
||||||
(ssoFindContinue in AOptions) and (not SelAvail)
|
(ssoFindContinue in AOptions) and (not SelAvail)
|
||||||
)
|
)
|
||||||
)
|
) and
|
||||||
|
( ZeroLen = (ptFoundStart = ptFoundEnd) )
|
||||||
then
|
then
|
||||||
begin
|
begin
|
||||||
// pattern found
|
// pattern found
|
||||||
|
Loading…
Reference in New Issue
Block a user