From 2c3fcf762b27da1e27231d209eeef3d0e9705ef0 Mon Sep 17 00:00:00 2001 From: Dankrushen Date: Thu, 27 May 2021 23:04:44 -0400 Subject: [PATCH] Patch potential string.Format exception --- MultiAdmin/Server.cs | 2 +- MultiAdmin/Utility/StringExtensions.cs | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/MultiAdmin/Server.cs b/MultiAdmin/Server.cs index e1f1873..8157b52 100644 --- a/MultiAdmin/Server.cs +++ b/MultiAdmin/Server.cs @@ -144,7 +144,7 @@ private set // Update related variables LogDirFile = string.IsNullOrEmpty(value) || string.IsNullOrEmpty(logDir) ? null - : $"{Path.Combine(logDir, value)}_{{0}}_log_{Port}.txt"; + : $"{Path.Combine(logDir.EscapeFormat(), value)}_{{0}}_log_{Port}.txt"; lock (this) { diff --git a/MultiAdmin/Utility/StringExtensions.cs b/MultiAdmin/Utility/StringExtensions.cs index 9525521..eadb1f0 100644 --- a/MultiAdmin/Utility/StringExtensions.cs +++ b/MultiAdmin/Utility/StringExtensions.cs @@ -39,5 +39,15 @@ public static bool Equals(this string input, string value, int startIndex) return Equals(input, value, startIndex, length); } + + /// + /// Escapes this for use with + /// + /// The to escape + /// A escaped for use with + public static string EscapeFormat(this string input) + { + return input?.Replace("{", "{{").Replace("}", "}}"); + } } }