You've already forked linux-packaging-mono
Imported Upstream version 4.2.1.36
Former-commit-id: fb75898888a02f4d3a74cf0a5b841681bc4c7fa8
This commit is contained in:
committed by
Jo Shields
parent
9668de7cb8
commit
dd547c45d4
@@ -442,8 +442,10 @@ namespace System.Net.NetworkInformation {
|
||||
|
||||
unsafe void OnDataAvailable (object sender, SocketAsyncEventArgs args)
|
||||
{
|
||||
if (nl_sock == null) // Recent changes in Mono cause MaybeCloseSocket to be called before OnDataAvailable
|
||||
return;
|
||||
EventType type;
|
||||
fixed (byte *ptr = args.Buffer) {
|
||||
fixed (byte *ptr = args.Buffer) {
|
||||
type = ReadEvents (nl_sock.Handle, new IntPtr (ptr), args.BytesTransferred, 8192);
|
||||
}
|
||||
nl_sock.ReceiveAsync (nl_args);
|
||||
|
@@ -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 &&
|
||||
|
@@ -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);
|
||||
|
@@ -387,6 +387,13 @@ namespace MonoTests.System
|
||||
// this is what ASP.NET really means (the ?)
|
||||
Assert.AreEqual ("http://192.168.0.21/error404.aspx?aspxerrorpath=/WebResource.axd", ub.Uri.ToString ());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void NoHostname ()
|
||||
{
|
||||
UriBuilder ub = new UriBuilder ("about", null, -1, "config");
|
||||
Assert.AreEqual ("about:config", ub.ToString ());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -1946,12 +1946,44 @@ namespace MonoTests.System
|
||||
[Test]
|
||||
public void DotNetRelativeOrAbsoluteTest ()
|
||||
{
|
||||
var uri1 = new Uri ("/foo", DotNetRelativeOrAbsolute);
|
||||
Assert.IsFalse (uri1.IsAbsoluteUri);
|
||||
|
||||
Uri uri2;
|
||||
Uri.TryCreate("/foo", DotNetRelativeOrAbsolute, out uri2);
|
||||
Assert.IsFalse (uri2.IsAbsoluteUri);
|
||||
FieldInfo useDotNetRelativeOrAbsoluteField = null;
|
||||
bool useDotNetRelativeOrAbsoluteOld = false;
|
||||
|
||||
if (Type.GetType ("Mono.Runtime") != null) {
|
||||
useDotNetRelativeOrAbsoluteField = typeof (Uri).GetField ("useDotNetRelativeOrAbsolute",
|
||||
BindingFlags.Static | BindingFlags.GetField | BindingFlags.NonPublic);
|
||||
useDotNetRelativeOrAbsoluteOld = (bool) useDotNetRelativeOrAbsoluteField.GetValue (null);
|
||||
useDotNetRelativeOrAbsoluteField.SetValue (null, false);
|
||||
}
|
||||
|
||||
try {
|
||||
Uri uri;
|
||||
|
||||
uri = new Uri ("/foo", DotNetRelativeOrAbsolute);
|
||||
Assert.IsFalse (uri.IsAbsoluteUri);
|
||||
|
||||
Uri.TryCreate("/foo", DotNetRelativeOrAbsolute, out uri);
|
||||
Assert.IsFalse (uri.IsAbsoluteUri);
|
||||
|
||||
if (useDotNetRelativeOrAbsoluteField != null) {
|
||||
uri = new Uri ("/foo", UriKind.RelativeOrAbsolute);
|
||||
Assert.IsTrue (uri.IsAbsoluteUri);
|
||||
|
||||
Uri.TryCreate("/foo", UriKind.RelativeOrAbsolute, out uri);
|
||||
Assert.IsTrue (uri.IsAbsoluteUri);
|
||||
|
||||
useDotNetRelativeOrAbsoluteField.SetValue (null, true);
|
||||
}
|
||||
|
||||
uri = new Uri ("/foo", UriKind.RelativeOrAbsolute);
|
||||
Assert.IsFalse (uri.IsAbsoluteUri);
|
||||
|
||||
Uri.TryCreate("/foo", DotNetRelativeOrAbsolute, out uri);
|
||||
Assert.IsFalse (uri.IsAbsoluteUri);
|
||||
} finally {
|
||||
if (useDotNetRelativeOrAbsoluteField != null)
|
||||
useDotNetRelativeOrAbsoluteField.SetValue (null, useDotNetRelativeOrAbsoluteOld);
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
Reference in New Issue
Block a user