Bug 43032

Summary: System.Uri cannot parse url with underscore at start
Product: [Mono] Class Libraries Reporter: Matt Ward <matt.ward>
Component: SystemAssignee: Marek Safar <masafa>
Severity: normal CC: masafa, mono-bugs+mono, prashantm
Priority: ---    
Version: 4.4.0 (C7)   
Target Milestone: Untriaged   
Hardware: PC   
OS: Mac OS   
Related Links: https://bugzilla.xamarin.com/show_bug.cgi?id=44449
Tags: Is this bug a regression?: Yes
Last known good build:
Bug Depends on:    
Bug Blocks: 42985    

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