Skip to content
Merged
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
2 changes: 1 addition & 1 deletion src/libraries/System.Private.Uri/src/System/Uri.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3855,7 +3855,7 @@ str[delimiterIdx] is not ('/' or '\\') &&
// Here we have checked the syntax up to the end of host
// The only thing that can cause an exception is the port value
// Spend some (duplicated) cycles on that.
else if (hostDelimiter == ':')
else if (hostDelimiter == ':' && hostLength != 0)
{
if ((syntaxFlags & UriSyntaxFlags.MayHavePort) != 0)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,9 @@ public static IEnumerable<object[]> Scheme_Authority_TestData()
yield return new object[] { "unknown://h.-/", "unknown", "", "h.-", UriHostNameType.Basic, -1, true, false };
yield return new object[] { "unknown://h._", "unknown", "", "h._", UriHostNameType.Basic, -1, true, false };
yield return new object[] { "unknown://", "unknown", "", "", UriHostNameType.Basic, -1, true, true };
yield return new object[] { "unknown:///path", "unknown", "", "", UriHostNameType.Basic, -1, true, true };
yield return new object[] { "unknown://?query", "unknown", "", "", UriHostNameType.Basic, -1, true, true };
yield return new object[] { "unknown://#fragment", "unknown", "", "", UriHostNameType.Basic, -1, true, true };

// Mailto
yield return new object[] { "mailto:", "mailto", "", "", UriHostNameType.Basic, 25, true, true };
Expand Down Expand Up @@ -372,6 +375,9 @@ public static IEnumerable<object[]> Scheme_Authority_TestData()
yield return new object[] { "unknown:", "unknown", "", "", UriHostNameType.Unknown, -1, true, false };
yield return new object[] { "unknown:path", "unknown", "", "", UriHostNameType.Unknown, -1, true, false };
yield return new object[] { "unknown://host", "unknown", "", "host", UriHostNameType.Dns, -1, true, false };
yield return new object[] { "unknown://a:80", "unknown", "", "a", UriHostNameType.Dns, 80, false, false };
yield return new object[] { "unknown://ab:80", "unknown", "", "ab", UriHostNameType.Dns, 80, false, false };
yield return new object[] { "unknown://host:80", "unknown", "", "host", UriHostNameType.Dns, 80, false, false };
yield return new object[] { "unknown://userinfo@host", "unknown", "userinfo", "host", UriHostNameType.Dns, -1, true, false };
yield return new object[] { "unknown://userinfo@host:80", "unknown", "userinfo", "host", UriHostNameType.Dns, 80, false, false };
yield return new object[] { "unknown://./", "unknown", "", ".", UriHostNameType.Basic, -1, true, false };
Expand Down Expand Up @@ -1274,6 +1280,17 @@ public static IEnumerable<object[]> Create_String_Invalid_TestData()
yield return new object[] { "uri://a:2147483648", UriKind.Absolute };
yield return new object[] { "uri://a:80:80", UriKind.Absolute };

// Unknown scheme with no host and a port
yield return new object[] { "tcp://:11111", UriKind.Absolute };
yield return new object[] { "udp://:11111", UriKind.Absolute };
yield return new object[] { "unix://:11111", UriKind.Absolute };
yield return new object[] { "unknown://:80", UriKind.Absolute };
yield return new object[] { "unknown://:80/path", UriKind.Absolute };
yield return new object[] { "unknown://:80?query", UriKind.Absolute };
yield return new object[] { "unknown://:80#fragment", UriKind.Absolute };
yield return new object[] { "unknown://userinfo@:80", UriKind.Absolute };
yield return new object[] { "unknown://userinfo@", UriKind.Absolute };

if (PlatformDetection.IsNotInvariantGlobalization)
{
// Invalid unicode
Expand Down
Loading