summaryrefslogtreecommitdiff
path: root/protocols/VKontakte/src
diff options
context:
space:
mode:
Diffstat (limited to 'protocols/VKontakte/src')
-rw-r--r--protocols/VKontakte/src/misc.cpp44
-rw-r--r--protocols/VKontakte/src/resource.h3
-rw-r--r--protocols/VKontakte/src/version.h2
-rw-r--r--protocols/VKontakte/src/vk.h4
-rw-r--r--protocols/VKontakte/src/vk_chats.cpp2
-rw-r--r--protocols/VKontakte/src/vk_options.cpp8
-rw-r--r--protocols/VKontakte/src/vk_proto.cpp1
-rw-r--r--protocols/VKontakte/src/vk_proto.h4
-rw-r--r--protocols/VKontakte/src/vk_queue.cpp4
9 files changed, 62 insertions, 10 deletions
diff --git a/protocols/VKontakte/src/misc.cpp b/protocols/VKontakte/src/misc.cpp
index 9576d09224..b49d4424e2 100644
--- a/protocols/VKontakte/src/misc.cpp
+++ b/protocols/VKontakte/src/misc.cpp
@@ -80,6 +80,48 @@ HANDLE GetIconHandle(int iCommand)
/////////////////////////////////////////////////////////////////////////////////////////
+static const char szHexDigits[] = "0123456789ABCDEF";
+
+char* ExpUrlEncode(const char *szUrl, bool strict)
+{
+ if (szUrl == NULL)
+ return NULL;
+
+ const BYTE *s;
+ int outputLen;
+ for (outputLen = 0, s = (const BYTE*)szUrl; *s; s++) {
+ if ((*s & 0x80 && !strict) || // UTF-8 multibyte
+ ('0' <= *s && *s <= '9') || //0-9
+ ('A' <= *s && *s <= 'Z') || //ABC...XYZ
+ ('a' <= *s && *s <= 'z') || //abc...xyz
+ *s == '~' || *s == '-' || *s == '_' || *s == '.' || *s == ' ') outputLen++;
+ else outputLen += 3;
+ }
+
+ char *szOutput = (char*)mir_alloc(outputLen + 1);
+ if (szOutput == NULL)
+ return NULL;
+
+ char *d = szOutput;
+ for (s = (const BYTE*)szUrl; *s; s++) {
+ if ((*s & 0x80 && !strict) || // UTF-8 multibyte
+ ('0' <= *s && *s <= '9') || //0-9
+ ('A' <= *s && *s <= 'Z') || //ABC...XYZ
+ ('a' <= *s && *s <= 'z') || //abc...xyz
+ *s == '~' || *s == '-' || *s == '_' || *s == '.') *d++ = *s;
+ else if (*s == ' ') *d++ = '+';
+ else {
+ *d++ = '%';
+ *d++ = szHexDigits[*s >> 4];
+ *d++ = szHexDigits[*s & 0xF];
+ }
+ }
+ *d = '\0';
+ return szOutput;
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
AsyncHttpRequest::AsyncHttpRequest()
{
cbSize = sizeof(NETLIBHTTPREQUEST);
@@ -91,6 +133,7 @@ AsyncHttpRequest::AsyncHttpRequest()
bNeedsRestart = false;
bIsMainConn = false;
m_pFunc = NULL;
+ bExpUrlEncode = false;
}
AsyncHttpRequest::AsyncHttpRequest(CVkProto *ppro, int iRequestType, LPCSTR _url, bool bSecure, VK_REQUEST_HANDLER pFunc)
@@ -98,6 +141,7 @@ AsyncHttpRequest::AsyncHttpRequest(CVkProto *ppro, int iRequestType, LPCSTR _url
cbSize = sizeof(NETLIBHTTPREQUEST);
m_bApiReq = true;
bIsMainConn = false;
+ bExpUrlEncode = ppro->m_bUseNonStandardUrlEncode;
AddHeader("Connection", "keep-alive");
AddHeader("Accept-Encoding", "booo");
diff --git a/protocols/VKontakte/src/resource.h b/protocols/VKontakte/src/resource.h
index 3beec16457..bba391dc78 100644
--- a/protocols/VKontakte/src/resource.h
+++ b/protocols/VKontakte/src/resource.h
@@ -93,6 +93,7 @@
#define IDC_ATTBBC_BASIC 1085
#define IDC_ATTBBC_ADV 1086
#define IDC_BBC_ATT_NEWS 1087
+#define IDC_USENOSTDURLENCODE 1088
// Next default values for new objects
//
@@ -101,7 +102,7 @@
#define _APS_NO_MFC 1
#define _APS_NEXT_RESOURCE_VALUE 119
#define _APS_NEXT_COMMAND_VALUE 40001
-#define _APS_NEXT_CONTROL_VALUE 1088
+#define _APS_NEXT_CONTROL_VALUE 1089
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif
diff --git a/protocols/VKontakte/src/version.h b/protocols/VKontakte/src/version.h
index d82be5d6f4..57af18735a 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 0
-#define __BUILD_NUM 41
+#define __BUILD_NUM 43
#include <stdver.h>
diff --git a/protocols/VKontakte/src/vk.h b/protocols/VKontakte/src/vk.h
index 2a20d681ad..61addafec7 100644
--- a/protocols/VKontakte/src/vk.h
+++ b/protocols/VKontakte/src/vk.h
@@ -86,4 +86,6 @@ LPCSTR findHeader(NETLIBHTTPREQUEST *hdr, LPCSTR szField);
bool tlstrstr(TCHAR* _s1, TCHAR* _s2);
void InitIcons(void);
-HANDLE GetIconHandle(int iCommand); \ No newline at end of file
+HANDLE GetIconHandle(int iCommand);
+
+char* ExpUrlEncode(const char *szUrl, bool strict = false); \ No newline at end of file
diff --git a/protocols/VKontakte/src/vk_chats.cpp b/protocols/VKontakte/src/vk_chats.cpp
index 8b1a567ad2..aec5954217 100644
--- a/protocols/VKontakte/src/vk_chats.cpp
+++ b/protocols/VKontakte/src/vk_chats.cpp
@@ -113,7 +113,7 @@ void CVkProto::RetrieveChatInfo(CVkChatInfo *cc)
debugLogA("CVkProto::RetrieveChantInfo(%d)", cc->m_chatid);
if (!IsOnline())
return;
- Push(new AsyncHttpRequest(this, REQUEST_GET, "/method/execute.json", true, &CVkProto::OnReceiveChatInfo)
+ Push(new AsyncHttpRequest(this, REQUEST_GET, "/method/execute.json", true, &CVkProto::OnReceiveChatInfo)
<< CHAR_PARAM("code", szQuery)
<< VER_API)->pUserInfo = cc;
}
diff --git a/protocols/VKontakte/src/vk_options.cpp b/protocols/VKontakte/src/vk_options.cpp
index 9caec1fb78..abc53e5ccd 100644
--- a/protocols/VKontakte/src/vk_options.cpp
+++ b/protocols/VKontakte/src/vk_options.cpp
@@ -245,6 +245,7 @@ INT_PTR CALLBACK CVkProto::OptionsAdvProc(HWND hwndDlg, UINT uMsg, WPARAM wParam
CheckDlgButton(hwndDlg, IDC_HIDECHATS, ppro->m_bHideChats ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_MESASUREAD, ppro->m_bMesAsUnread ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_FORCE_ONLINE_ON_ACT, ppro->m_bUserForceOnlineOnActivity ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hwndDlg, IDC_USENOSTDURLENCODE, ppro->m_bUseNonStandardUrlEncode ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_REPORT_ABUSE, ppro->m_bReportAbuse ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_CLEAR_SERVER_HISTORY, ppro->m_bClearServerHistory ? BST_CHECKED : BST_UNCHECKED);
@@ -263,6 +264,7 @@ INT_PTR CALLBACK CVkProto::OptionsAdvProc(HWND hwndDlg, UINT uMsg, WPARAM wParam
case IDC_HIDECHATS:
case IDC_MESASUREAD:
case IDC_FORCE_ONLINE_ON_ACT:
+ case IDC_USENOSTDURLENCODE:
case IDC_REPORT_ABUSE:
case IDC_CLEAR_SERVER_HISTORY:
case IDC_REMOVE_FROM_FRENDLIST:
@@ -285,12 +287,12 @@ INT_PTR CALLBACK CVkProto::OptionsAdvProc(HWND hwndDlg, UINT uMsg, WPARAM wParam
ppro->m_bMesAsUnread = IsDlgButtonChecked(hwndDlg, IDC_MESASUREAD) == BST_CHECKED;
ppro->setByte("MesAsUnread", ppro->m_bMesAsUnread);
-
-
-
ppro->m_bUserForceOnlineOnActivity = IsDlgButtonChecked(hwndDlg, IDC_FORCE_ONLINE_ON_ACT) == BST_CHECKED;
ppro->setByte("UserForceOnlineOnActivity", ppro->m_bUserForceOnlineOnActivity);
+ ppro->m_bUseNonStandardUrlEncode = IsDlgButtonChecked(hwndDlg, IDC_USENOSTDURLENCODE) == BST_CHECKED;
+ ppro->setByte("UseNonStandardUrlEncode", ppro->m_bUseNonStandardUrlEncode);
+
ppro->m_bReportAbuse = IsDlgButtonChecked(hwndDlg, IDC_REPORT_ABUSE) == BST_CHECKED;
ppro->setByte("ReportAbuseOnBanUser", ppro->m_bReportAbuse);
diff --git a/protocols/VKontakte/src/vk_proto.cpp b/protocols/VKontakte/src/vk_proto.cpp
index fffb4eafed..9bfe354b60 100644
--- a/protocols/VKontakte/src/vk_proto.cpp
+++ b/protocols/VKontakte/src/vk_proto.cpp
@@ -107,6 +107,7 @@ CVkProto::CVkProto(const char *szModuleName, const TCHAR *ptszUserName) :
m_bNotificationFilterReposts = getBool("NotificationFilterComments", true);
m_bNotificationFilterMentions = getBool("NotificationFilterMentions", true);
+ m_bUseNonStandardUrlEncode = getBool("UseNonStandardUrlEncode", false);
// Set all contacts offline -- in case we crashed
SetAllContactStatuses(ID_STATUS_OFFLINE);
vk_Instances.insert(this);
diff --git a/protocols/VKontakte/src/vk_proto.h b/protocols/VKontakte/src/vk_proto.h
index c77952393e..b55bc4f68a 100644
--- a/protocols/VKontakte/src/vk_proto.h
+++ b/protocols/VKontakte/src/vk_proto.h
@@ -52,6 +52,7 @@ struct AsyncHttpRequest : public NETLIBHTTPREQUEST, public MZeroedObject
void *pUserInfo;
int m_iRetry;
bool m_bApiReq;
+ bool bExpUrlEncode;
bool bNeedsRestart, bIsMainConn;
};
@@ -581,7 +582,8 @@ private:
m_bNotificationFilterLikes,
m_bNotificationFilterReposts,
m_bNotificationFilterMentions,
- m_bUseBBCOnAttacmentsAsNews;
+ m_bUseBBCOnAttacmentsAsNews,
+ m_bUseNonStandardUrlEncode;
int m_iNewsInterval,
m_iNotificationsInterval,
diff --git a/protocols/VKontakte/src/vk_queue.cpp b/protocols/VKontakte/src/vk_queue.cpp
index 1fdc21242c..a4c7b59ee4 100644
--- a/protocols/VKontakte/src/vk_queue.cpp
+++ b/protocols/VKontakte/src/vk_queue.cpp
@@ -159,7 +159,7 @@ AsyncHttpRequest* operator<<(AsyncHttpRequest *pReq, const CHAR_PARAM &param)
CMStringA &s = pReq->m_szParam;
if (!s.IsEmpty())
s.AppendChar('&');
- s.AppendFormat("%s=%s", param.szName, ptrA(mir_urlEncode(param.szValue)));
+ s.AppendFormat("%s=%s", param.szName, ptrA(pReq->bExpUrlEncode ? ExpUrlEncode(param.szValue) : mir_urlEncode(param.szValue)));
return pReq;
}
@@ -169,6 +169,6 @@ AsyncHttpRequest* operator<<(AsyncHttpRequest *pReq, const TCHAR_PARAM &param)
CMStringA &s = pReq->m_szParam;
if (!s.IsEmpty())
s.AppendChar('&');
- s.AppendFormat("%s=%s", param.szName, ptrA(mir_urlEncode(szValue)));
+ s.AppendFormat("%s=%s", param.szName, ptrA(pReq->bExpUrlEncode ? ExpUrlEncode(szValue) : mir_urlEncode(szValue)));
return pReq;
}