summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorElzorFox <elzorfox@ya.ru>2024-10-25 21:15:39 +0500
committerElzorFox <elzorfox@ya.ru>2024-10-25 21:15:39 +0500
commite2c129c8814b6c6843d83f031e955edd3f3312ec (patch)
tree2f31ba47fd739f272aba9b8796c01e608f937fb9
parent9534b7f6e47873097aa79279bfc2f02ea6afffba (diff)
VKontakte: fix #4760
-rw-r--r--protocols/VKontakte/src/vk_files.cpp22
1 files changed, 9 insertions, 13 deletions
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);