global-functions: prevent infinite loop

This commit is contained in:
Christian Hesse 2019-03-28 12:36:12 +01:00
parent 04b7b1f3b5
commit 26ccf41298

View file

@ -44,6 +44,7 @@
:local ReplaceFrom [ :tostr $2 ];
:local ReplaceWith [ :tostr $3 ];
:local Len [ :len $ReplaceFrom ];
:local Return "";
:if ($ReplaceFrom = "") do={
:return $String;
@ -51,10 +52,11 @@
:while ($String ~ $ReplaceFrom) do={
:local Pos [ :find $String $ReplaceFrom ];
:set String ([ :pick $String 0 $Pos ] . $ReplaceWith . [ :pick $String ($Pos + $Len) 999 ]);
:set Return ($Return . [ :pick $String 0 $Pos ] . $ReplaceWith);
:set String [ :pick $String ($Pos + $Len) 999 ];
}
:return $String;
:return ($Return . $String);
}
# check and import required certificates