Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PM-15392] Decode Foreign Encodings at User Creation #5082

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.ComponentModel.DataAnnotations;
using System.Net;
using System.Text.Json;
using Bit.Core;
using Bit.Core.Auth.Models.Api;
Expand Down Expand Up @@ -37,7 +38,7 @@ public User ToUser()
{
var user = new User
{
Name = Name,
Name = WebUtility.HtmlDecode(Name),
Email = Email,
MasterPasswordHint = MasterPasswordHint,
Kdf = Kdf.GetValueOrDefault(KdfType.PBKDF2_SHA256),
Expand Down
27 changes: 27 additions & 0 deletions test/Identity.IntegrationTest/Endpoints/IdentityServerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Bit.Core.AdminConsole.Entities;
using Bit.Core.AdminConsole.Enums;
using Bit.Core.AdminConsole.Repositories;
using Bit.Core.Entities;
using Bit.Core.Enums;
using Bit.Core.Repositories;
using Bit.Identity.IdentityServer;
Expand Down Expand Up @@ -515,6 +516,32 @@ public async Task TokenEndpoint_GrantTypeClientCredentials_AsInstallation_BadIns
Assert.Equal("invalid_client", error);
}

[Fact]
public void EncodedNameGetsDecoded()
{
RegisterRequestModel model = new RegisterRequestModel
{
Name = "Windmüller"
};

User user = model.ToUser();

Assert.Equal("Windmüller", user.Name);
}

[Fact]
public void DecodedNameStaysTheSame()
{
RegisterRequestModel model = new RegisterRequestModel
{
Name = "Windmüller"
};

User user = model.ToUser();

Assert.Equal("Windmüller", user.Name);
}

/// <inheritdoc cref="TokenEndpoint_GrantTypeClientCredentials_AsOrganization_NoIdPart_Fails"/>
[Fact]
public async Task TokenEndpoint_GrantTypeClientCredentials_AsInstallation_NoIdPart_Fails()
Expand Down
Loading