You've already forked linux-packaging-mono
Imported Upstream version 3.10.0
Former-commit-id: 172c8e3c300b39d5785c7a3e8dfb08ebdbc1a99b
This commit is contained in:
@@ -38,12 +38,15 @@ using MSX = Mono.Security.X509;
|
||||
namespace System {
|
||||
|
||||
internal static class AndroidPlatform {
|
||||
|
||||
delegate int GetInterfaceAddressesDelegate (out IntPtr ifap);
|
||||
delegate void FreeInterfaceAddressesDelegate (IntPtr ifap);
|
||||
|
||||
#if SECURITY_DEP
|
||||
static readonly Converter<List <byte[]>, bool> trustEvaluateSsl;
|
||||
#endif // SECURITY_DEP
|
||||
static readonly Func<IWebProxy> getDefaultProxy;
|
||||
|
||||
static readonly GetInterfaceAddressesDelegate getInterfaceAddresses;
|
||||
static readonly FreeInterfaceAddressesDelegate freeInterfaceAddresses;
|
||||
|
||||
static AndroidPlatform ()
|
||||
{
|
||||
@@ -60,6 +63,16 @@ namespace System {
|
||||
typeof (Func<IWebProxy>), t, "GetDefaultProxy",
|
||||
ignoreCase:false,
|
||||
throwOnBindFailure:true);
|
||||
|
||||
getInterfaceAddresses = (GetInterfaceAddressesDelegate)Delegate.CreateDelegate (
|
||||
typeof (GetInterfaceAddressesDelegate), t, "GetInterfaceAddresses",
|
||||
ignoreCase: false,
|
||||
throwOnBindFailure: false);
|
||||
|
||||
freeInterfaceAddresses = (FreeInterfaceAddressesDelegate)Delegate.CreateDelegate (
|
||||
typeof (FreeInterfaceAddressesDelegate), t, "FreeInterfaceAddresses",
|
||||
ignoreCase: false,
|
||||
throwOnBindFailure: false);
|
||||
}
|
||||
|
||||
#if SECURITY_DEP
|
||||
@@ -76,6 +89,23 @@ namespace System {
|
||||
{
|
||||
return getDefaultProxy ();
|
||||
}
|
||||
|
||||
internal static int GetInterfaceAddresses (out IntPtr ifap)
|
||||
{
|
||||
ifap = IntPtr.Zero;
|
||||
if (getInterfaceAddresses == null)
|
||||
return -1;
|
||||
|
||||
return getInterfaceAddresses (out ifap);
|
||||
}
|
||||
|
||||
internal static void FreeInterfaceAddresses (IntPtr ifap)
|
||||
{
|
||||
if (freeInterfaceAddresses == null)
|
||||
return;
|
||||
|
||||
freeInterfaceAddresses (ifap);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif // MONODROID
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -33,20 +33,26 @@ namespace System {
|
||||
public UriElements()
|
||||
{
|
||||
scheme = String.Empty;
|
||||
user = String.Empty;
|
||||
delimiter = String.Empty;
|
||||
host = String.Empty;
|
||||
port = String.Empty;
|
||||
port = -1;
|
||||
path = String.Empty;
|
||||
query = String.Empty;
|
||||
fragment = String.Empty;
|
||||
|
||||
isAbsoluteUri = true;
|
||||
}
|
||||
|
||||
public string scheme;
|
||||
public string delimiter;
|
||||
public string user;
|
||||
public string host;
|
||||
public string port;
|
||||
public int port;
|
||||
public string path;
|
||||
public string query;
|
||||
public string fragment;
|
||||
|
||||
public bool isAbsoluteUri;
|
||||
public bool isUnixFilePath;
|
||||
public bool isUnc;
|
||||
public long scopeId;
|
||||
}
|
||||
}
|
||||
|
606
mcs/class/System/System/UriHelper.cs
Normal file
606
mcs/class/System/System/UriHelper.cs
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -50,7 +50,12 @@ namespace System {
|
||||
if ((format < UriFormat.UriEscaped) || (format > UriFormat.SafeUnescaped))
|
||||
throw new ArgumentOutOfRangeException ("format");
|
||||
|
||||
UriElements elements = UriParseComponents.ParseComponents (uri.OriginalString.Trim ());
|
||||
return GetComponentsHelper (uri, components, format);
|
||||
}
|
||||
|
||||
internal string GetComponentsHelper (Uri uri, UriComponents components, UriFormat format)
|
||||
{
|
||||
UriElements elements = UriParseComponents.ParseComponents (uri.OriginalString.Trim (), UriKind.Absolute);
|
||||
|
||||
string scheme = scheme_name;
|
||||
int dp = default_port;
|
||||
@@ -62,29 +67,44 @@ namespace System {
|
||||
throw new SystemException ("URI Parser: scheme mismatch: " + scheme + " vs. " + elements.scheme);
|
||||
}
|
||||
|
||||
var formatFlags = UriHelper.FormatFlags.None;
|
||||
if (UriHelper.HasCharactersToNormalize (uri.OriginalString))
|
||||
formatFlags |= UriHelper.FormatFlags.HasUriCharactersToNormalize;
|
||||
|
||||
if (uri.UserEscaped)
|
||||
formatFlags |= UriHelper.FormatFlags.UserEscaped;
|
||||
|
||||
if (!string.IsNullOrEmpty (elements.host))
|
||||
formatFlags |= UriHelper.FormatFlags.HasHost;
|
||||
|
||||
// it's easier to answer some case directly (as the output isn't identical
|
||||
// when mixed with others components, e.g. leading slash, # ...)
|
||||
switch (components) {
|
||||
case UriComponents.Scheme:
|
||||
return scheme;
|
||||
case UriComponents.UserInfo:
|
||||
return elements.user;
|
||||
return elements.user ?? "";
|
||||
case UriComponents.Host:
|
||||
return elements.host;
|
||||
case UriComponents.Port: {
|
||||
string p = elements.port;
|
||||
if (p != null && p.Length != 0 && p != dp.ToString ())
|
||||
return p;
|
||||
int p = elements.port;
|
||||
if (p >= 0 && p != dp)
|
||||
return p.ToString (CultureInfo.InvariantCulture);
|
||||
return String.Empty;
|
||||
}
|
||||
case UriComponents.Path:
|
||||
return Format (IgnoreFirstCharIf (elements.path, '/'), format);
|
||||
var path = elements.path;
|
||||
if (scheme != Uri.UriSchemeMailto && scheme != Uri.UriSchemeNews)
|
||||
path = IgnoreFirstCharIf (elements.path, '/');
|
||||
return UriHelper.FormatAbsolute (path, scheme, UriComponents.Path, format, formatFlags);
|
||||
case UriComponents.Query:
|
||||
return Format (elements.query, format);
|
||||
return UriHelper.FormatAbsolute (elements.query, scheme, UriComponents.Query, format, formatFlags);
|
||||
case UriComponents.Fragment:
|
||||
return Format (elements.fragment, format);
|
||||
return UriHelper.FormatAbsolute (elements.fragment, scheme, UriComponents.Fragment, format, formatFlags);
|
||||
case UriComponents.StrongPort: {
|
||||
return elements.port.Length != 0 ? elements.port : dp.ToString ();
|
||||
return elements.port >= 0
|
||||
? elements.port.ToString (CultureInfo.InvariantCulture)
|
||||
: dp.ToString (CultureInfo.InvariantCulture);
|
||||
}
|
||||
case UriComponents.SerializationInfoString:
|
||||
components = UriComponents.AbsoluteUri;
|
||||
@@ -97,12 +117,12 @@ namespace System {
|
||||
|
||||
if ((components & UriComponents.Scheme) != 0) {
|
||||
sb.Append (scheme);
|
||||
sb.Append (Uri.GetSchemeDelimiter (scheme));
|
||||
sb.Append (elements.delimiter);
|
||||
}
|
||||
|
||||
if ((components & UriComponents.UserInfo) != 0) {
|
||||
string userinfo = elements.user;
|
||||
if (!String.IsNullOrEmpty (userinfo)) {
|
||||
if (userinfo != null) {
|
||||
sb.Append (elements.user);
|
||||
sb.Append ('@');
|
||||
}
|
||||
@@ -115,7 +135,7 @@ namespace System {
|
||||
// otherwise only display if ut's not the default port
|
||||
if ((components & UriComponents.StrongPort) != 0) {
|
||||
sb.Append (":");
|
||||
if (elements.port.Length != 0) {
|
||||
if (elements.port >= 0) {
|
||||
sb.Append (elements.port);
|
||||
} else {
|
||||
sb.Append (dp);
|
||||
@@ -123,36 +143,38 @@ namespace System {
|
||||
}
|
||||
|
||||
if ((components & UriComponents.Port) != 0) {
|
||||
string p = elements.port;
|
||||
if (p != null && p.Length != 0 && p != dp.ToString ()) {
|
||||
int p = elements.port;
|
||||
if (p >= 0 && p != dp) {
|
||||
sb.Append (":");
|
||||
sb.Append (elements.port);
|
||||
}
|
||||
}
|
||||
|
||||
if ((components & UriComponents.Path) != 0) {
|
||||
string path = elements.path;
|
||||
if ((components & UriComponents.PathAndQuery) != 0 &&
|
||||
(elements.path.Length == 0 || !elements.path.StartsWith ("/")))
|
||||
(path.Length == 0 || !path.StartsWith ("/", StringComparison.Ordinal)) &&
|
||||
elements.delimiter == Uri.SchemeDelimiter)
|
||||
sb.Append ("/");
|
||||
sb.Append (elements.path);
|
||||
sb.Append (UriHelper.FormatAbsolute (path, scheme, UriComponents.Path, format, formatFlags));
|
||||
}
|
||||
|
||||
if ((components & UriComponents.Query) != 0) {
|
||||
string query = elements.query;
|
||||
if (!String.IsNullOrEmpty (query)) {
|
||||
if (query != null) {
|
||||
sb.Append ("?");
|
||||
sb.Append (elements.query);
|
||||
sb.Append (UriHelper.FormatAbsolute (query, scheme, UriComponents.Query, format, formatFlags));
|
||||
}
|
||||
}
|
||||
|
||||
string result = Format (sb.ToString (), format);
|
||||
if ((components & UriComponents.Fragment) != 0) {
|
||||
string f = elements.fragment;
|
||||
if (!String.IsNullOrEmpty (f)) {
|
||||
result += "#" + Format (f, format);
|
||||
if (f != null) {
|
||||
sb.Append ("#");
|
||||
sb.Append (UriHelper.FormatAbsolute (f, scheme, UriComponents.Fragment, format, formatFlags));
|
||||
}
|
||||
}
|
||||
return result;
|
||||
return sb.ToString ();
|
||||
}
|
||||
|
||||
protected internal virtual void InitializeAndValidate (Uri uri, out UriFormatException parsingError)
|
||||
@@ -167,6 +189,11 @@ namespace System {
|
||||
|
||||
protected internal virtual bool IsBaseOf (Uri baseUri, Uri relativeUri)
|
||||
{
|
||||
if (baseUri == null)
|
||||
throw new ArgumentNullException ("baseUri");
|
||||
if (relativeUri == null)
|
||||
throw new ArgumentNullException ("relativeUri");
|
||||
|
||||
// compare, not case sensitive, the scheme, host and port (+ user informations)
|
||||
if (Uri.Compare (baseUri, relativeUri, UriComponents.SchemeAndServer | UriComponents.UserInfo, UriFormat.Unescaped, StringComparison.InvariantCultureIgnoreCase) != 0)
|
||||
return false;
|
||||
@@ -226,23 +253,6 @@ namespace System {
|
||||
return s;
|
||||
}
|
||||
|
||||
private string Format (string s, UriFormat format)
|
||||
{
|
||||
if (s.Length == 0)
|
||||
return String.Empty;
|
||||
|
||||
switch (format) {
|
||||
case UriFormat.UriEscaped:
|
||||
return Uri.EscapeString (s, Uri.EscapeCommonHexBrackets);
|
||||
case UriFormat.SafeUnescaped:
|
||||
return Uri.UnescapeDataString (s, true);
|
||||
case UriFormat.Unescaped:
|
||||
return Uri.Unescape (s, false);
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException ("format");
|
||||
}
|
||||
}
|
||||
|
||||
// static methods
|
||||
|
||||
private static void CreateDefaults ()
|
||||
|
Reference in New Issue
Block a user