summaryrefslogtreecommitdiff
path: root/protocols/ICQ-WIM
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2020-02-20 13:16:04 +0300
committerGeorge Hazan <ghazan@miranda.im>2020-02-20 13:16:04 +0300
commita9df1935b39b2fddb192a1d38968603e6d0ed783 (patch)
tree6fe5abddfb2c3ed09d93702aa2e60871623660c3 /protocols/ICQ-WIM
parent9137bfd8d560226146de1390e12db02aa63c1c31 (diff)
fixes #2213 (ICQ: filetransfer stuck)
Diffstat (limited to 'protocols/ICQ-WIM')
-rw-r--r--protocols/ICQ-WIM/src/proto.cpp2
-rw-r--r--protocols/ICQ-WIM/src/server.cpp21
2 files changed, 10 insertions, 13 deletions
diff --git a/protocols/ICQ-WIM/src/proto.cpp b/protocols/ICQ-WIM/src/proto.cpp
index e36dbe39f8..9999c6a3c4 100644
--- a/protocols/ICQ-WIM/src/proto.cpp
+++ b/protocols/ICQ-WIM/src/proto.cpp
@@ -501,7 +501,7 @@ HANDLE CIcqProto::SendFile(MCONTACT hContact, const wchar_t *szDescription, wcha
pTransfer->m_wszDescr = szDescription;
auto *pReq = new AsyncHttpRequest(CONN_NONE, REQUEST_GET, "https://files.icq.com/files/init", &CIcqProto::OnFileInit);
- pReq << CHAR_PARAM("a", m_szAToken) << CHAR_PARAM("client", "icq") << CHAR_PARAM("f", "json") << CHAR_PARAM("filename", mir_urlEncode(T2Utf(pTransfer->m_wszShortName)))
+ pReq << CHAR_PARAM("a", m_szAToken) << CHAR_PARAM("client", "icq") << CHAR_PARAM("f", "json") << WCHAR_PARAM("filename", pTransfer->m_wszShortName)
<< CHAR_PARAM("k", ICQ_APP_ID) << INT_PARAM("size", statbuf.st_size) << INT_PARAM("ts", TS());
CalcHash(pReq);
pReq->pUserInfo = pTransfer;
diff --git a/protocols/ICQ-WIM/src/server.cpp b/protocols/ICQ-WIM/src/server.cpp
index d2b56be036..5b7db80bb4 100644
--- a/protocols/ICQ-WIM/src/server.cpp
+++ b/protocols/ICQ-WIM/src/server.cpp
@@ -419,7 +419,12 @@ void CIcqProto::ParseMessage(MCONTACT hContact, __int64 &lastMsgId, const JSONNo
bool bIsOutgoing = it["outgoing"].as_bool();
if (!bIsOutgoing && wszText.Left(26) == L"https://files.icq.net/get/") {
- CMStringA szUrl(FORMAT, ICQ_FILE_SERVER "/info/%S/", wszText.Mid(26).c_str());
+ CMStringW wszUrl(wszText.Mid(26));
+ int idx = wszUrl.Find(' ');
+ if (idx != -1)
+ wszUrl.Truncate(idx);
+
+ CMStringA szUrl(FORMAT, ICQ_FILE_SERVER "/info/%S/", wszUrl.c_str());
auto *pReq = new AsyncHttpRequest(CONN_MAIN, REQUEST_GET, szUrl, &CIcqProto::OnFileInfo);
pReq->hContact = hContact;
pReq << CHAR_PARAM("aimsid", m_aimsid) << CHAR_PARAM("previews", "600");
@@ -808,11 +813,6 @@ void CIcqProto::OnFileInit(NETLIBHTTPREQUEST *pReply, AsyncHttpRequest *pOld)
/////////////////////////////////////////////////////////////////////////////////////////
-static bool sttIsXDigit(char c)
-{
- return (c >= 'A' && c <= 'F') || (c >= '0' && c <= '9');
-}
-
void CIcqProto::OnFileInfo(NETLIBHTTPREQUEST *pReply, AsyncHttpRequest *pReq)
{
RobustReply root(pReply);
@@ -825,12 +825,8 @@ void CIcqProto::OnFileInfo(NETLIBHTTPREQUEST *pReply, AsyncHttpRequest *pReq)
return;
mir_urlDecode(&*szUrl.begin());
- for (size_t i = 0; i < szUrl.length(); ++i)
- if (szUrl[i] == '_' && sttIsXDigit(szUrl[i+1]) && sttIsXDigit(szUrl[i+2])) {
- int c;
- if (1 == sscanf(szUrl.c_str() + i + 1, "%02x", &c))
- szUrl.replace(i, 3, 1, c);
- }
+
+ CMStringW wszDescr(data["file_name"].as_mstring());
auto *ft = new IcqFileTransfer(pReq->hContact, szUrl.c_str());
ft->pfts.totalBytes = ft->pfts.currentFileSize = data["file_size"].as_int();
@@ -841,6 +837,7 @@ void CIcqProto::OnFileInfo(NETLIBHTTPREQUEST *pReply, AsyncHttpRequest *pReq)
pre.fileCount = 1;
pre.timestamp = time(0);
pre.files.w = &ft->m_wszShortName;
+ pre.descr.w = wszDescr;
pre.lParam = (LPARAM)ft;
ProtoChainRecvFile(pReq->hContact, &pre);
}