From 64c55f3f322d1c38393ed85fa461fa5e48c74870 Mon Sep 17 00:00:00 2001 From: Lacoi Date: Mon, 21 Aug 2023 15:37:10 +0200 Subject: [PATCH] bugfix: empty quoted string are not written properly --- .../Serialization/BaseSystemIniFile.cs | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/ServerManager.Common/Serialization/BaseSystemIniFile.cs b/src/ServerManager.Common/Serialization/BaseSystemIniFile.cs index b8dec04a..7c5e6502 100644 --- a/src/ServerManager.Common/Serialization/BaseSystemIniFile.cs +++ b/src/ServerManager.Common/Serialization/BaseSystemIniFile.cs @@ -1,5 +1,6 @@ using ServerManagerTool.Common.Attibutes; using ServerManagerTool.Common.Enums; +using ServerManagerTool.Common.Extensions; using ServerManagerTool.Common.Interfaces; using ServerManagerTool.Common.Utils; using System; @@ -349,11 +350,20 @@ namespace ServerManagerTool.Common.Serialization if (attr.QuotedString == QuotedStringType.True) { - // add the leading and trailing quotes, if not already have them. - if (!strValue.StartsWith("\"")) - strValue = "\"" + strValue; - if (!strValue.EndsWith("\"")) - strValue = strValue + "\""; + // if the stValue is empty, return empty quoted string (parsing not needed) + // bug fix for 'property="' on a empty string + if (strValue.IsEmpty()) + { + strValue = "\"\""; + } + else + { + // add the leading and trailing quotes, if not already have them. + if (!strValue.StartsWith("\"")) + strValue = "\"" + strValue; + if (!strValue.EndsWith("\"")) + strValue = strValue + "\""; + } } else if (attr.QuotedString == QuotedStringType.Remove) {