[Mono-dev] Possible issue with Uri.cs

SilentBob cinnamondonkey at gmail.com
Wed May 14 14:56:08 UTC 2014


Hi, 

I am seeing an issue with XmlDocument  .Load() always throwing an exception.
I have studied the code in the class library and noticed the following issue
that can be narrowed down to Uri.cs. 

    Path.GetFullPath("dev0:/dir1/dir2") => "//dev0:/dir1/dir2"
    Uri(Path.GetFullPath("dev0:/dir1/dir2")) => "file:///dev0:/dir1/dir2"

Note '///' in XmlDocument seems to cause a problem with FileStream which
throws and exception along the lines of can not find path
"/dev0:/dir1/dir2".

FileStream only seems happy seeing the following format: "dev0:/dir1/dir2"

Looking at Uri.cs I can see: 

		private void ParseAsUnixAbsoluteFilePath (string uriString)
		{
			isUnixFilePath = true;
			scheme = UriSchemeFile;
			port = -1;
			fragment = String.Empty;
			query = String.Empty;
			host = String.Empty;
			path = null;

			if (uriString.Length >= 2 && uriString [0] == '/' && uriString [1] ==
'/') {
				uriString = uriString.TrimStart (new char [] {'/'});
				// Now we don't regard //foo/bar as "foo" host.
				/* 
				int pos = uriString.IndexOf ('/');
				if (pos > 0) {
					path = '/' + uriString.Substring (pos + 1);
					host = uriString.Substring (0, pos);
				} else { // "///server"
					host = uriString;
					path = String.Empty;
				}
				*/
				path = '/' + uriString;
			}
			if (path == null)
				path = uriString;
		}


Why is the code doing:

    path = '/' + uriString;

After stripping the leading '//' ? 

I'm assuming at some point the library simply tags on or removes "file://"
as required.

Regards,
Shaun



--
View this message in context: http://mono.1490590.n4.nabble.com/Possible-issue-with-Uri-cs-tp4662793.html
Sent from the Mono - Dev mailing list archive at Nabble.com.


More information about the Mono-devel-list mailing list