(3be596a23) Don't allow using invalid filename characters in a save name. Fixes crashing when attempting to use symbols such as <, > or | in the name.
This commit is contained in:
@@ -119,6 +119,16 @@ namespace Barotrauma
|
||||
return true;
|
||||
}
|
||||
|
||||
public static string RemoveInvalidFileNameChars(string fileName)
|
||||
{
|
||||
var invalidChars = Path.GetInvalidFileNameChars();
|
||||
foreach (char invalidChar in invalidChars)
|
||||
{
|
||||
fileName = fileName.Replace(invalidChar.ToString(), "");
|
||||
}
|
||||
return fileName;
|
||||
}
|
||||
|
||||
public static string LimitString(string str, int maxCharacters)
|
||||
{
|
||||
if (str == null || maxCharacters < 0) return null;
|
||||
|
||||
Reference in New Issue
Block a user