hedgewars/uLocale.pas
changeset 15990 79b1129b4d03
parent 14882 acb0526bf458
child 15991 4ad8dd66d9d5
--- a/hedgewars/uLocale.pas	Fri Jun 16 21:06:46 2023 +0200
+++ b/hedgewars/uLocale.pas	Mon Jun 19 14:09:37 2023 +0200
@@ -164,6 +164,10 @@
             8: curArg:= arg9;
         end;
 
+        // Replace % sign in argument with ASCII ESC
+        // to prevent infinite loop below.
+        curArg:= StringReplace(curArg, '%', Char($1B), [rfReplaceAll]);
+
         repeat
         p:= Pos('%'+IntToStr(i+1), tempstr);
         if (p <> 0) then
@@ -173,6 +177,8 @@
             end;
         until (p = 0);
     end;
+
+tempstr:= StringReplace(tempstr, Char($1B), '%', [rfReplaceAll]);
 Format:= tempstr;
 end;
 
@@ -196,6 +202,10 @@
             8: curArg:= arg9;
         end;
 
+        // Replace % sign in argument with ASCII ESC
+        // to prevent infinite loop below.
+        curArg:= StringReplace(curArg, '%', Char($1B), [rfReplaceAll]);
+
         repeat
         p:= Pos('%'+IntToStr(i+1), tempstr);
         if (p <> 0) then
@@ -205,6 +215,8 @@
             end;
         until (p = 0);
     end;
+
+tempstr:= StringReplace(tempstr, Char($1B), '%', [rfReplaceAll]);
 FormatA:= tempstr;
 end;