Minor fixes re:PR870, added null checks from PR876

This commit is contained in:
Phallacy
2019-02-13 00:33:00 -08:00
parent 1ffd443d5a
commit 77602aff88
5 changed files with 124 additions and 98 deletions

View File

@@ -217,9 +217,8 @@ namespace Emby.Server.Implementations.Library
}
}
public bool IsValidUsername(string username)
public static bool IsValidUsername(string username)
{
//The old way was dumb, we should make it less dumb, lets do so.
//This is some regex that matches only on unicode "word" characters, as well as -, _ and @
//In theory this will cut out most if not all 'control' characters which should help minimize any weirdness
string UserNameRegex = "^[\\w-'._@]*$";
@@ -229,8 +228,7 @@ namespace Emby.Server.Implementations.Library
private static bool IsValidUsernameCharacter(char i)
{
string UserNameRegex = "^[\\w-'._@]*$";
return Regex.IsMatch(i.ToString(), UserNameRegex);
return IsValidUsername(i.ToString());
}
public string MakeValidUsername(string username)