remove reference to old NetFtp, as this was exchanged for FluentFTP; fix issue with paths that need url encoding, closing #736, closing #615

This commit is contained in:
Philipp Crocoll
2019-12-16 12:09:41 +01:00
parent d697b93f6a
commit 69abcd0786
4 changed files with 33 additions and 48 deletions

3
.gitmodules vendored
View File

@@ -1,9 +1,6 @@
[submodule "src/SamsungPass"] [submodule "src/SamsungPass"]
path = src/SamsungPass path = src/SamsungPass
url = https://github.com/PhilippC/Xamarin-Samsung-Pass.git url = https://github.com/PhilippC/Xamarin-Samsung-Pass.git
[submodule "src/netftpandroid"]
path = src/netftpandroid
url = https://github.com/PhilippC/netftpandroid.git
[submodule "src/java/argon2/phc-winner-argon2"] [submodule "src/java/argon2/phc-winner-argon2"]
path = src/java/argon2/phc-winner-argon2 path = src/java/argon2/phc-winner-argon2
url = https://github.com/P-H-C/phc-winner-argon2 url = https://github.com/P-H-C/phc-winner-argon2

View File

@@ -23,8 +23,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PluginSdkBinding", "PluginS
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ZlibAndroid", "ZlibAndroid\ZlibAndroid.csproj", "{6C29A7E7-E016-4FC1-B1A0-DEE26AC711BB}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ZlibAndroid", "ZlibAndroid\ZlibAndroid.csproj", "{6C29A7E7-E016-4FC1-B1A0-DEE26AC711BB}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.Net.FtpClient.Android", "netftpandroid\System.Net.FtpClient\System.Net.FtpClient.Android.csproj", "{146FD497-BA03-4740-B6C5-5C84EA8FCDE2}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SamsungPass", "SamsungPass\Xamarin.SamsungPass\SamsungPass\SamsungPass.csproj", "{3A4B8E88-FA9B-4663-BCDA-21C12E3AF98A}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SamsungPass", "SamsungPass\Xamarin.SamsungPass\SamsungPass\SamsungPass.csproj", "{3A4B8E88-FA9B-4663-BCDA-21C12E3AF98A}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PCloudBindings", "PCloudBindings\PCloudBindings.csproj", "{2DB80C77-D46F-4970-B967-E9FFA9B2AC2E}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PCloudBindings", "PCloudBindings\PCloudBindings.csproj", "{2DB80C77-D46F-4970-B967-E9FFA9B2AC2E}"
@@ -257,24 +255,6 @@ Global
{6C29A7E7-E016-4FC1-B1A0-DEE26AC711BB}.ReleaseNoNet|Win32.Build.0 = Release|Any CPU {6C29A7E7-E016-4FC1-B1A0-DEE26AC711BB}.ReleaseNoNet|Win32.Build.0 = Release|Any CPU
{6C29A7E7-E016-4FC1-B1A0-DEE26AC711BB}.ReleaseNoNet|x64.ActiveCfg = Release|Any CPU {6C29A7E7-E016-4FC1-B1A0-DEE26AC711BB}.ReleaseNoNet|x64.ActiveCfg = Release|Any CPU
{6C29A7E7-E016-4FC1-B1A0-DEE26AC711BB}.ReleaseNoNet|x64.Build.0 = Release|Any CPU {6C29A7E7-E016-4FC1-B1A0-DEE26AC711BB}.ReleaseNoNet|x64.Build.0 = Release|Any CPU
{146FD497-BA03-4740-B6C5-5C84EA8FCDE2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{146FD497-BA03-4740-B6C5-5C84EA8FCDE2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{146FD497-BA03-4740-B6C5-5C84EA8FCDE2}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{146FD497-BA03-4740-B6C5-5C84EA8FCDE2}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{146FD497-BA03-4740-B6C5-5C84EA8FCDE2}.Debug|Win32.ActiveCfg = Debug|Any CPU
{146FD497-BA03-4740-B6C5-5C84EA8FCDE2}.Debug|x64.ActiveCfg = Debug|Any CPU
{146FD497-BA03-4740-B6C5-5C84EA8FCDE2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{146FD497-BA03-4740-B6C5-5C84EA8FCDE2}.Release|Any CPU.Build.0 = Release|Any CPU
{146FD497-BA03-4740-B6C5-5C84EA8FCDE2}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{146FD497-BA03-4740-B6C5-5C84EA8FCDE2}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{146FD497-BA03-4740-B6C5-5C84EA8FCDE2}.Release|Win32.ActiveCfg = Release|Any CPU
{146FD497-BA03-4740-B6C5-5C84EA8FCDE2}.Release|x64.ActiveCfg = Release|Any CPU
{146FD497-BA03-4740-B6C5-5C84EA8FCDE2}.ReleaseNoNet|Any CPU.ActiveCfg = Release|Any CPU
{146FD497-BA03-4740-B6C5-5C84EA8FCDE2}.ReleaseNoNet|Any CPU.Build.0 = Release|Any CPU
{146FD497-BA03-4740-B6C5-5C84EA8FCDE2}.ReleaseNoNet|Mixed Platforms.ActiveCfg = Release|Any CPU
{146FD497-BA03-4740-B6C5-5C84EA8FCDE2}.ReleaseNoNet|Mixed Platforms.Build.0 = Release|Any CPU
{146FD497-BA03-4740-B6C5-5C84EA8FCDE2}.ReleaseNoNet|Win32.ActiveCfg = Release|Any CPU
{146FD497-BA03-4740-B6C5-5C84EA8FCDE2}.ReleaseNoNet|x64.ActiveCfg = Release|Any CPU
{3A4B8E88-FA9B-4663-BCDA-21C12E3AF98A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {3A4B8E88-FA9B-4663-BCDA-21C12E3AF98A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3A4B8E88-FA9B-4663-BCDA-21C12E3AF98A}.Debug|Any CPU.Build.0 = Debug|Any CPU {3A4B8E88-FA9B-4663-BCDA-21C12E3AF98A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3A4B8E88-FA9B-4663-BCDA-21C12E3AF98A}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU {3A4B8E88-FA9B-4663-BCDA-21C12E3AF98A}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU

View File

@@ -104,7 +104,7 @@ namespace keepass2android.Io
{ {
using (FtpClient client = GetClient(ioc)) using (FtpClient client = GetClient(ioc))
{ {
string localPath = IocToUri(ioc).PathAndQuery; string localPath = IocToLocalPath(ioc);
if (client.DirectoryExists(localPath)) if (client.DirectoryExists(localPath))
client.DeleteDirectory(localPath); client.DeleteDirectory(localPath);
else else
@@ -183,10 +183,11 @@ namespace keepass2android.Io
path = path.Substring(settings.Length + 1); path = path.Substring(settings.Length + 1);
} }
Kp2aLog.Log("FTP: IocToUri out = " + scheme + "://" + path);
return new Uri(scheme + "://" + path); return new Uri(scheme + "://" + path);
} }
private string IocPathFromUri(IOConnectionInfo baseIoc, Uri uri) private string IocPathFromUri(IOConnectionInfo baseIoc, string uri)
{ {
string basePath = baseIoc.Path; string basePath = baseIoc.Path;
int schemeLength = basePath.IndexOf("://", StringComparison.Ordinal); int schemeLength = basePath.IndexOf("://", StringComparison.Ordinal);
@@ -195,7 +196,8 @@ namespace keepass2android.Io
string baseSettings = basePath.Substring(0, basePath.IndexOf(ConnectionSettings.SettingsPostFix, StringComparison.Ordinal)); string baseSettings = basePath.Substring(0, basePath.IndexOf(ConnectionSettings.SettingsPostFix, StringComparison.Ordinal));
basePath = basePath.Substring(baseSettings.Length+1); basePath = basePath.Substring(baseSettings.Length+1);
string baseHost = basePath.Substring(0, basePath.IndexOf("/", StringComparison.Ordinal)); string baseHost = basePath.Substring(0, basePath.IndexOf("/", StringComparison.Ordinal));
return scheme + "://" + baseSettings + ConnectionSettings.SettingsPostFix + baseHost + uri.AbsolutePath; //TODO does this contain Query? string result = scheme + "://" + baseSettings + ConnectionSettings.SettingsPostFix + baseHost + uri; //TODO does this contain Query?
return result;
} }
@@ -215,7 +217,7 @@ namespace keepass2android.Io
{ {
using (var cl = GetClient(ioc)) using (var cl = GetClient(ioc))
{ {
return cl.OpenRead(IocToUri(ioc).PathAndQuery, FtpDataType.Binary, 0); return cl.OpenRead(IocToLocalPath(ioc), FtpDataType.Binary, 0);
} }
} }
catch (FtpCommandException ex) catch (FtpCommandException ex)
@@ -263,7 +265,7 @@ namespace keepass2android.Io
{ {
using (var client = GetClient(ioc)) using (var client = GetClient(ioc))
{ {
client.CreateDirectory(IocToUri(GetFilePath(ioc, newDirName)).PathAndQuery); client.CreateDirectory(IocToLocalPath(GetFilePath(ioc, newDirName)));
} }
} }
catch (FtpCommandException ex) catch (FtpCommandException ex)
@@ -272,6 +274,11 @@ namespace keepass2android.Io
} }
} }
public static string IocToLocalPath(IOConnectionInfo ioc)
{
return WebUtility.UrlDecode(IocToUri(ioc).PathAndQuery);
}
public IEnumerable<FileDescription> ListContents(IOConnectionInfo ioc) public IEnumerable<FileDescription> ListContents(IOConnectionInfo ioc)
{ {
try try
@@ -279,7 +286,7 @@ namespace keepass2android.Io
using (var client = GetClient(ioc)) using (var client = GetClient(ioc))
{ {
List<FileDescription> files = new List<FileDescription>(); List<FileDescription> files = new List<FileDescription>();
foreach (FtpListItem item in client.GetListing(IocToUri(ioc).PathAndQuery, foreach (FtpListItem item in client.GetListing(IocToLocalPath(ioc),
FtpListOption.Modify | FtpListOption.Size | FtpListOption.DerefLinks)) FtpListOption.Modify | FtpListOption.Size | FtpListOption.DerefLinks))
{ {
@@ -293,7 +300,7 @@ namespace keepass2android.Io
DisplayName = item.Name, DisplayName = item.Name,
IsDirectory = true, IsDirectory = true,
LastModified = item.Modified, LastModified = item.Modified,
Path = IocPathFromUri(ioc, new Uri(item.FullName)) Path = IocPathFromUri(ioc, item.FullName)
}); });
break; break;
case FtpFileSystemObjectType.File: case FtpFileSystemObjectType.File:
@@ -304,7 +311,7 @@ namespace keepass2android.Io
DisplayName = item.Name, DisplayName = item.Name,
IsDirectory = false, IsDirectory = false,
LastModified = item.Modified, LastModified = item.Modified,
Path = IocPathFromUri(ioc, new Uri(item.FullName)), Path = IocPathFromUri(ioc, item.FullName),
SizeInBytes = item.Size SizeInBytes = item.Size
}); });
break; break;
@@ -331,8 +338,8 @@ namespace keepass2android.Io
using (FtpClient client = GetClient(ioc)) using (FtpClient client = GetClient(ioc))
{ {
var uri = IocToUri(ioc);
string path = uri.PathAndQuery; string path = IocToLocalPath(ioc);
if (!client.FileExists(path) && (!client.DirectoryExists(path))) if (!client.FileExists(path) && (!client.DirectoryExists(path)))
throw new FileNotFoundException(); throw new FileNotFoundException();
var fileDesc = new FileDescription() var fileDesc = new FileDescription()
@@ -444,7 +451,7 @@ namespace keepass2android.Io
{ {
using (var client = GetClient(ioc)) using (var client = GetClient(ioc))
{ {
return client.OpenWrite(IocToUri(ioc).PathAndQuery); return client.OpenWrite(IocToLocalPath(ioc));
} }
} }
@@ -513,7 +520,7 @@ namespace keepass2android.Io
{ {
_client = _fileStorage.GetClient(_ioc, false); _client = _fileStorage.GetClient(_ioc, false);
_stream = _client.OpenWrite(NetFtpFileStorage.IocToUri(_iocTemp).PathAndQuery); _stream = _client.OpenWrite(NetFtpFileStorage.IocToLocalPath(_iocTemp));
return _stream; return _stream;
} }
catch (FtpCommandException ex) catch (FtpCommandException ex)
@@ -534,8 +541,8 @@ namespace keepass2android.Io
//make sure target file does not exist: //make sure target file does not exist:
//try //try
{ {
if (_client.FileExists(NetFtpFileStorage.IocToUri(_ioc).PathAndQuery)) if (_client.FileExists(NetFtpFileStorage.IocToLocalPath(_ioc)))
_client.DeleteFile(NetFtpFileStorage.IocToUri(_ioc).PathAndQuery); _client.DeleteFile(NetFtpFileStorage.IocToLocalPath(_ioc));
} }
//catch (FtpCommandException) //catch (FtpCommandException)
@@ -543,8 +550,8 @@ namespace keepass2android.Io
//TODO get a new clien? might be stale //TODO get a new clien? might be stale
} }
_client.Rename(NetFtpFileStorage.IocToUri(_iocTemp).PathAndQuery, _client.Rename(NetFtpFileStorage.IocToLocalPath(_iocTemp),
NetFtpFileStorage.IocToUri(_ioc).PathAndQuery); NetFtpFileStorage.IocToLocalPath(_ioc));
} }
catch (FtpCommandException ex) catch (FtpCommandException ex)

View File

@@ -1,6 +1,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Net;
#if !NoNet #if !NoNet
using FluentFTP; using FluentFTP;
#endif #endif
@@ -185,7 +186,7 @@ namespace keepass2android
string pathAndQuery = uri.PathAndQuery; string pathAndQuery = uri.PathAndQuery;
var host = uri.Host; var host = uri.Host;
var localPath = pathAndQuery; var localPath = WebUtility.UrlDecode(pathAndQuery);
if (!uri.IsDefaultPort) if (!uri.IsDefaultPort)