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 in $CharacterReplace

This commit is contained in:
Christian Hesse
2019-02-08 20:15:49 +01:00
parent 6a48c8b5e7
commit db2c4fbf39

View File

@ -47,6 +47,10 @@
:local ReplaceWith [ :tostr $3 ];
:local Len [ :len $ReplaceFrom ];
:if ($ReplaceFrom = "") do={
:return $String;
}
:while ($String ~ $ReplaceFrom) do={
:local Pos [ :find $String $ReplaceFrom ];
:set String ([ :pick $String 0 $Pos ] . $ReplaceWith . [ :pick $String ($Pos + $Len) 999 ]);