diff options
author | George Hazan <ghazan@miranda.im> | 2019-01-30 18:33:10 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2019-01-30 18:33:10 +0300 |
commit | ec516b756030446b0a6b11604e102f3ec7b03031 (patch) | |
tree | 1afe35cf59623ca19ec55ec610f04833db75b6a5 /plugins/FTPFileYM/src | |
parent | 66490d0535bbe1abeff8ee8110c3bbe72a16a190 (diff) |
fixes #1703 (FTPFileYM broken filename / download link)
Diffstat (limited to 'plugins/FTPFileYM/src')
-rw-r--r-- | plugins/FTPFileYM/src/job_upload.cpp | 36 | ||||
-rw-r--r-- | plugins/FTPFileYM/src/job_upload.h | 9 | ||||
-rw-r--r-- | plugins/FTPFileYM/src/utils.cpp | 11 | ||||
-rw-r--r-- | plugins/FTPFileYM/src/utils.h | 1 | ||||
-rw-r--r-- | plugins/FTPFileYM/src/version.h | 2 |
5 files changed, 31 insertions, 28 deletions
diff --git a/plugins/FTPFileYM/src/job_upload.cpp b/plugins/FTPFileYM/src/job_upload.cpp index 29a51fc1fb..ba88b9c48d 100644 --- a/plugins/FTPFileYM/src/job_upload.cpp +++ b/plugins/FTPFileYM/src/job_upload.cpp @@ -44,9 +44,7 @@ UploadJob::UploadJob(PackerJob *job) : for (int i = 0; i < _countof(m_lastSpeed); i++)
m_lastSpeed[i] = 0;
- CMStringA buf = _T2A(job->m_tszFileName);
- Utils::makeSafeString(buf);
- strncpy_s(m_szSafeFileName, buf.c_str(), _TRUNCATE);
+ makeSafeString(job->m_tszFileName);
m_status = STATUS_CREATED;
}
@@ -67,9 +65,7 @@ void UploadJob::addToUploadDlg() wcsncpy_s(jobCopy->m_tszFilePath, m_files[i], _TRUNCATE);
wcsncpy_s(jobCopy->m_tszFileName, Utils::getFileNameFromPath(jobCopy->m_tszFilePath), _TRUNCATE);
- CMStringA buf = jobCopy->m_tszFileName;
- Utils::makeSafeString(buf);
- strncpy_s(jobCopy->m_szSafeFileName, buf.c_str(), _TRUNCATE);
+ jobCopy->makeSafeString(jobCopy->m_tszFileName);
UploadDialog::Tab *newTab = new UploadDialog::Tab(jobCopy);
jobCopy->m_tab = newTab;
@@ -180,7 +176,7 @@ void UploadJob::start() mir_forkThread<UploadJob>(&UploadJob::waitingThread, this);
}
-char *UploadJob::getChmodString()
+char* UploadJob::getChmodString()
{
if (m_ftp->m_ftpProto == ServerList::FTP::FT_SSH)
mir_snprintf(m_buff, "%s \"%s/%s\"", m_ftp->m_szChmod, m_ftp->m_szDir, m_szSafeFileName);
@@ -190,7 +186,7 @@ char *UploadJob::getChmodString() return m_buff;
}
-char *UploadJob::getDelFileString()
+char* UploadJob::getDelFileString()
{
if (m_ftp->m_ftpProto == ServerList::FTP::FT_SSH)
mir_snprintf(m_buff, "rm \"%s/%s\"", m_ftp->m_szDir, m_szSafeFileName);
@@ -200,7 +196,7 @@ char *UploadJob::getDelFileString() return m_buff;
}
-char *UploadJob::getUrlString()
+char* UploadJob::getUrlString()
{
if (m_ftp->m_szDir[0])
mir_snprintf(m_buff, "%s%s/%s/%s", m_ftp->getProtoString(), m_ftp->m_szServer, m_ftp->m_szDir, m_szSafeFileName);
@@ -210,7 +206,7 @@ char *UploadJob::getUrlString() return m_buff;
}
-char *UploadJob::getDelUrlString()
+char* UploadJob::getDelUrlString()
{
if (m_ftp->m_szDir[0] && m_ftp->m_ftpProto != ServerList::FTP::FT_SSH)
mir_snprintf(m_buff, "%s%s/%s/", m_ftp->getProtoString(), m_ftp->m_szServer, m_ftp->m_szDir);
@@ -220,7 +216,7 @@ char *UploadJob::getDelUrlString() return m_buff;
}
-CURL *UploadJob::curlInit(char *szUrl, struct curl_slist *headerList)
+CURL* UploadJob::curlInit(char *szUrl, struct curl_slist *headerList)
{
m_hCurl = curl_easy_init();
if (!m_hCurl)
@@ -240,6 +236,24 @@ bool UploadJob::fileExistsOnServer() return result != CURLE_REMOTE_FILE_NOT_FOUND;
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
+const wchar_t from_chars[] = L"абвгдеёжзийклмнопрстуфхцчшщъыьэюяАБВГДЕЁЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯ !@#$%^&=,{}[];'`";
+const wchar_t to_chars[] = L"abvgdeezziiklmnoprstufhccwwqyqeuaABVGDEEZZIIKLMNOPRSTUFHCCWWQYQEUA_________________";
+
+void UploadJob::makeSafeString(const wchar_t *input)
+{
+ CMStringW tmp(input);
+
+ size_t len = mir_wstrlen(from_chars);
+ for (size_t i = 0; i < len; i++)
+ tmp.Replace(from_chars[i], to_chars[i]);
+
+ strncpy(this->m_szSafeFileName, _T2A(tmp), _TRUNCATE);
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
INT_PTR CALLBACK UploadJob::DlgProcFileExists(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch (msg) {
diff --git a/plugins/FTPFileYM/src/job_upload.h b/plugins/FTPFileYM/src/job_upload.h index dfa34e638a..60c00a9d48 100644 --- a/plugins/FTPFileYM/src/job_upload.h +++ b/plugins/FTPFileYM/src/job_upload.h @@ -44,10 +44,10 @@ private: static mir_cs mutexJobCount;
static int iRunningJobCount;
- char *getChmodString();
- char *getDelFileString();
- char *getUrlString();
- char *getDelUrlString();
+ char* getChmodString();
+ char* getDelFileString();
+ char* getUrlString();
+ char* getDelUrlString();
void copyLinkToML();
void autoSend();
@@ -58,6 +58,7 @@ private: static INT_PTR CALLBACK DlgProcFileExists(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
bool fileExistsOnServer();
+ void makeSafeString(const wchar_t*);
void upload();
void updateStats();
diff --git a/plugins/FTPFileYM/src/utils.cpp b/plugins/FTPFileYM/src/utils.cpp index 4cf391444b..a75bc14c08 100644 --- a/plugins/FTPFileYM/src/utils.cpp +++ b/plugins/FTPFileYM/src/utils.cpp @@ -77,17 +77,6 @@ void Utils::copyToClipboard(char *szText) }
}
-const char from_chars[] = "абвгдеёжзийклмнопрстуфхцчшщъыьэюяАБВГДЕЁЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯ !@#$%^&=,{}[];'`";
-const char to_chars[] = "abvgdeezziiklmnoprstufhccwwqyqeuaABVGDEEZZIIKLMNOPRSTUFHCCWWQYQEUA_________________";
-
-CMStringA Utils::makeSafeString(CMStringA &input)
-{
- size_t len = mir_strlen(from_chars);
- for (size_t i = 0; i < len; i++)
- input.Replace(from_chars[i], to_chars[i]);
- return input;
-}
-
void Utils::curlSetOpt(CURL *hCurl, ServerList::FTP *ftp, char *url, struct curl_slist *headerList, char *errorBuff)
{
char buff[256];
diff --git a/plugins/FTPFileYM/src/utils.h b/plugins/FTPFileYM/src/utils.h index 084e66a664..b57fd024c5 100644 --- a/plugins/FTPFileYM/src/utils.h +++ b/plugins/FTPFileYM/src/utils.h @@ -35,7 +35,6 @@ public: static HANDLE getIconHandle(const char *szName);
static wchar_t *getFileNameFromPath(wchar_t *stzPath);
- static CMStringA makeSafeString(CMStringA &input);
static void createFileDownloadLink(char *szUrl, char *fileName, char *buff, int buffSize);
static void copyToClipboard(char *szText);
diff --git a/plugins/FTPFileYM/src/version.h b/plugins/FTPFileYM/src/version.h index 422594ceac..45859d8f11 100644 --- a/plugins/FTPFileYM/src/version.h +++ b/plugins/FTPFileYM/src/version.h @@ -1,7 +1,7 @@ #define __MAJOR_VERSION 0
#define __MINOR_VERSION 6
#define __RELEASE_NUM 0
-#define __BUILD_NUM 3
+#define __BUILD_NUM 4
#include <stdver.h>
|