Upgrade crypto provider, retarget better framework

This commit is contained in:
Phallacy
2019-01-31 00:24:53 -08:00
parent 49d9649b8e
commit 4519ce26e2
5 changed files with 248 additions and 57 deletions

View File

@@ -4,6 +4,7 @@ using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using MediaBrowser.Common.Events;
@@ -220,22 +221,20 @@ namespace Emby.Server.Implementations.Library
}
}
public bool IsValidUsername(string username)
{
// Usernames can contain letters (a-z), numbers (0-9), dashes (-), underscores (_), apostrophes ('), and periods (.)
foreach (var currentChar in username)
{
if (!IsValidUsernameCharacter(currentChar))
{
return false;
}
}
return true;
}
private static bool IsValidUsernameCharacter(char i)
{
return !char.Equals(i, '<') && !char.Equals(i, '>');
public 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-'._@]*$";
// Usernames can contain letters (a-z + whatever else unicode is cool with), numbers (0-9), dashes (-), underscores (_), apostrophes ('), and periods (.)
return Regex.IsMatch(username, UserNameRegex);
}
private static bool IsValidUsernameCharacter(char i)
{
string UserNameRegex = "^[\\w-'._@]*$";
return Regex.IsMatch(i.ToString(), UserNameRegex);
}
public string MakeValidUsername(string username)