From 676ff2e0bd23d7fe6b958ab3253d2dc1ccbe5eef Mon Sep 17 00:00:00 2001 From: ElzorFox Date: Wed, 19 May 2021 08:38:22 +0500 Subject: VKontakte: authorization fix version bump --- protocols/VKontakte/src/version.h | 4 ++-- protocols/VKontakte/src/vk_thread.cpp | 26 +++++++++++++++++++++++++- 2 files changed, 27 insertions(+), 3 deletions(-) (limited to 'protocols/VKontakte') diff --git a/protocols/VKontakte/src/version.h b/protocols/VKontakte/src/version.h index f354b5f967..fe73c99beb 100644 --- a/protocols/VKontakte/src/version.h +++ b/protocols/VKontakte/src/version.h @@ -1,7 +1,7 @@ #define __MAJOR_VERSION 0 #define __MINOR_VERSION 1 -#define __RELEASE_NUM 11 -#define __BUILD_NUM 8 +#define __RELEASE_NUM 12 +#define __BUILD_NUM 0 #include diff --git a/protocols/VKontakte/src/vk_thread.cpp b/protocols/VKontakte/src/vk_thread.cpp index 3c90ec5872..013fadba8b 100644 --- a/protocols/VKontakte/src/vk_thread.cpp +++ b/protocols/VKontakte/src/vk_thread.cpp @@ -247,11 +247,35 @@ void CVkProto::OnOAuthAuthorize(NETLIBHTTPREQUEST *reply, AsyncHttpRequest*) return; } - if (reply->resultCode != 200 || !reply->pData || !strstr(reply->pData, "form method=\"post\"")) { // something went wrong + if (reply->resultCode != 200 || !reply->pData || (!strstr(reply->pData, "form method=\"post\"") && !strstr(reply->pData, "meta http-equiv=\"refresh\""))) { // something went wrong ConnectionFailed(LOGINERR_NOSERVER); return; } + LPCSTR pBlankUrl = strstr(reply->pData, szBlankUrl); + if (pBlankUrl) { + debugLogA("CVkProto::OnOAuthAuthorize blank ulr found"); + m_szAccessToken = nullptr; + LPCSTR p = strstr(pBlankUrl, VK_TOKEN_BEG); + if (p) { + p += sizeof(VK_TOKEN_BEG) - 1; + for (LPCSTR q = p + 1; *q; q++) { + if (*q == '&' || *q == '=' || *q == '\"') { + m_szAccessToken = mir_strndup(p, q - p); + break; + } + } + setString("AccessToken", m_szAccessToken); + RetrieveMyInfo(); + } + else { + debugLogA("CVkProto::OnOAuthAuthorize blank ulr found, access_token not found"); + delSetting("AccessToken"); + ConnectionFailed(LOGINERR_NOSERVER); + } + return; + } + char *pMsgWarning = strstr(reply->pData, "service_msg_warning"); if (pMsgWarning) { char *p1 = strchr(pMsgWarning, '>'); -- cgit v1.2.3