From 26ccf4129831b9a48c7c918e6614ec2fe5fad07f Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Thu, 28 Mar 2019 12:36:12 +0100 Subject: global-functions: prevent infinite loop --- global-functions | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/global-functions b/global-functions index 043da42..1145200 100644 --- a/global-functions +++ b/global-functions @@ -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 -- cgit v1.2.3-54-g00ecf