Merge branch 'master' of github.com:ShareX/ShareX

This commit is contained in:
Jaex 2015-01-02 11:57:33 +02:00
commit aefafc84de
3 changed files with 6 additions and 7 deletions

View file

@ -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)

View file

@ -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;

View file

@ -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()