Bug 43032 - System.Uri cannot parse url with underscore at start
Summary: System.Uri cannot parse url with underscore at start
Alias: None
Product: Class Libraries
Classification: Mono
Component: System (show other bugs)
Version: 4.4.0 (C7)
Hardware: PC Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Marek Safar
Depends on:
Blocks: 42985
  Show dependency tree
Reported: 2016-08-03 17:38 UTC by Matt Ward
Modified: 2016-10-06 09:21 UTC (History)
3 users (show)

See Also:
Is this bug a regression?: Yes
Last known good build:


Description Matt Ward 2016-08-03 17:38:04 UTC
To repro:

Create a console app that runs the following line of code:

    var uri = new Uri ("https://_foo/bar.html");

Expected result:

The url is parsed.

Actual result:

System.UriFormatException: Invalid URI: The hostname could not be parsed.
  at System.Uri.Parse (UriKind kind, System.String uriString) [0x00020] in /private/tmp/source-mono-4.4.0-c7sr1/bockbuild-mono-4.4.0-branch-c7sr1/profiles/mono-mac-xamarin/build-root/mono-x86/mcs/class/System/System/Uri.cs:1306 
  at System.Uri.ParseUri (UriKind kind) [0x00000] in /private/tmp/source-mono-4.4.0-c7sr1/bockbuild-mono-4.4.0-branch-c7sr1/profiles/mono-mac-xamarin/build-root/mono-x86/mcs/class/System/System/Uri.cs:1176 
  at System.Uri..ctor (System.String uriString, Boolean dontEscape) [0x00059] in /private/tmp/source-mono-4.4.0-c7sr1/bockbuild-mono-4.4.0-branch-c7sr1/profiles/mono-mac-xamarin/build-root/mono-x86/mcs/class/System/System/Uri.cs:282 
  at System.Uri..ctor (System.String uriString) [0x00000] in /private/tmp/source-mono-4.4.0-c7sr1/bockbuild-mono-4.4.0-branch-c7sr1/profiles/mono-mac-xamarin/build-root/mono-x86/mcs/class/System/System/Uri.cs:160 

On Windows the code works without any exception being thrown.

Mono 4.4.2 (mono-4.4.0-branch-c7sr1/f72fe45 Wed Jul 27 16:20:13 EDT 2016)
Comment 1 Marek Safar 2016-08-09 17:55:37 UTC
Fixed in master and Mono 4.6

Note You need to log in before you can comment on or make changes to this bug.