From db2c4fbf3972074c7e9ce978a906b8bbb437a0d2 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Fri, 8 Feb 2019 20:15:49 +0100 Subject: global-functions: prevent infinite loop in $CharacterReplace --- global-functions | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/global-functions b/global-functions index 50d0eed..6e5dd5d 100644 --- a/global-functions +++ b/global-functions @@ -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 ]); -- cgit v1.2.3-54-g00ecf