Fixed single quote in filename not working

This commit is contained in:
N00MKRAD
2021-01-14 14:52:21 +01:00
parent 63ef217e31
commit 2a9c7a79a9
3 changed files with 3 additions and 15 deletions

View File

@@ -108,7 +108,7 @@ namespace Flowframes
public static string StripBadChars(this string str)
{
string outStr = Regex.Replace(str, @"[^\u0020-\u007E]", string.Empty);
outStr = outStr.Replace("(", "").Replace(")", "").Replace("[", "").Replace("]", "").Replace("{", "").Replace("}", "").Replace("%", "");
outStr = outStr.Remove("(").Remove(")").Remove("[").Remove("]").Remove("{").Remove("}").Remove("%").Remove("'");
return outStr;
}
@@ -124,17 +124,6 @@ namespace Flowframes
return str.Replace(stringToRemove, "");
}
public static string TrimWhitespacesSafe (this string str) // Trim whitespaces, unless they are "quoted" (to avoid trimming file paths)
{
var result = str.Split('"').Select((element, index) => index % 2 == 0 ? element.TrimWhitespaces() : element.Wrap());
string resultJoined = string.Join("", result);
result = resultJoined.Split('\'').Select((element, index) => index % 2 == 0 ? element.TrimWhitespaces() : "'" + element + "'");
resultJoined = string.Join("", result);
return resultJoined;
}
public static string TrimWhitespaces(this string str)
{
if (str == null) return str;