Imported Upstream version 4.2.1.36

Former-commit-id: f3008ca867fe7e4b7ae9b9a8844c0ad5798925a9
This commit is contained in:
Xamarin Public Jenkins
2015-09-24 06:06:07 -04:00
committed by Jo Shields
parent afe402035c
commit ea5caba957
172 changed files with 6570 additions and 11015 deletions

View File

@@ -96,6 +96,12 @@ namespace System {
set { s_IriParsing = value; }
}
// Do not rename this.
// User code might set this to true with reflection.
// When set to true an Uri constructed with UriKind.RelativeOrAbsolute
// and paths such as "/foo" is assumed relative.
private static bool useDotNetRelativeOrAbsolute;
#if BOOTSTRAP_BASIC
private static readonly string hexUpperChars = "0123456789ABCDEF";
private static readonly string [] Empty = new string [0];
@@ -147,6 +153,8 @@ namespace System {
IriParsing = true;
else if (iriparsingVar == "false")
IriParsing = false;
useDotNetRelativeOrAbsolute = Environment.GetEnvironmentVariable ("MONO_URI_DOTNETRELATIVEORABSOLUTE") == "true";
}
public Uri (string uriString) : this (uriString, false)
@@ -173,12 +181,21 @@ namespace System {
// When used instead of UriKind.RelativeOrAbsolute paths such as "/foo" are assumed relative.
const UriKind DotNetRelativeOrAbsolute = (UriKind) 300;
private void ProcessUriKind (string uriString, ref UriKind uriKind)
{
if (uriString == null)
return;
if (uriKind == DotNetRelativeOrAbsolute ||
(uriKind == UriKind.RelativeOrAbsolute && useDotNetRelativeOrAbsolute))
uriKind = (uriString.StartsWith ("/", StringComparison.Ordinal))? UriKind.Relative : UriKind.RelativeOrAbsolute;
}
public Uri (string uriString, UriKind uriKind)
{
source = uriString;
if (uriString != null && uriKind == DotNetRelativeOrAbsolute)
uriKind = (uriString.StartsWith ("/", StringComparison.Ordinal))? UriKind.Relative : UriKind.RelativeOrAbsolute;
ProcessUriKind (uriString, ref uriKind);
ParseUri (uriKind);
@@ -212,8 +229,7 @@ namespace System {
return;
}
if (uriKind == DotNetRelativeOrAbsolute)
uriKind = (uriString.StartsWith ("/", StringComparison.Ordinal))? UriKind.Relative : UriKind.RelativeOrAbsolute;
ProcessUriKind (uriString, ref uriKind);
if (uriKind != UriKind.RelativeOrAbsolute &&
uriKind != UriKind.Absolute &&

View File

@@ -263,7 +263,12 @@ namespace System
builder.Append (scheme);
// note: mailto and news use ':', not "://", as their delimiter
builder.Append (Uri.GetSchemeDelimiter (scheme));
if (UriParser.IsKnownScheme(scheme)) {
builder.Append (Uri.GetSchemeDelimiter (scheme));
}
else {
builder.Append (host.Length > 0 ? Uri.SchemeDelimiter : ":");
}
if (username != String.Empty) {
builder.Append (username);
@@ -280,7 +285,8 @@ namespace System
if (path != String.Empty &&
builder [builder.Length - 1] != '/' &&
path.Length > 0 && path [0] != '/')
path.Length > 0 && path [0] != '/' &&
host.Length > 0)
builder.Append ('/');
builder.Append (path);
builder.Append (query);