1
0
mirror of https://github.com/eworm-de/routeros-scripts.git synced 2024-05-11 05:55:19 +00:00

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