Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions MultiAdmin/Config/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,15 @@ public bool Contains(string key)
rawData.Any(entry => entry.StartsWith($"{key}:", StringComparison.CurrentCultureIgnoreCase));
}

private static string CleanValue(string value)
private static string CleanValue(string value, bool removeQuotes = true)
{
if (string.IsNullOrEmpty(value)) return value;

string newValue = value.Trim();

try
{
if (newValue.StartsWith("\"") && newValue.EndsWith("\""))
if (removeQuotes && newValue.StartsWith("\"") && newValue.EndsWith("\""))
return newValue.Substring(1, newValue.Length - 2);
}
catch (Exception e)
Expand All @@ -88,7 +88,7 @@ private static string CleanValue(string value)
return newValue;
}

public string GetString(string key, string def = null)
public string GetString(string key, string def = null, bool removeQuotes = true)
{
try
{
Expand All @@ -98,7 +98,7 @@ public string GetString(string key, string def = null)

try
{
return CleanValue(line.Substring(key.Length + 1));
return CleanValue(line.Substring(key.Length + 1), removeQuotes);
}
catch (Exception e)
{
Expand All @@ -118,13 +118,13 @@ public string[] GetStringArray(string key, string[] def = null)
{
try
{
foreach (string line in rawData)
{
if (!line.ToLower().StartsWith(key.ToLower() + ":")) continue;
string value = GetString(key, removeQuotes: false);

if (!string.IsNullOrEmpty(value))
{
try
{
return line.Substring(key.Length + 1).Split(',').Select(CleanValue).ToArray();
return value.Split(',').Select(entry => CleanValue(entry)).ToArray();
}
catch (Exception e)
{
Expand Down