Bug 79 - Uri class makes file:// uri's instead of relative ones
Summary: Uri class makes file:// uri's instead of relative ones
Status: RESOLVED INVALID
Alias: None
Product: Class Libraries
Classification: Mono
Component: System ()
Version: master
Hardware: PC Linux
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2011-07-27 04:30 UTC by Yves Bastide
Modified: 2012-01-23 12:04 UTC (History)
3 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED INVALID

Description Yves Bastide 2011-07-27 04:30:39 UTC
csharp> using System.Net;
csharp> new Uri("/interstitial?url=http://malware-infected.site");
file:///interstitial?url=http://malware-infected.site

.Net keeps the relative URI "/interstitial?url=http://malware-infected.site".
Comment 1 Sebastien Pouliot 2011-09-07 16:03:30 UTC
/interstitial?url=http://malware-infected.site
is a valid Unix file name, while it's not for Windows - it's one of the few places where Uri differs from MS (we had a very test suite for it when we tested Moonlight)
Comment 2 Yves Bastide 2011-09-07 18:02:05 UTC
Yep. And I guess scheme-less Uri's must be converted to file:// if locally valid?

This does work though, and may be OK for our use cases:
csharp> new Uri(new Uri("http://www.google.com"), new Uri("/interstitial?url=http://malware-infected.site"));
http://www.google.com/interstitial?url=http://malware-infected.site

Thanks,

yves
Comment 3 Lionel 2012-01-23 12:04:10 UTC
Even if /myfile.html is a valid uri in unix, should it be considered as relative or absolute? I'd say relative, but Mono/Linux says relative ... and absolute! Isn't is inconsistent (or should I go back reading the RFC)? At least, there should be some warning in the doc (I had the bad suprise while debugging an application we're porting from Windows to Linux).

Ex:

string uri = "/myfile.html"

** An url can be absolute and relative? **
Uri.IsWellFormedUriString(uri, UriKind.Relative) -> yes
Uri.IsWellFormedUriString(uri, UriKind.Absolute) -> yes. weird! Both???

** Inconsistent result? **
Uri.TryCreate(uri, UriKind.Absolute, out tmp) -> tmp = file:///myfile.html
Uri.TryCreate(uri, UriKind.Relative, out tmp) -> tmp = /myfile.html
Uri.TryCreate(uri, UriKind.RelativeOrAbsolute, out tmp) -> tmp = file:///myfile.html