microsoft / dotnet

This repo is the official home of .NET on GitHub. It's a great starting point to find many .NET OSS projects from Microsoft and the community, including many that are part of the .NET Foundation.
https://devblogs.microsoft.com/dotnet/
MIT License
14.34k stars 2.21k forks source link

DotNet 5.0 IdnMapping.GetAscii throws ArgumentException #1328

Closed HelenMakarchuk closed 2 years ago

HelenMakarchuk commented 2 years ago

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?

HelenMakarchuk commented 2 years ago

recreated in Core project https://github.com/dotnet/core/issues/6809