mirror of
https://github.com/ShareX/ShareX.git
synced 2024-10-01 09:47:22 +13:00
Fix issue #372
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:
parent
03bff07e96
commit
17b8291113
3 changed files with 6 additions and 7 deletions
|
@ -43,6 +43,7 @@ You should have received a copy of the GNU General Public License
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
using System.Web;
|
||||||
|
|
||||||
namespace ShareX.HelpersLib
|
namespace ShareX.HelpersLib
|
||||||
{
|
{
|
||||||
|
@ -215,7 +216,7 @@ public static string GetValidFilePath(string filePath)
|
||||||
public static string GetValidURL(string url, bool replaceSpace = false)
|
public static string GetValidURL(string url, bool replaceSpace = false)
|
||||||
{
|
{
|
||||||
if (replaceSpace) url = url.Replace(' ', '_');
|
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)
|
public static string GetXMLValue(string input, string tag)
|
||||||
|
|
|
@ -110,7 +110,7 @@ public override UploadResult Upload(Stream stream, string fileName)
|
||||||
UploadResult result = new UploadResult();
|
UploadResult result = new UploadResult();
|
||||||
|
|
||||||
fileName = Helpers.GetValidURL(fileName);
|
fileName = Helpers.GetValidURL(fileName);
|
||||||
string subFolderPath = Account.GetSubFolderPath();
|
string subFolderPath = Account.GetSubFolderPath(null, NameParserType.FolderPath);
|
||||||
string path = subFolderPath.CombineURL(fileName);
|
string path = subFolderPath.CombineURL(fileName);
|
||||||
bool uploadResult;
|
bool uploadResult;
|
||||||
|
|
||||||
|
|
|
@ -138,9 +138,9 @@ public FTPAccount()
|
||||||
FTPSCertificateLocation = string.Empty;
|
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);
|
return URLHelpers.CombineURL(path, filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -175,8 +175,6 @@ public string GetUriPath(string filename, string subFolderPath = null)
|
||||||
subFolderPath = GetSubFolderPath();
|
subFolderPath = GetSubFolderPath();
|
||||||
}
|
}
|
||||||
|
|
||||||
subFolderPath = URLHelpers.URLPathEncode(subFolderPath);
|
|
||||||
|
|
||||||
UriBuilder httpHomeUri;
|
UriBuilder httpHomeUri;
|
||||||
var httpHomePath = GetHttpHomePath();
|
var httpHomePath = GetHttpHomePath();
|
||||||
|
|
||||||
|
@ -242,7 +240,7 @@ public string GetFtpPath(string filemame)
|
||||||
return string.Empty;
|
return string.Empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
return URLHelpers.CombineURL(FTPAddress, GetSubFolderPath(filemame));
|
return URLHelpers.CombineURL(FTPAddress, GetSubFolderPath(filemame, NameParserType.FolderPath));
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
|
|
Loading…
Reference in a new issue