summaryrefslogtreecommitdiff
path: root/protocols
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2024-06-06 16:18:43 +0300
committerGeorge Hazan <george.hazan@gmail.com>2024-06-06 16:18:43 +0300
commit5b70baa32617190d97f36e389c11140d389e093c (patch)
tree5e1ecfd6b577b0d6c49fe91e260076b65197d720 /protocols
parentcf9398bf479f55b792fc932f1fdadfe7d1deb3c3 (diff)
fixes #4449 (ICQ: broken cloud file download)
Diffstat (limited to 'protocols')
-rw-r--r--protocols/ICQ-WIM/src/server.cpp9
-rw-r--r--protocols/ICQ-WIM/src/stdafx.h2
-rw-r--r--protocols/ICQ-WIM/src/utils.cpp19
3 files changed, 17 insertions, 13 deletions
diff --git a/protocols/ICQ-WIM/src/server.cpp b/protocols/ICQ-WIM/src/server.cpp
index c2ef85ff90..1135542926 100644
--- a/protocols/ICQ-WIM/src/server.cpp
+++ b/protocols/ICQ-WIM/src/server.cpp
@@ -176,7 +176,8 @@ IcqFileInfo *CIcqProto::RetrieveFileInfo(MCONTACT hContact, const CMStringW &wsz
bool CIcqProto::CheckFile(MCONTACT hContact, CMStringW &wszText, IcqFileInfo *&pFileInfo)
{
CMStringW wszUrl;
- if (!fileText2url(wszText, &wszUrl))
+ int idx = fileText2url(wszText, &wszUrl);
+ if (!idx)
return false;
pFileInfo = nullptr;
@@ -186,9 +187,9 @@ bool CIcqProto::CheckFile(MCONTACT hContact, CMStringW &wszText, IcqFileInfo *&p
if (!pFileInfo)
return false;
- if (wszUrl != wszText) {
- pFileInfo->szOrigUrl = wszUrl;
- wszText.Delete(0, wszUrl.GetLength() + 1);
+ if (idx != -1) {
+ pFileInfo->szOrigUrl = wszText.Mid(0, idx);
+ wszText.Delete(0, idx + 1);
}
else {
pFileInfo->szOrigUrl = wszText;
diff --git a/protocols/ICQ-WIM/src/stdafx.h b/protocols/ICQ-WIM/src/stdafx.h
index e8c1452cb7..dcb161eaf4 100644
--- a/protocols/ICQ-WIM/src/stdafx.h
+++ b/protocols/ICQ-WIM/src/stdafx.h
@@ -110,6 +110,6 @@ void RefreshGroups(void);
wchar_t* time2text(time_t time);
wchar_t* time2text(DBVARIANT *dbv);
-bool fileText2url(const CMStringW &wszText, CMStringW *res = nullptr);
+int fileText2url(const CMStringW &wszText, CMStringW *res = nullptr);
extern bool g_bSecureIM, g_bMessageState;
diff --git a/protocols/ICQ-WIM/src/utils.cpp b/protocols/ICQ-WIM/src/utils.cpp
index 2c36c3fb86..460e20ff2f 100644
--- a/protocols/ICQ-WIM/src/utils.cpp
+++ b/protocols/ICQ-WIM/src/utils.cpp
@@ -266,26 +266,29 @@ void CIcqProto::setId(MCONTACT hContact, const char *szSetting, __int64 iValue)
/////////////////////////////////////////////////////////////////////////////////////////
-bool fileText2url(const CMStringW &wszText, CMStringW *res)
+int fileText2url(const CMStringW &wszText, CMStringW *res)
{
+ int iStart = 0;
if (!mir_wstrncmp(wszText, L"https://files.icq.net/get/", 26)) {
if (res)
- *res = wszText.Mid(26);
+ *res = wszText.Mid(iStart = 26);
}
else if (!mir_wstrncmp(wszText, L"http://files.icq.net/get/", 25)) {
if (res)
- *res = wszText.Mid(25);
- return true;
+ *res = wszText.Mid(iStart = 25);
}
- else return false;
+ else return 0;
if (res) {
int idx = res->FindOneOf(L" \r\n\t");
- if (idx != -1)
- *res = res->Mid(0, idx);
+ if (idx == -1)
+ return -1;
+
+ *res = res->Mid(0, idx);
+ return iStart + idx;
}
- return true;
+ return 1;
}
/////////////////////////////////////////////////////////////////////////////////////////