bugfix: empty quoted string are not written properly

This commit is contained in:
Lacoi 2023-08-21 15:37:10 +02:00
parent 6e3a6b9890
commit 64c55f3f32

View file

@ -1,5 +1,6 @@
using ServerManagerTool.Common.Attibutes; using ServerManagerTool.Common.Attibutes;
using ServerManagerTool.Common.Enums; using ServerManagerTool.Common.Enums;
using ServerManagerTool.Common.Extensions;
using ServerManagerTool.Common.Interfaces; using ServerManagerTool.Common.Interfaces;
using ServerManagerTool.Common.Utils; using ServerManagerTool.Common.Utils;
using System; using System;
@ -348,6 +349,14 @@ namespace ServerManagerTool.Common.Serialization
} }
if (attr.QuotedString == QuotedStringType.True) if (attr.QuotedString == QuotedStringType.True)
{
// 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. // add the leading and trailing quotes, if not already have them.
if (!strValue.StartsWith("\"")) if (!strValue.StartsWith("\""))
@ -355,6 +364,7 @@ namespace ServerManagerTool.Common.Serialization
if (!strValue.EndsWith("\"")) if (!strValue.EndsWith("\""))
strValue = strValue + "\""; strValue = strValue + "\"";
} }
}
else if (attr.QuotedString == QuotedStringType.Remove) else if (attr.QuotedString == QuotedStringType.Remove)
{ {
// remove the leading and trailing quotes, if any // remove the leading and trailing quotes, if any