From 4c6d4277439397a65c48d954578c6b575dbfc7dd Mon Sep 17 00:00:00 2001 From: George Hazan Date: Mon, 2 Oct 2023 15:47:48 +0300 Subject: =?UTF-8?q?fixes=20#3684=20(ICQ:=20=D0=BD=D0=B5=D0=BA=D0=BE=D1=82?= =?UTF-8?q?=D0=BE=D1=80=D1=8B=D0=B5=20=D1=84=D0=B0=D0=B9=D0=BB=D1=8B=20?= =?UTF-8?q?=D0=B2=D1=81=D1=91=20=D0=B5=D1=89=D1=91=20=D0=BF=D1=80=D0=B8?= =?UTF-8?q?=D1=85=D0=BE=D0=B4=D1=8F=D1=82=20=D0=B2=20=D0=B2=D0=B8=D0=B4?= =?UTF-8?q?=D0=B5=20=D0=B1=D0=B8=D1=82=D1=8B=D1=85=20=D1=81=D1=81=D1=8B?= =?UTF-8?q?=D0=BB=D0=BE=D0=BA)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- protocols/ICQ-WIM/src/server.cpp | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/protocols/ICQ-WIM/src/server.cpp b/protocols/ICQ-WIM/src/server.cpp index 8bb416a2c2..15064b4408 100644 --- a/protocols/ICQ-WIM/src/server.cpp +++ b/protocols/ICQ-WIM/src/server.cpp @@ -176,6 +176,9 @@ IcqFileInfo *CIcqProto::RetrieveFileInfo(MCONTACT hContact, const CMStringW &wsz bool CIcqProto::CheckFile(MCONTACT hContact, CMStringW &wszText, IcqFileInfo *&pFileInfo) { + if (wszText.Left(26) != L"https://files.icq.net/get/") + return false; + pFileInfo = nullptr; int idx = wszText.Find(' '); @@ -540,21 +543,36 @@ void CIcqProto::ParseMessage(MCONTACT hContact, __int64 &lastMsgId, const JSONNo bool bIsOutgoing = it["outgoing"].as_bool(); bool bIsChat = Contact::IsGroupChat(hContact); + + // check for embedded file IcqFileInfo *pFileInfo = nullptr; - if (wszText.Left(26) == L"https://files.icq.net/get/") { - if (!CheckFile(hContact, wszText, pFileInfo)) { - debugLogA("Some shit happened, report this case to developers"); - return; - } + for (auto &jt : it["parts"]) { + if (auto &content = jt["captionedContent"]) { + CMStringW wszUrl(content["url"].as_mstring()); + if (wszUrl.IsEmpty()) + continue; - for (auto &jt : it["parts"]) { - CMStringW wszDescr(jt["captionedContent"]["caption"].as_mstring()); + if (!CheckFile(hContact, wszUrl, pFileInfo)) + continue; + + if (jt["mediaType"].as_string() == "forward") { + int idx = wszText.Find(L"\n\n"); + if (idx != -1) + wszText.Truncate(idx + 2); + pFileInfo->wszDescr = wszText; + } + + CMStringW wszDescr(content["caption"].as_mstring()); if (!wszDescr.IsEmpty()) pFileInfo->wszDescr = wszDescr; + break; } } + // message text might be a separate file link as well + CheckFile(hContact, wszText, pFileInfo); + // process our own messages CMStringA reqId(it["reqId"].as_mstring()); if (CheckOwnMessage(reqId, szMsgId, true)) { -- cgit v1.2.3