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

DotNet 5.0 IdnMapping.GetAscii throws ArgumentException #60478

Closed
HelenMakarchuk opened this issue Oct 15, 2021 · 5 comments
Closed

DotNet 5.0 IdnMapping.GetAscii throws ArgumentException #60478

HelenMakarchuk opened this issue Oct 15, 2021 · 5 comments
Labels
area-System.Globalization needs-further-triage Issue has been initially triaged, but needs deeper consideration or reconsideration
Milestone

Comments

@HelenMakarchuk
Copy link

Description

I wrote an example console application:

  1. Get current DotNet version
  2. Then get ASCII from latine string (each label equals to or less 63 symbols long, total string length (including dots) is 254 symbols long)
static void Main(string[] args)
{
    Console.WriteLine("Environment.Version: " + Environment.Version);

    new IdnMapping().GetAscii(
        "sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss." +
        "sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss." +
        "sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss." +
        "ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss");

    Console.WriteLine("Hello World!");
}

When I run program on .Net Core 3.1 output is:

Environment.Version: 3.1.13
Hello World!

When I run program on .Net 5.0 output is:

Environment.Version: 5.0.9
Unhandled exception. System.ArgumentException: Decoded string is not a valid IDN name. (Parameter 'unicode')
   at System.Globalization.IdnMapping.IcuGetAsciiCore(String unicodeString, Char* unicode, Int32 count)
   at System.Globalization.IdnMapping.GetAscii(String unicode, Int32 index, Int32 count)
   at System.Globalization.IdnMapping.GetAscii(String unicode, Int32 index)
   at System.Globalization.IdnMapping.GetAscii(String unicode)
   at Program.Main(String[] args)

Are there any breaking changes in DotNet 5 for IdnMapping?
What requirements should be for an input string (characters count, known encoding dependencies, etc)?

Configuration

Version of .NET: 3.1.13, 5.0.9
OS: Windows 10 Enterprise 20H2 (build 19042.1237)
PC Architecture: x64
IDE: Microsoft Visual Studio Community 2019 (version 16.9.2)
Solution platform: ANY CPU

@steveharter steveharter transferred this issue from dotnet/core Oct 15, 2021
@dotnet-issue-labeler
Copy link

I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.

@dotnet-issue-labeler dotnet-issue-labeler bot added the untriaged New issue has not been triaged by the area owner label Oct 15, 2021
@ghost
Copy link

ghost commented Oct 15, 2021

Tagging subscribers to this area: @tarekgh, @safern
See info in area-owners.md if you want to be subscribed.

Issue Details

Description

I wrote an example console application:

  1. Get current DotNet version
  2. Then get ASCII from latine string (each label equals to or less 63 symbols long, total string length (including dots) is 254 symbols long)
static void Main(string[] args)
{
    Console.WriteLine("Environment.Version: " + Environment.Version);

    new IdnMapping().GetAscii(
        "sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss." +
        "sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss." +
        "sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss." +
        "ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss");

    Console.WriteLine("Hello World!");
}

When I run program on .Net Core 3.1 output is:

Environment.Version: 3.1.13
Hello World!

When I run program on .Net 5.0 output is:

Environment.Version: 5.0.9
Unhandled exception. System.ArgumentException: Decoded string is not a valid IDN name. (Parameter 'unicode')
   at System.Globalization.IdnMapping.IcuGetAsciiCore(String unicodeString, Char* unicode, Int32 count)
   at System.Globalization.IdnMapping.GetAscii(String unicode, Int32 index, Int32 count)
   at System.Globalization.IdnMapping.GetAscii(String unicode, Int32 index)
   at System.Globalization.IdnMapping.GetAscii(String unicode)
   at Program.Main(String[] args)

Are there any breaking changes in DotNet 5 for IdnMapping?
What requirements should be for an input string (characters count, known encoding dependencies, etc)?

Configuration

Version of .NET: 3.1.13, 5.0.9
OS: Windows 10 Enterprise 20H2 (build 19042.1237)
PC Architecture: x64
IDE: Microsoft Visual Studio Community 2019 (version 16.9.2)
Solution platform: ANY CPU

Author: HelenMakarchuk
Assignees: -
Labels:

area-System.Globalization, untriaged

Milestone: -

@tarekgh tarekgh removed the untriaged New issue has not been triaged by the area owner label Oct 15, 2021
@tarekgh tarekgh added this to the Future milestone Oct 15, 2021
@tarekgh
Copy link
Member

tarekgh commented Oct 15, 2021

@HelenMakarchuk in .NET 5.0 we have switched to use ICU library. In .NET 3.1 we were using the native Windows NLS APIs for IDN. you can learn more about this change in the doc.

Looking at the case in your repro, looks the length of the string is what is causing the failure. If I remove just one character from the end of the string, it will succeed. if you want to go back to old behavior (which we don't recommend doing that as ICU behavior is more correct), you may follow this instructions. Let me know if you need any more help if you are blocked.

@tarekgh
Copy link
Member

tarekgh commented Oct 15, 2021

I confirmed that ICU is failing the call with the info error UIDNA_ERROR_DOMAIN_NAME_TOO_LONG because of the length.

@HelenMakarchuk
Copy link
Author

Thank you for the detailed answer

@ghost ghost added needs-further-triage Issue has been initially triaged, but needs deeper consideration or reconsideration and removed needs more info labels Oct 15, 2021
@tarekgh tarekgh closed this as completed Oct 15, 2021
@ghost ghost locked as resolved and limited conversation to collaborators Nov 15, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-System.Globalization needs-further-triage Issue has been initially triaged, but needs deeper consideration or reconsideration
Projects
None yet
Development

No branches or pull requests

3 participants