Username with German or French letters gets encoded and passes validation ASP.NET Core Identity
See original GitHub issueOn .Net Core 3.0 Preview 3, Asp.NET Core Identity Template, register a user with username
bernhard@günter.com
Expected
Validation responds that this is not an allowed character for a username since the default is
public string AllowedUserNameCharacters { get; set; } = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._@+";
Result
bernhard@xn--gnter-kva.com
is stored in the db as username and email and displayed in the UI!
That is pretty unexpected for an old framework and a handicap in the current implementation. Probably this has been encountered in the past??
Issue Analytics
- State:
- Created 4 years ago
- Comments:36 (36 by maintainers)
Top Results From Across the Web
Username with German or French letters gets encoded and ...
NET Core Identity Username with German or French letters gets encoded and passes validation ASP.NET Core Identity on Apr 5, 2019.
Read more >Error with German character in Asp.Net Core Identity
Usermanager validates the username by checking if there is any character not contained in the list of allowed characters.
Read more >How to use character encoding classes in .NET
This article explains how to use the classes that .NET provides for encoding and decoding text by using various encoding schemes.
Read more >OpenID Connect Core 1.0 incorporating errata set 1
It enables Clients to verify the identity of the End-User based on the authentication performed by an Authorization Server, as well as to...
Read more >Building Multilingual Applications in ASP.NET Core
For this tutorial, I want to support French, German, and English languages so let's configure these three cultures as shown below: ? 1....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Yep, that’s because the MVC 5.x templates use
Html.TextBoxFor
for the email/username field. If you switch toHtml.EditorFor
, it will take theEmailAddress
attribute into account and you’ll see a similar behavior.At best, Identity’s UI could try to proactively “punydecode” the username/email fields back to their real Unicode representation and validate them after that. Whether it’s a good idea or something rather fragile is what @blowdart will have to determine 😄
Still dwelling upon this issue. I found out that when client side validation is enabled we get some weird behavior:
For a@ü.com Client side validation enabled FF refuses the post with error “Please enter a valid email address” Edge same as FF Chrome allows the post and sends you the punycode a@xn–tda.com
For a@ü.com Client side validation disabled FF allows the post and sends the raw value a@ü.com Edge still silly, it refuses the post and displays its default error “You must enter a valid email address” Chrome allows the post and sends you the punycode a@xn–tda.com
In short, Chrome does not care about client side validation, whereas FF will work only if client side val is disabled, Edge refuses unicode altogether. Two problems:
Any thought?