diff options
author | Jeffrey Stedfast <jeff@xamarin.com> | 2013-09-14 03:39:49 +0400 |
---|---|---|
committer | Jeffrey Stedfast <jeff@xamarin.com> | 2013-09-14 03:45:37 +0400 |
commit | eb1f433a8ace83883ced0d965f4ce13408af8e3c (patch) | |
tree | 70a230c51c26cdc40db4e2fb28ba68e7fc281026 | |
parent | d202db2123c42ebdf55de5f702de0fef6ec076ab (diff) |
[MacPlatform] Fixed password lookup logic for Uri's without paths
Fixes bug #14740
-rw-r--r-- | main/src/addins/MacPlatform/MacInterop/Keychain.cs | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/main/src/addins/MacPlatform/MacInterop/Keychain.cs b/main/src/addins/MacPlatform/MacInterop/Keychain.cs index fb5fafe516..bd6ef514fa 100644 --- a/main/src/addins/MacPlatform/MacInterop/Keychain.cs +++ b/main/src/addins/MacPlatform/MacInterop/Keychain.cs @@ -698,7 +698,8 @@ namespace MonoDevelop.MacInterop public static unsafe void AddInternetPassword (Uri uri, string username, string password) { - byte[] path = Encoding.UTF8.GetBytes (string.Join (string.Empty, uri.Segments).Substring (1)); // don't include the leading '/' + var pathStr = string.Join (string.Empty, uri.Segments); + byte[] path = pathStr.Length > 0 ? Encoding.UTF8.GetBytes (pathStr.Substring (1)) : new byte[0]; // don't include the leading '/' byte[] passwd = Encoding.UTF8.GetBytes (password); byte[] host = Encoding.UTF8.GetBytes (uri.Host); byte[] user = Encoding.UTF8.GetBytes (username); @@ -736,7 +737,8 @@ namespace MonoDevelop.MacInterop public static unsafe void AddInternetPassword (Uri uri, string password) { - byte[] path = Encoding.UTF8.GetBytes (string.Join (string.Empty, uri.Segments).Substring (1)); // don't include the leading '/' + var pathStr = string.Join (string.Empty, uri.Segments); + byte[] path = pathStr.Length > 0 ? Encoding.UTF8.GetBytes (pathStr.Substring (1)) : new byte[0]; // don't include the leading '/' byte[] user = Encoding.UTF8.GetBytes (Uri.UnescapeDataString (uri.UserInfo)); byte[] passwd = Encoding.UTF8.GetBytes (password); byte[] host = Encoding.UTF8.GetBytes (uri.Host); @@ -806,7 +808,8 @@ namespace MonoDevelop.MacInterop public static unsafe Tuple<string, string> FindInternetUserNameAndPassword (Uri uri) { - byte[] path = Encoding.UTF8.GetBytes (string.Join (string.Empty, uri.Segments).Substring (1)); // don't include the leading '/' + var pathStr = string.Join (string.Empty, uri.Segments); + byte[] path = pathStr.Length > 0 ? Encoding.UTF8.GetBytes (pathStr.Substring (1)) : new byte[0]; // don't include the leading '/' byte[] host = Encoding.UTF8.GetBytes (uri.Host); var auth = GetSecAuthenticationType (uri.Query); var protocol = GetSecProtocolType (uri.Scheme); @@ -831,7 +834,8 @@ namespace MonoDevelop.MacInterop public static string FindInternetPassword (Uri uri) { - byte[] path = Encoding.UTF8.GetBytes (string.Join (string.Empty, uri.Segments).Substring (1)); // don't include the leading '/' + var pathStr = string.Join (string.Empty, uri.Segments); + byte[] path = pathStr.Length > 0 ? Encoding.UTF8.GetBytes (pathStr.Substring (1)) : new byte[0]; // don't include the leading '/' byte[] user = Encoding.UTF8.GetBytes (Uri.UnescapeDataString (uri.UserInfo)); byte[] host = Encoding.UTF8.GetBytes (uri.Host); var auth = GetSecAuthenticationType (uri.Query); |