From 6523841d45aa39f407993545a38d764ad2bb8a19 Mon Sep 17 00:00:00 2001 From: Ben Sanecki Date: Mon, 16 Oct 2023 20:36:11 -0500 Subject: [PATCH 1/3] allows for plus in username, addresses issue #10414 --- Jellyfin.Server.Implementations/Users/UserManager.cs | 2 +- .../Users/UserManagerTests.cs | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Jellyfin.Server.Implementations/Users/UserManager.cs b/Jellyfin.Server.Implementations/Users/UserManager.cs index 94ac4798ca..7b3bea4b40 100644 --- a/Jellyfin.Server.Implementations/Users/UserManager.cs +++ b/Jellyfin.Server.Implementations/Users/UserManager.cs @@ -103,7 +103,7 @@ namespace Jellyfin.Server.Implementations.Users // 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 // Usernames can contain letters (a-z + whatever else unicode is cool with), numbers (0-9), at-signs (@), dashes (-), underscores (_), apostrophes ('), periods (.) and spaces ( ) - [GeneratedRegex("^[\\w\\ \\-'._@]+$")] + [GeneratedRegex("^[\\w\\ \\-\\+'._@]+$")] private static partial Regex ValidUsernameRegex(); /// diff --git a/tests/Jellyfin.Server.Implementations.Tests/Users/UserManagerTests.cs b/tests/Jellyfin.Server.Implementations.Tests/Users/UserManagerTests.cs index 867dda29d6..da6d492d2b 100644 --- a/tests/Jellyfin.Server.Implementations.Tests/Users/UserManagerTests.cs +++ b/tests/Jellyfin.Server.Implementations.Tests/Users/UserManagerTests.cs @@ -9,7 +9,12 @@ namespace Jellyfin.Server.Implementations.Tests.Users [Theory] [InlineData("this_is_valid")] [InlineData("this is also valid")] + [InlineData("this+too")] [InlineData("0@_-' .")] + [InlineData("john+doe")] + [InlineData("JöhnDøë")] + [InlineData("Jö hn+Døë")] + [InlineData("Jö hn+Døë@")] public void ThrowIfInvalidUsername_WhenValidUsername_DoesNotThrowArgumentException(string username) { var ex = Record.Exception(() => UserManager.ThrowIfInvalidUsername(username)); From 85d2db25f81a7ef238515c422b5db21400b8cf06 Mon Sep 17 00:00:00 2001 From: Ben Sanecki Date: Tue, 24 Oct 2023 12:36:26 -0500 Subject: [PATCH 2/3] Update Jellyfin.Server.Implementations/Users/UserManager.cs, include + in comments Co-authored-by: Patrick Barron --- Jellyfin.Server.Implementations/Users/UserManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jellyfin.Server.Implementations/Users/UserManager.cs b/Jellyfin.Server.Implementations/Users/UserManager.cs index 7b3bea4b40..8882a9d76d 100644 --- a/Jellyfin.Server.Implementations/Users/UserManager.cs +++ b/Jellyfin.Server.Implementations/Users/UserManager.cs @@ -100,7 +100,7 @@ namespace Jellyfin.Server.Implementations.Users /// public IEnumerable UsersIds => _users.Keys; - // This is some regex that matches only on unicode "word" characters, as well as -, _ and @ + // 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 // Usernames can contain letters (a-z + whatever else unicode is cool with), numbers (0-9), at-signs (@), dashes (-), underscores (_), apostrophes ('), periods (.) and spaces ( ) [GeneratedRegex("^[\\w\\ \\-\\+'._@]+$")] From c82b15f07ca25d132cd3ac5b254042f0513f2591 Mon Sep 17 00:00:00 2001 From: Ben Sanecki Date: Wed, 15 Nov 2023 17:16:17 -0600 Subject: [PATCH 3/3] updating comment --- Jellyfin.Server.Implementations/Users/UserManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jellyfin.Server.Implementations/Users/UserManager.cs b/Jellyfin.Server.Implementations/Users/UserManager.cs index 4eb2b7b602..5a55dd38eb 100644 --- a/Jellyfin.Server.Implementations/Users/UserManager.cs +++ b/Jellyfin.Server.Implementations/Users/UserManager.cs @@ -107,7 +107,7 @@ namespace Jellyfin.Server.Implementations.Users // 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 - // Usernames can contain letters (a-z + whatever else unicode is cool with), numbers (0-9), at-signs (@), dashes (-), underscores (_), apostrophes ('), periods (.) and spaces ( ) + // Usernames can contain letters (a-z + whatever else unicode is cool with), numbers (0-9), at-signs (@), dashes (-), underscores (_), apostrophes ('), periods (.), plus-signs (+), and spaces ( ) [GeneratedRegex("^[\\w\\ \\-\\+'._@]+$")] private static partial Regex ValidUsernameRegex();