From e2c129c8814b6c6843d83f031e955edd3f3312ec Mon Sep 17 00:00:00 2001 From: ElzorFox Date: Fri, 25 Oct 2024 21:15:39 +0500 Subject: VKontakte: fix #4760 --- protocols/VKontakte/src/vk_files.cpp | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) (limited to 'protocols') diff --git a/protocols/VKontakte/src/vk_files.cpp b/protocols/VKontakte/src/vk_files.cpp index 7a29c0d3d8..19b8619881 100644 --- a/protocols/VKontakte/src/vk_files.cpp +++ b/protocols/VKontakte/src/vk_files.cpp @@ -32,30 +32,26 @@ CMStringW CVkProto::GetVkFileItem(CMStringW& _wszUrl, MCONTACT hContact, VKMessa CreateDirectoryTreeW(buf); - CMStringW wszUrl = _wszUrl, wszAltFileName; + CMStringW wszUrl = _wszUrl; wszUrl.Replace(L"\\", L"/"); int i = wszUrl.Find('?'); - if (i > -1) { - wszAltFileName = wszUrl.Mid(i + 1); + if (i > -1) wszUrl.Truncate(i); - } - + i = wszUrl.ReverseFind('/'); if (i > -1) wszUrl = wszUrl.Mid(i + 1); i = wszUrl.ReverseFind('.'); if (i < 0) { - i = wszAltFileName.Find('&'); - if (i > -1) - wszAltFileName.Truncate(i); - - i = wszAltFileName.ReverseFind('='); - if (i > -1) - wszAltFileName = wszAltFileName.Mid(i + 1); + char szHash[33]; + uint8_t digest[16]; + mir_md5_hash((uint8_t*)_wszUrl.c_str(), _wszUrl.GetLength() * sizeof(wchar_t), digest); + bin2hex(digest, sizeof(digest), szHash); - wszUrl = wszAltFileName + L".jpg"; + wszUrl = szHash; + wszUrl += ".jpg"; } wszUrl.Insert(0, buf); -- cgit v1.2.3