Several changes were made to fix the encoding of ftp dirpaths and allow
uploads to folders with non-ascii characters:

-Fixed encoding of valid urls in ShareX.HelpersLib.NameParser.cs
-Fixed subfolder path generation and wrong url re-encoding in
FTPAccount.cs
-Fixed preview paths in FTP Destination settings (FTPAccount.cs)
-Fixed subfolder path generation in FTP.cs

This fixes issue #372, which was reproduced with the following account
config on a local ftp server (import from clipboard on destination
settings):

{
"Protocol": "FTP",
"Name": "New account",
"Host": "localhost",
"Port": 21,
"Username": "test",
"Password": "test",
"ServerProtocol": "ftp",
"SubFolderPath": "DEV/grhh本人%",
"BrowserProtocol": "http",
"HttpHomePath": "",
"HttpHomePathAutoAddSubFolderPath": true,
"HttpHomePathNoExtension": false,
"IsActive": false,
"FTPSEncryption": "Explicit",
"FTPSCertificateLocation": "",
"Passphrase": null,
"Keypath": null
}
This commit is contained in:
luis.gomez 2015-01-01 18:44:18 -03:00
parent 03bff07e96
commit 17b8291113
3 changed files with 6 additions and 7 deletions

View file

@ -43,6 +43,7 @@
using System.Text.RegularExpressions;
using System.Threading;
using System.Windows.Forms;
using System.Web;
namespace ShareX.HelpersLib
{
@ -215,7 +216,7 @@ public static string GetValidFilePath(string filePath)
public static string GetValidURL(string url, bool replaceSpace = false)
{
if (replaceSpace) url = url.Replace(' ', '_');
return new string(url.Where(c => ValidURLCharacters.Contains(c)).ToArray());
return HttpUtility.UrlPathEncode(url);
}
public static string GetXMLValue(string input, string tag)

View file

@ -110,7 +110,7 @@ public override UploadResult Upload(Stream stream, string fileName)
UploadResult result = new UploadResult();
fileName = Helpers.GetValidURL(fileName);
string subFolderPath = Account.GetSubFolderPath();
string subFolderPath = Account.GetSubFolderPath(null, NameParserType.FolderPath);
string path = subFolderPath.CombineURL(fileName);
bool uploadResult;

View file

@ -138,9 +138,9 @@ public FTPAccount()
FTPSCertificateLocation = string.Empty;
}
public string GetSubFolderPath(string filename = null)
public string GetSubFolderPath(string filename = null, NameParserType nameParserType = NameParserType.URL)
{
string path = NameParser.Parse(NameParserType.URL, SubFolderPath.Replace("%host", Host));
string path = NameParser.Parse(nameParserType, SubFolderPath.Replace("%host", Host));
return URLHelpers.CombineURL(path, filename);
}
@ -175,8 +175,6 @@ public string GetUriPath(string filename, string subFolderPath = null)
subFolderPath = GetSubFolderPath();
}
subFolderPath = URLHelpers.URLPathEncode(subFolderPath);
UriBuilder httpHomeUri;
var httpHomePath = GetHttpHomePath();
@ -242,7 +240,7 @@ public string GetFtpPath(string filemame)
return string.Empty;
}
return URLHelpers.CombineURL(FTPAddress, GetSubFolderPath(filemame));
return URLHelpers.CombineURL(FTPAddress, GetSubFolderPath(filemame, NameParserType.FolderPath));
}
public override string ToString()