From ac6607c5f76566c2c840ca3955a22448738df9b3 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Mon, 28 Jan 2019 15:51:04 +0300 Subject: mir_urlDecode & mir_urlEncode to return CMStringA --- include/delphi/m_core.inc | 8 --- include/m_core.h | 6 --- include/m_system_cpp.h | 10 ++++ libs/libjson/src/stdafx.h | 1 - libs/win32/mir_core.lib | Bin 322734 -> 323166 bytes libs/win64/mir_core.lib | Bin 323850 -> 324326 bytes plugins/AVS/src/stdafx.h | 1 - plugins/AddContactPlus/src/stdafx.h | 1 - plugins/Clist_nicer/src/stdafx.h | 1 - plugins/CloudFile/src/Services/microsoft_api.h | 8 +-- plugins/CloudFile/src/Services/yandex_api.h | 6 +-- plugins/CloudFile/src/http_request.h | 2 +- plugins/CloudFile/src/stdafx.h | 1 - plugins/CrashDumper/src/stdafx.h | 1 - plugins/DbEditorPP/src/stdafx.h | 1 - plugins/Folders/src/stdafx.h | 1 - plugins/GmailNotifier/src/notify.cpp | 6 +-- plugins/IEView/src/stdafx.h | 1 - plugins/MimCmd/src/stdafx.h | 1 - plugins/NewXstatusNotify/src/stdafx.h | 1 - plugins/New_GPG/src/stdafx.h | 1 - plugins/NewsAggregator/Src/stdafx.h | 1 - plugins/Non-IM Contact/src/stdafx.h | 1 - plugins/OpenSSL/src/stdafx.h | 1 - plugins/Popup/src/stdafx.h | 1 - plugins/QuickReplies/src/stdafx.h | 1 - plugins/Scriver/src/stdafx.h | 1 - plugins/Scriver/src/utils.cpp | 18 +++---- plugins/SeenPlugin/src/stdafx.h | 1 - plugins/SendScreenshotPlus/src/stdafx.h | 1 - plugins/SimpleAR/src/stdafx.h | 1 - plugins/SmileyAdd/src/stdafx.h | 1 - plugins/StatusManager/src/stdafx.h | 1 - plugins/TabSRMM/src/stdafx.h | 1 - plugins/TranslitSwitcher/src/stdafx.h | 1 - plugins/UserInfoEx/src/stdafx.h | 1 - plugins/Variables/src/stdafx.h | 1 - plugins/Weather/src/weather_addstn.cpp | 2 +- protocols/Dummy/src/stdafx.h | 1 - protocols/FacebookRM/src/messages.cpp | 2 +- protocols/Gadu-Gadu/src/avatar.cpp | 7 ++- protocols/ICQ-WIM/src/options.cpp | 4 +- protocols/ICQ-WIM/src/proto.cpp | 2 +- protocols/ICQ-WIM/src/server.cpp | 2 +- protocols/ICQ-WIM/src/utils.cpp | 4 +- protocols/JabberG/src/jabber_file.cpp | 6 +-- protocols/JabberG/src/stdafx.h | 1 - protocols/MSN/src/msn_auth.cpp | 11 ++-- protocols/MSN/src/msn_menu.cpp | 2 +- protocols/MSN/src/msn_misc.cpp | 12 ++--- protocols/MSN/src/stdafx.h | 1 - protocols/Sametime/src/StdAfx.h | 1 - protocols/SkypeWeb/src/requests/capabilities.h | 2 +- protocols/SkypeWeb/src/requests/endpoint.h | 2 +- protocols/SkypeWeb/src/requests/history.h | 2 +- protocols/SkypeWeb/src/requests/login.h | 6 +-- protocols/SkypeWeb/src/requests/messages.h | 2 +- protocols/SkypeWeb/src/requests/mslogin.h | 22 ++++---- protocols/SkypeWeb/src/requests/oauth.h | 6 +-- protocols/SkypeWeb/src/requests/trouter.h | 4 +- protocols/SkypeWeb/src/skype_search.cpp | 3 +- protocols/SkypeWeb/src/stdafx.h | 1 - protocols/Steam/src/http_request.h | 4 +- protocols/Steam/src/stdafx.h | 1 - protocols/Twitter/src/http.cpp | 2 +- protocols/VKontakte/src/misc.cpp | 2 +- protocols/VKontakte/src/stdafx.h | 1 - src/core/stdcrypt/src/stdafx.h | 1 - src/core/stdfile/src/stdafx.h | 1 - src/mir_app/src/MHttpRequest.cpp | 4 +- src/mir_app/src/stdafx.h | 1 - src/mir_core/src/http.cpp | 68 +++++++++---------------- src/mir_core/src/stdafx.h | 1 - utils/std_string_utils.cpp | 2 +- 74 files changed, 107 insertions(+), 180 deletions(-) diff --git a/include/delphi/m_core.inc b/include/delphi/m_core.inc index 33ff1fdfb8..479644b896 100644 --- a/include/delphi/m_core.inc +++ b/include/delphi/m_core.inc @@ -144,14 +144,6 @@ procedure KillObjectServices(var ptr); stdcall; function CallProtoService(const szModule:PAnsiChar;const szService:PAnsiChar;wParam:WPARAM;lParam:LPARAM):int_ptr; stdcall; external AppDLL name 'CallProtoService'; - -/////////////////////////////////////////////////////////////////////////////// -// http - -// returned result must be freed using mir_free() -function mir_urlEncode(url:PAnsiChar): PAnsiChar; stdcall; - external CoreDLL name 'mir_urlEncode'; - /////////////////////////////////////////////////////////////////////////////// // wait handles diff --git a/include/m_core.h b/include/m_core.h index 44152a2733..a13d9fc118 100644 --- a/include/m_core.h +++ b/include/m_core.h @@ -150,12 +150,6 @@ typedef DWORD (__cdecl *pfnExceptionFilter)(DWORD code, EXCEPTION_POINTERS* info MIR_CORE_DLL(pfnExceptionFilter) GetExceptionFilter(void); MIR_CORE_DLL(pfnExceptionFilter) SetExceptionFilter(pfnExceptionFilter pMirandaExceptFilter); -/////////////////////////////////////////////////////////////////////////////// -// http support - -MIR_CORE_DLL(char*) mir_urlDecode(const char *szUrl); -MIR_CORE_DLL(char*) mir_urlEncode(const char *szUrl); - /////////////////////////////////////////////////////////////////////////////// // icons support diff --git a/include/m_system_cpp.h b/include/m_system_cpp.h index 667aa5f1c8..78df1577f5 100644 --- a/include/m_system_cpp.h +++ b/include/m_system_cpp.h @@ -30,6 +30,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "m_system.h" #endif +#ifndef M_STRING_H__ + #include +#endif + #if defined(__cplusplus) /////////////////////////////////////////////////////////////////////////////// @@ -424,6 +428,12 @@ struct WCHAR_PARAM : public PARAM {} }; +/////////////////////////////////////////////////////////////////////////////// +// http support + +MIR_CORE_DLL(CMStringA) mir_urlDecode(const char *szUrl); +MIR_CORE_DLL(CMStringA) mir_urlEncode(const char *szUrl); + #endif #endif // M_SYSTEM_CPP_H diff --git a/libs/libjson/src/stdafx.h b/libs/libjson/src/stdafx.h index 7a56cc6d56..f98b28f2aa 100644 --- a/libs/libjson/src/stdafx.h +++ b/libs/libjson/src/stdafx.h @@ -38,5 +38,4 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include -#include #include diff --git a/libs/win32/mir_core.lib b/libs/win32/mir_core.lib index 85bbc4d222..ae087fdef9 100644 Binary files a/libs/win32/mir_core.lib and b/libs/win32/mir_core.lib differ diff --git a/libs/win64/mir_core.lib b/libs/win64/mir_core.lib index a17a757261..778ce4008b 100644 Binary files a/libs/win64/mir_core.lib and b/libs/win64/mir_core.lib differ diff --git a/plugins/AVS/src/stdafx.h b/plugins/AVS/src/stdafx.h index 7a3b675086..78f90ce490 100644 --- a/plugins/AVS/src/stdafx.h +++ b/plugins/AVS/src/stdafx.h @@ -41,7 +41,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include #include #include -#include #include #include diff --git a/plugins/AddContactPlus/src/stdafx.h b/plugins/AddContactPlus/src/stdafx.h index 24535e7645..d374ea0cc1 100644 --- a/plugins/AddContactPlus/src/stdafx.h +++ b/plugins/AddContactPlus/src/stdafx.h @@ -36,7 +36,6 @@ with this program; if not, write to the Free Software Foundation, Inc., #include #include #include -#include #include "m_toptoolbar.h" #include "m_addcontactplus.h" diff --git a/plugins/Clist_nicer/src/stdafx.h b/plugins/Clist_nicer/src/stdafx.h index 9c58d131db..bd776d8938 100644 --- a/plugins/Clist_nicer/src/stdafx.h +++ b/plugins/Clist_nicer/src/stdafx.h @@ -58,7 +58,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include #include #include -#include #include #include diff --git a/plugins/CloudFile/src/Services/microsoft_api.h b/plugins/CloudFile/src/Services/microsoft_api.h index 62a2204459..6c22ac512f 100644 --- a/plugins/CloudFile/src/Services/microsoft_api.h +++ b/plugins/CloudFile/src/Services/microsoft_api.h @@ -48,7 +48,7 @@ namespace OneDriveAPI { public: UploadFileRequest(const char *token, const char *name, const char *data, size_t size, OnConflict strategy = NONE) : - HttpRequest(REQUEST_PUT, FORMAT, ONEDRIVE_API "/special/approot:/%s:/content", ptrA(mir_urlEncode(name))) + HttpRequest(REQUEST_PUT, FORMAT, ONEDRIVE_API "/special/approot:/%s:/content", mir_urlEncode(name).c_str()) { AddUrlParameter("select=id"); @@ -63,7 +63,7 @@ namespace OneDriveAPI } UploadFileRequest(const char *token, const char *parentId, const char *name, const char *data, size_t size, OnConflict strategy = NONE) : - HttpRequest(REQUEST_PUT, FORMAT, ONEDRIVE_API "/items/%s:/%s:/content", parentId, ptrA(mir_urlEncode(name))) + HttpRequest(REQUEST_PUT, FORMAT, ONEDRIVE_API "/items/%s:/%s:/content", parentId, mir_urlEncode(name).c_str()) { AddUrlParameter("select=id"); @@ -82,7 +82,7 @@ namespace OneDriveAPI { public: CreateUploadSessionRequest(const char *token, const char *name, OnConflict strategy = NONE) : - HttpRequest(REQUEST_POST, FORMAT, ONEDRIVE_API "/special/approot:/%s:/createUploadSession", ptrA(mir_urlEncode(name))) + HttpRequest(REQUEST_POST, FORMAT, ONEDRIVE_API "/special/approot:/%s:/createUploadSession", mir_urlEncode(name).c_str()) { AddBearerAuthHeader(token); AddHeader("Content-Type", "application/json"); @@ -102,7 +102,7 @@ namespace OneDriveAPI } CreateUploadSessionRequest(const char *token, const char *parentId, const char *name, OnConflict strategy = NONE) : - HttpRequest(REQUEST_POST, FORMAT, ONEDRIVE_API "/items/%s:/%s:/createUploadSession", parentId, ptrA(mir_urlEncode(name))) + HttpRequest(REQUEST_POST, FORMAT, ONEDRIVE_API "/items/%s:/%s:/createUploadSession", parentId, mir_urlEncode(name).c_str()) { AddBearerAuthHeader(token); AddHeader("Content-Type", "application/json"); diff --git a/plugins/CloudFile/src/Services/yandex_api.h b/plugins/CloudFile/src/Services/yandex_api.h index ac99cb0177..c7c3dfe19d 100644 --- a/plugins/CloudFile/src/Services/yandex_api.h +++ b/plugins/CloudFile/src/Services/yandex_api.h @@ -60,7 +60,7 @@ namespace YandexAPI HttpRequest(REQUEST_GET, YADISK_API "/upload") { AddOAuthHeader(token); - AddUrlParameter("path=app:%s", ptrA(mir_urlEncode(path))); + AddUrlParameter("path=app:%s", mir_urlEncode(path).c_str()); AddUrlParameter("fields=href"); if (strategy == OnConflict::REPLACE) AddUrlParameter("overwrite=true"); @@ -111,7 +111,7 @@ namespace YandexAPI HttpRequest(REQUEST_PUT, YADISK_API "/publish") { AddOAuthHeader(token); - AddUrlParameter("path=app:%s", ptrA(mir_urlEncode(path))); + AddUrlParameter("path=app:%s", mir_urlEncode(path).c_str()); } }; @@ -122,7 +122,7 @@ namespace YandexAPI HttpRequest(REQUEST_GET, YADISK_API) { AddOAuthHeader(token); - AddUrlParameter("path=app:%s", ptrA(mir_urlEncode(path))); + AddUrlParameter("path=app:%s", mir_urlEncode(path).c_str()); AddUrlParameter("fields=public_url"); } }; diff --git a/plugins/CloudFile/src/http_request.h b/plugins/CloudFile/src/http_request.h index db052604b8..c74b2ae40c 100644 --- a/plugins/CloudFile/src/http_request.h +++ b/plugins/CloudFile/src/http_request.h @@ -125,7 +125,7 @@ protected: m_szUrl.AppendFormat("%s=", name); CMStringA value; value.AppendFormatV(valueFormat, valueArgs); - m_szUrl.Append(ptrA(mir_urlEncode(value))); + m_szUrl += mir_urlEncode(value); va_end(valueArgs); } diff --git a/plugins/CloudFile/src/stdafx.h b/plugins/CloudFile/src/stdafx.h index 08628d1488..58801c4a34 100644 --- a/plugins/CloudFile/src/stdafx.h +++ b/plugins/CloudFile/src/stdafx.h @@ -22,7 +22,6 @@ #include #include #include -#include #include #include #include diff --git a/plugins/CrashDumper/src/stdafx.h b/plugins/CrashDumper/src/stdafx.h index 7799b59a4e..c6ace054d4 100644 --- a/plugins/CrashDumper/src/stdafx.h +++ b/plugins/CrashDumper/src/stdafx.h @@ -36,7 +36,6 @@ along with this program. If not, see . #include #include #include -#include #include #include diff --git a/plugins/DbEditorPP/src/stdafx.h b/plugins/DbEditorPP/src/stdafx.h index 1b0b9c586f..d623275d4c 100644 --- a/plugins/DbEditorPP/src/stdafx.h +++ b/plugins/DbEditorPP/src/stdafx.h @@ -32,7 +32,6 @@ #include #include #include -#include #include #include "m_toptoolbar.h" diff --git a/plugins/Folders/src/stdafx.h b/plugins/Folders/src/stdafx.h index afadf0a653..1c56ec4f1d 100644 --- a/plugins/Folders/src/stdafx.h +++ b/plugins/Folders/src/stdafx.h @@ -34,7 +34,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include #include #include -#include #include #include diff --git a/plugins/GmailNotifier/src/notify.cpp b/plugins/GmailNotifier/src/notify.cpp index 42804b3322..b07805dac4 100644 --- a/plugins/GmailNotifier/src/notify.cpp +++ b/plugins/GmailNotifier/src/notify.cpp @@ -46,14 +46,10 @@ static void __cdecl Login_ThreadFunc(Account *curAcc) mir_strcat(lpPathBuffer, szTempName); } else { - char *szEncodedURL = mir_urlEncode(curAcc->name); mir_strcat(lpPathBuffer, LINK); - mir_strcat(lpPathBuffer, szEncodedURL); - //mir_strcat(lpPathBuffer, "&Passwd="); - //mir_strcat(lpPathBuffer, mir_urlEncode(curAcc->pass)); + mir_strcat(lpPathBuffer, mir_urlEncode(curAcc->name)); if (opt.AutoLogin == 1) mir_strcat(lpPathBuffer, "&PersistentCookie=yes"); - mir_free(szEncodedURL); } } } diff --git a/plugins/IEView/src/stdafx.h b/plugins/IEView/src/stdafx.h index fa6f601184..f7da077d89 100644 --- a/plugins/IEView/src/stdafx.h +++ b/plugins/IEView/src/stdafx.h @@ -49,7 +49,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include #include #include -#include #include #include #include diff --git a/plugins/MimCmd/src/stdafx.h b/plugins/MimCmd/src/stdafx.h index d6aa7d304c..7fe5cafc4f 100644 --- a/plugins/MimCmd/src/stdafx.h +++ b/plugins/MimCmd/src/stdafx.h @@ -32,7 +32,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include #include #include -#include #include "../CmdLine/src/mimcmd_ipc.h" #include "version.h" diff --git a/plugins/NewXstatusNotify/src/stdafx.h b/plugins/NewXstatusNotify/src/stdafx.h index 5f92ba982a..02e2fbeb43 100644 --- a/plugins/NewXstatusNotify/src/stdafx.h +++ b/plugins/NewXstatusNotify/src/stdafx.h @@ -52,7 +52,6 @@ #include #include #include -#include #include #include diff --git a/plugins/New_GPG/src/stdafx.h b/plugins/New_GPG/src/stdafx.h index 40518948c2..9a39ad4ea5 100755 --- a/plugins/New_GPG/src/stdafx.h +++ b/plugins/New_GPG/src/stdafx.h @@ -62,7 +62,6 @@ using std::fstream; #include #include #include -#include #include #include diff --git a/plugins/NewsAggregator/Src/stdafx.h b/plugins/NewsAggregator/Src/stdafx.h index b40650e2f9..67c4ff057a 100644 --- a/plugins/NewsAggregator/Src/stdafx.h +++ b/plugins/NewsAggregator/Src/stdafx.h @@ -48,7 +48,6 @@ Boston, MA 02111-1307, USA. #include #include -#include #include "Options.h" #include "version.h" diff --git a/plugins/Non-IM Contact/src/stdafx.h b/plugins/Non-IM Contact/src/stdafx.h index 2c7df9029d..b0cec1f9cb 100644 --- a/plugins/Non-IM Contact/src/stdafx.h +++ b/plugins/Non-IM Contact/src/stdafx.h @@ -44,7 +44,6 @@ struct DLGTEMPLATEEX #include #include #include -#include #include #include "resource.h" diff --git a/plugins/OpenSSL/src/stdafx.h b/plugins/OpenSSL/src/stdafx.h index ef64bfa1e4..8eacec47c2 100644 --- a/plugins/OpenSSL/src/stdafx.h +++ b/plugins/OpenSSL/src/stdafx.h @@ -38,7 +38,6 @@ typedef struct SslHandle *HSSL; #include #include #include -#include #include #include diff --git a/plugins/Popup/src/stdafx.h b/plugins/Popup/src/stdafx.h index a63a558885..74e34acc48 100644 --- a/plugins/Popup/src/stdafx.h +++ b/plugins/Popup/src/stdafx.h @@ -81,7 +81,6 @@ https://miranda-ng.org/distr/ #include #include #include -#include #include #include diff --git a/plugins/QuickReplies/src/stdafx.h b/plugins/QuickReplies/src/stdafx.h index 091d8e57cf..f39d1ea9d6 100644 --- a/plugins/QuickReplies/src/stdafx.h +++ b/plugins/QuickReplies/src/stdafx.h @@ -25,7 +25,6 @@ Boston, MA 02111-1307, USA. #include #include -#include #include #include #include diff --git a/plugins/Scriver/src/stdafx.h b/plugins/Scriver/src/stdafx.h index 7a023eaeab..e1ae6b4b96 100644 --- a/plugins/Scriver/src/stdafx.h +++ b/plugins/Scriver/src/stdafx.h @@ -59,7 +59,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include #include #include -#include #include #include #include diff --git a/plugins/Scriver/src/utils.cpp b/plugins/Scriver/src/utils.cpp index 593eaba0f2..e8f9590391 100644 --- a/plugins/Scriver/src/utils.cpp +++ b/plugins/Scriver/src/utils.cpp @@ -232,32 +232,32 @@ void SearchWord(wchar_t *word, int engine) char szURL[4096]; if (word && word[0]) { T2Utf wordUTF(word); - ptrA wordURL(mir_urlEncode(wordUTF)); + CMStringA wordURL(mir_urlEncode(wordUTF)); switch (engine) { case SEARCHENGINE_WIKIPEDIA: - mir_snprintf(szURL, "http://en.wikipedia.org/wiki/%s", wordURL); + mir_snprintf(szURL, "http://en.wikipedia.org/wiki/%s", wordURL.c_str()); break; case SEARCHENGINE_YAHOO: - mir_snprintf(szURL, "http://search.yahoo.com/search?p=%s&ei=UTF-8", wordURL); + mir_snprintf(szURL, "http://search.yahoo.com/search?p=%s&ei=UTF-8", wordURL.c_str()); break; case SEARCHENGINE_FOODNETWORK: - mir_snprintf(szURL, "http://search.foodnetwork.com/search/delegate.do?fnSearchString=%s", wordURL); + mir_snprintf(szURL, "http://search.foodnetwork.com/search/delegate.do?fnSearchString=%s", wordURL.c_str()); break; case SEARCHENGINE_BING: - mir_snprintf(szURL, "http://www.bing.com/search?q=%s&form=OSDSRC", wordURL); + mir_snprintf(szURL, "http://www.bing.com/search?q=%s&form=OSDSRC", wordURL.c_str()); break; case SEARCHENGINE_GOOGLE_MAPS: - mir_snprintf(szURL, "http://maps.google.com/maps?q=%s&ie=utf-8&oe=utf-8", wordURL); + mir_snprintf(szURL, "http://maps.google.com/maps?q=%s&ie=utf-8&oe=utf-8", wordURL.c_str()); break; case SEARCHENGINE_GOOGLE_TRANSLATE: - mir_snprintf(szURL, "http://translate.google.com/?q=%s&ie=utf-8&oe=utf-8", wordURL); + mir_snprintf(szURL, "http://translate.google.com/?q=%s&ie=utf-8&oe=utf-8", wordURL.c_str()); break; case SEARCHENGINE_YANDEX: - mir_snprintf(szURL, "http://yandex.ru/yandsearch?text=%s", wordURL); + mir_snprintf(szURL, "http://yandex.ru/yandsearch?text=%s", wordURL.c_str()); break; case SEARCHENGINE_GOOGLE: default: - mir_snprintf(szURL, "http://www.google.com/search?q=%s&ie=utf-8&oe=utf-8", wordURL); + mir_snprintf(szURL, "http://www.google.com/search?q=%s&ie=utf-8&oe=utf-8", wordURL.c_str()); break; } diff --git a/plugins/SeenPlugin/src/stdafx.h b/plugins/SeenPlugin/src/stdafx.h index f76c1fc0ae..f8f4c338e2 100644 --- a/plugins/SeenPlugin/src/stdafx.h +++ b/plugins/SeenPlugin/src/stdafx.h @@ -47,7 +47,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include #include #include -#include #include #include diff --git a/plugins/SendScreenshotPlus/src/stdafx.h b/plugins/SendScreenshotPlus/src/stdafx.h index 720f67165e..a615d173bb 100644 --- a/plugins/SendScreenshotPlus/src/stdafx.h +++ b/plugins/SendScreenshotPlus/src/stdafx.h @@ -67,7 +67,6 @@ using namespace std; #include #include #include -#include #include #include diff --git a/plugins/SimpleAR/src/stdafx.h b/plugins/SimpleAR/src/stdafx.h index 0c13a139e3..afbf46a9e4 100644 --- a/plugins/SimpleAR/src/stdafx.h +++ b/plugins/SimpleAR/src/stdafx.h @@ -9,7 +9,6 @@ #include #include #include -#include #include diff --git a/plugins/SmileyAdd/src/stdafx.h b/plugins/SmileyAdd/src/stdafx.h index 3a43b4a00b..6817dfcbc9 100644 --- a/plugins/SmileyAdd/src/stdafx.h +++ b/plugins/SmileyAdd/src/stdafx.h @@ -66,7 +66,6 @@ along with this program. If not, see . #include #include #include -#include #include #include diff --git a/plugins/StatusManager/src/stdafx.h b/plugins/StatusManager/src/stdafx.h index 6162650dad..5594382334 100644 --- a/plugins/StatusManager/src/stdafx.h +++ b/plugins/StatusManager/src/stdafx.h @@ -30,7 +30,6 @@ #include #include #include -#include #include #include #include diff --git a/plugins/TabSRMM/src/stdafx.h b/plugins/TabSRMM/src/stdafx.h index aae1f8a4cc..10debe1e4e 100644 --- a/plugins/TabSRMM/src/stdafx.h +++ b/plugins/TabSRMM/src/stdafx.h @@ -74,7 +74,6 @@ #include #include #include -#include #include #include #include diff --git a/plugins/TranslitSwitcher/src/stdafx.h b/plugins/TranslitSwitcher/src/stdafx.h index fd6e7cd3c7..bd61dbf255 100644 --- a/plugins/TranslitSwitcher/src/stdafx.h +++ b/plugins/TranslitSwitcher/src/stdafx.h @@ -30,7 +30,6 @@ Boston, MA 02111-1307, USA. #include #include #include -#include #include #include diff --git a/plugins/UserInfoEx/src/stdafx.h b/plugins/UserInfoEx/src/stdafx.h index d438efa2da..e3e8f5e21d 100644 --- a/plugins/UserInfoEx/src/stdafx.h +++ b/plugins/UserInfoEx/src/stdafx.h @@ -72,7 +72,6 @@ using namespace std; #include #include #include -#include #include /*********************************************************************************************************** diff --git a/plugins/Variables/src/stdafx.h b/plugins/Variables/src/stdafx.h index 926eeef75f..14e7d17c04 100644 --- a/plugins/Variables/src/stdafx.h +++ b/plugins/Variables/src/stdafx.h @@ -42,7 +42,6 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #include #include #include -#include #include #include diff --git a/plugins/Weather/src/weather_addstn.cpp b/plugins/Weather/src/weather_addstn.cpp index c40fd5c431..7756ac3e39 100644 --- a/plugins/Weather/src/weather_addstn.cpp +++ b/plugins/Weather/src/weather_addstn.cpp @@ -310,7 +310,7 @@ int NameSearchProc(wchar_t *name, const int searchId, WINAMESEARCH *sData, wchar // replace spaces with %20 char loc[256]; T2Utf szSearchName(name); - mir_snprintf(loc, sData->SearchURL, ptrA(mir_urlEncode(szSearchName))); + mir_snprintf(loc, sData->SearchURL, mir_urlEncode(szSearchName).c_str()); if (InternetDownloadFile(loc, nullptr, nullptr, &szData) == 0) { wchar_t* szInfo = szData; search = wcsstr(szInfo, sData->NotFoundStr); // determine if data is available diff --git a/protocols/Dummy/src/stdafx.h b/protocols/Dummy/src/stdafx.h index a921985f35..3655b635ae 100644 --- a/protocols/Dummy/src/stdafx.h +++ b/protocols/Dummy/src/stdafx.h @@ -48,7 +48,6 @@ along with this program. If not, see . #include #include #include -#include #include #include #include diff --git a/protocols/FacebookRM/src/messages.cpp b/protocols/FacebookRM/src/messages.cpp index d3e8461cc9..dc103b739d 100644 --- a/protocols/FacebookRM/src/messages.cpp +++ b/protocols/FacebookRM/src/messages.cpp @@ -326,7 +326,7 @@ HttpRequest* facebook_client::markMessageReadRequest(const LIST &ids) if (id_.substr(0, 3) == "id.") id_ = id_.substr(3); - CMStringA id(::FORMAT, "ids[%s]", ptrA(mir_urlEncode(id_.c_str()))); + CMStringA id(::FORMAT, "ids[%s]", mir_urlEncode(id_.c_str()).c_str()); p->Body << BOOL_PARAM(id, true); } diff --git a/protocols/Gadu-Gadu/src/avatar.cpp b/protocols/Gadu-Gadu/src/avatar.cpp index ab7356ec0a..58ec424d37 100644 --- a/protocols/Gadu-Gadu/src/avatar.cpp +++ b/protocols/Gadu-Gadu/src/avatar.cpp @@ -384,17 +384,16 @@ void __cdecl GaduProto::setavatarthread(void *param) ptrA avatarFileB64(mir_base64_encode(avatarFile, avatarFileLen)); mir_free(avatarFile); - ptrA avatarFileB64Enc(mir_urlEncode(avatarFileB64)); - size_t avatarFileB64EncLen = mir_strlen(avatarFileB64Enc); + CMStringA avatarFileB64Enc(mir_urlEncode(avatarFileB64)); char dataPrefix[64]; mir_snprintf(dataPrefix, "uin=%d&photo=", getDword(GG_KEY_UIN, 0)); size_t dataPrefixLen = mir_strlen(dataPrefix); - size_t dataLen = dataPrefixLen + avatarFileB64EncLen; + size_t dataLen = dataPrefixLen + avatarFileB64Enc.GetLength(); char* data = (char*)mir_alloc(dataLen); memcpy(data, dataPrefix, dataPrefixLen); - memcpy(data + dataPrefixLen, avatarFileB64Enc, avatarFileB64EncLen); + memcpy(data + dataPrefixLen, avatarFileB64Enc, avatarFileB64Enc.GetLength()); //check if we have token, if no - receive new one oauth_checktoken(0); diff --git a/protocols/ICQ-WIM/src/options.cpp b/protocols/ICQ-WIM/src/options.cpp index 3a9d3be3f1..20261a9585 100644 --- a/protocols/ICQ-WIM/src/options.cpp +++ b/protocols/ICQ-WIM/src/options.cpp @@ -140,11 +140,11 @@ void CIcqProto::OnLoginViaPhone(NETLIBHTTPREQUEST *pReply, AsyncHttpRequest *pRe const JSONNode &data = root.data(); m_szAToken = data["token"]["a"].as_mstring(); - m_szAToken = ptrA(mir_urlDecode(m_szAToken)); + m_szAToken = mir_urlDecode(m_szAToken); setString(DB_KEY_ATOKEN, m_szAToken); m_szSessionKey = data["sessionKey"].as_mstring(); - m_szSessionKey = ptrA(mir_urlDecode(m_szSessionKey)); + m_szSessionKey = mir_urlDecode(m_szSessionKey); setString(DB_KEY_SESSIONKEY, m_szSessionKey); m_dwUin = _wtoi(data["loginId"].as_mstring()); diff --git a/protocols/ICQ-WIM/src/proto.cpp b/protocols/ICQ-WIM/src/proto.cpp index bebceafef8..52620647ca 100644 --- a/protocols/ICQ-WIM/src/proto.cpp +++ b/protocols/ICQ-WIM/src/proto.cpp @@ -377,7 +377,7 @@ HANDLE CIcqProto::SendFile(MCONTACT hContact, const wchar_t*, wchar_t **ppszFile pwszFileName = ppszFiles[0]; auto *pReq = new AsyncHttpRequest(CONN_NONE, REQUEST_GET, "https://files.icq.com/files/init", &CIcqProto::OnFileInit); - pReq << CHAR_PARAM("a", m_szAToken) << CHAR_PARAM("client", "icq") << CHAR_PARAM("f", "json") << CHAR_PARAM("fileName", ptrA(mir_urlEncode(T2Utf(pwszFileName)))) + pReq << CHAR_PARAM("a", m_szAToken) << CHAR_PARAM("client", "icq") << CHAR_PARAM("f", "json") << CHAR_PARAM("fileName", mir_urlEncode(T2Utf(pwszFileName))) << CHAR_PARAM("k", ICQ_APP_ID) << INT_PARAM("size", statbuf.st_size) << INT_PARAM("ts", time(0)); CalcHash(pReq); pReq->pUserInfo = pTransfer; diff --git a/protocols/ICQ-WIM/src/server.cpp b/protocols/ICQ-WIM/src/server.cpp index 369b732e59..06994acbb1 100644 --- a/protocols/ICQ-WIM/src/server.cpp +++ b/protocols/ICQ-WIM/src/server.cpp @@ -467,7 +467,7 @@ void CIcqProto::OnCheckPassword(NETLIBHTTPREQUEST *pReply, AsyncHttpRequest*) JSONNode &data = root.data(); m_szAToken = data["token"]["a"].as_mstring(); - m_szAToken = ptrA(mir_urlDecode(m_szAToken)); + m_szAToken = mir_urlDecode(m_szAToken); setString(DB_KEY_ATOKEN, m_szAToken); CMStringA szSessionSecret = data["sessionSecret"].as_mstring(); diff --git a/protocols/ICQ-WIM/src/utils.cpp b/protocols/ICQ-WIM/src/utils.cpp index f372d71de5..a962cb6a3c 100644 --- a/protocols/ICQ-WIM/src/utils.cpp +++ b/protocols/ICQ-WIM/src/utils.cpp @@ -62,7 +62,7 @@ void CIcqProto::CalcHash(AsyncHttpRequest *pReq) { CMStringA hashData(FORMAT, "%s&%s&%s", pReq->requestType == REQUEST_POST ? "POST" : "GET", - ptrA(mir_urlEncode(pReq->m_szUrl)), ptrA(mir_urlEncode(pReq->m_szParam))); + mir_urlEncode(pReq->m_szUrl).c_str(), mir_urlEncode(pReq->m_szParam).c_str()); unsigned int len; BYTE hashOut[MIR_SHA256_HASH_SIZE]; @@ -170,7 +170,7 @@ INT_PTR __cdecl CIcqProto::SetAvatar(WPARAM, LPARAM lParam) _wremove(wszOldName); auto *pReq = new AsyncHttpRequest(CONN_MAIN, REQUEST_POST, ICQ_API_SERVER "/expressions/upload"); - pReq->m_szUrl.AppendFormat("?f=json&aimsid=%s&r=%s&type=largeBuddyIcon", ptrA(mir_urlEncode(m_aimsid.c_str())), pReq->m_reqId); + pReq->m_szUrl.AppendFormat("?f=json&aimsid=%s&r=%s&type=largeBuddyIcon", mir_urlEncode(m_aimsid.c_str()).c_str(), pReq->m_reqId); if (pwszFileName == nullptr) delSetting("AvatarHash"); diff --git a/protocols/JabberG/src/jabber_file.cpp b/protocols/JabberG/src/jabber_file.cpp index ec653ca3c1..4c77f434c0 100644 --- a/protocols/JabberG/src/jabber_file.cpp +++ b/protocols/JabberG/src/jabber_file.cpp @@ -279,8 +279,8 @@ void __cdecl CJabberProto::FileServerThread(filetransfer *ft) else p = ft->std.pszFiles.w[i]; - ptrA pFileName(mir_urlEncode(T2Utf(p))); - if (pFileName != nullptr) { + CMStringA pFileName(mir_urlEncode(T2Utf(p))); + if (!pFileName.IsEmpty()) { ft->szId = JabberId2string(SerialNext()); ptrA myAddr; @@ -294,7 +294,7 @@ void __cdecl CJabberProto::FileServerThread(filetransfer *ft) } char szAddr[256]; - mir_snprintf(szAddr, "http://%s:%d/%s", myAddr, nlb.wPort, pFileName); + mir_snprintf(szAddr, "http://%s:%d/%s", myAddr, nlb.wPort, pFileName.c_str()); size_t len = mir_wstrlen(ptszResource) + mir_wstrlen(ft->jid) + 2; wchar_t *fulljid = (wchar_t *)alloca(sizeof(wchar_t) * len); diff --git a/protocols/JabberG/src/stdafx.h b/protocols/JabberG/src/stdafx.h index 3fd27902d3..105e805d61 100755 --- a/protocols/JabberG/src/stdafx.h +++ b/protocols/JabberG/src/stdafx.h @@ -78,7 +78,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include #include #include -#include #include #include #include diff --git a/protocols/MSN/src/msn_auth.cpp b/protocols/MSN/src/msn_auth.cpp index 5f54249d69..02da53e8c9 100644 --- a/protocols/MSN/src/msn_auth.cpp +++ b/protocols/MSN/src/msn_auth.cpp @@ -559,16 +559,16 @@ CMStringA CMsnProto::HotmailLogin(const char* url) derive_key(key2, key1, key1len, data1, data1len); CMStringA result; - result.Format("%s&da=%s&nonce=", url, ptrA(mir_urlEncode(hotAuthToken))); + result.Format("%s&da=%s&nonce=", url, mir_urlEncode(hotAuthToken).c_str()); ptrA noncenc(mir_base64_encode(nonce, sizeof(nonce))); - result.Append(ptrA(mir_urlEncode(noncenc))); + result.Append(mir_urlEncode(noncenc)); BYTE hash[MIR_SHA1_HASH_SIZE]; unsigned int len; HMAC(EVP_sha1(), key2, sizeof(key2), (BYTE*)result.GetString(), result.GetLength(), hash, &len); ptrA szHash(mir_base64_encode(hash, sizeof(hash))); - result.AppendFormat("&hash=%s", ptrA(mir_urlEncode(szHash))); + result.AppendFormat("&hash=%s", mir_urlEncode(szHash).c_str()); return result; } @@ -690,7 +690,7 @@ bool CMsnProto::RefreshOAuth(const char *pszRefreshToken, const char *pszService nlhr.headers[1].szValue = "application/x-www-form-urlencoded"; nlhr.headers[2].szName = "Cookie"; nlhr.headers[2].szValue = authCookies; - post.Format("client_id=00000000480BC46C&scope=%s&grant_type=refresh_token&refresh_token=%s", ptrA(mir_urlEncode(pszService)), pszRefreshToken); + post.Format("client_id=00000000480BC46C&scope=%s&grant_type=refresh_token&refresh_token=%s", mir_urlEncode(pszService).c_str(), pszRefreshToken); nlhr.pData = (char*)(const char*)post; nlhr.dataLength = (int)mir_strlen(nlhr.pData); @@ -930,8 +930,7 @@ bool CMsnProto::parseLoginPage(char *pszHTML, NETLIBHTTPREQUEST *nlhr, CMStringA if (db_get_static(NULL, m_szModuleName, "Password", szPassword, sizeof(szPassword))) return false; szPassword[99] = 0; - post->Format("PPFT=%s&login=%s&passwd=%s", ptrA(mir_urlEncode(pPPFT)), - ptrA(mir_urlEncode(MyOptions.szEmail)), ptrA(mir_urlEncode(szPassword))); + post->Format("PPFT=%s&login=%s&passwd=%s", mir_urlEncode(pPPFT).c_str(), mir_urlEncode(MyOptions.szEmail).c_str(), mir_urlEncode(szPassword).c_str()); /* Do the login and get the required tokens */ nlhr->dataLength = post->GetLength(); diff --git a/protocols/MSN/src/msn_menu.cpp b/protocols/MSN/src/msn_menu.cpp index b216212d37..70c00d637f 100644 --- a/protocols/MSN/src/msn_menu.cpp +++ b/protocols/MSN/src/msn_menu.cpp @@ -59,7 +59,7 @@ INT_PTR CMsnProto::MsnSendHotmail(WPARAM hContact, LPARAM) if (MSN_IsMeByContact(hContact, szEmail)) MsnGotoInbox(0, 0); else if (msnLoggedIn) - MsnInvokeMyURL(true, CMStringA().Format("http://mail.live.com?rru=compose?to=%s", ptrA(mir_urlEncode(szEmail)))); + MsnInvokeMyURL(true, CMStringA().Format("http://mail.live.com?rru=compose?to=%s", mir_urlEncode(szEmail).c_str())); return 0; } diff --git a/protocols/MSN/src/msn_misc.cpp b/protocols/MSN/src/msn_misc.cpp index 0557aeba8c..2946b53418 100644 --- a/protocols/MSN/src/msn_misc.cpp +++ b/protocols/MSN/src/msn_misc.cpp @@ -254,10 +254,8 @@ int CMsnProto::MSN_SetMyAvatar(const wchar_t* sztFname, void* pData, size_t cbLe // ezxml_set_attr(xmlp, "SHA1C", szSha1c); - char* szBuffer = ezxml_toxml(xmlp, false); + ptrA szBuffer(ezxml_toxml(xmlp, false)); ezxml_free(xmlp); - ptrA szEncodedBuffer(mir_urlEncode(szBuffer)); - free(szBuffer); const wchar_t *szExt; int fmt = ProtoGetBufferFormat(pData, &szExt); @@ -279,7 +277,7 @@ int CMsnProto::MSN_SetMyAvatar(const wchar_t* sztFname, void* pData, size_t cbLe if (!db_get_static(NULL, m_szModuleName, "AvatarHash", szAvatarHashdOld, sizeof(szAvatarHashdOld))) { char *szAvatarHash = arrayToHex(sha1d, sizeof(sha1d)); if (mir_strcmp(szAvatarHashdOld, szAvatarHash)) { - setString("PictObject", szEncodedBuffer); + setString("PictObject", mir_urlEncode(szBuffer)); setString("AvatarHash", szAvatarHash); } mir_free(szAvatarHash); @@ -405,7 +403,7 @@ int ThreadData::sendMessage(int, const char *email, int netId, const char *parMs break; if (*p == 0) { - strncpy_s(tFontName, sizeof(tFontName), ptrA(mir_urlEncode(dbv.pszVal)), _TRUNCATE); + strncpy_s(tFontName, sizeof(tFontName), mir_urlEncode(dbv.pszVal), _TRUNCATE); db_free(&dbv); } } @@ -710,10 +708,10 @@ void CMsnProto::MsnInvokeMyURL(bool ismail, const char* url) if (p) *p = 0; - CMStringA post = HotmailLogin(CMStringA().Format(postdata, (unsigned)time(0), ptrA(mir_urlEncode(url)))); + CMStringA post = HotmailLogin(CMStringA().Format(postdata, (unsigned)time(0), mir_urlEncode(url).c_str())); if (!post.IsEmpty()) { CMStringA hippy(passport); - hippy.AppendFormat("/ppsecure/sha1auth.srf?lc=%d&token=%s", itoa(langpref, passport, 10), ptrA(mir_urlEncode(post))); + hippy.AppendFormat("/ppsecure/sha1auth.srf?lc=%d&token=%s", itoa(langpref, passport, 10), mir_urlEncode(post).c_str()); debugLogA("Starting URL: '%s'", hippy.c_str()); Utils_OpenUrl(hippy.GetString()); diff --git a/protocols/MSN/src/stdafx.h b/protocols/MSN/src/stdafx.h index bf6c0703c8..ab5303e074 100644 --- a/protocols/MSN/src/stdafx.h +++ b/protocols/MSN/src/stdafx.h @@ -61,7 +61,6 @@ along with this program. If not, see . #include #include #include -#include #include #include "m_proto_listeningto.h" diff --git a/protocols/Sametime/src/StdAfx.h b/protocols/Sametime/src/StdAfx.h index 5fa7d2b4d3..86a25658ad 100644 --- a/protocols/Sametime/src/StdAfx.h +++ b/protocols/Sametime/src/StdAfx.h @@ -74,4 +74,3 @@ extern "C" { #include #include #include -#include diff --git a/protocols/SkypeWeb/src/requests/capabilities.h b/protocols/SkypeWeb/src/requests/capabilities.h index 5cf4524f67..174b486ed7 100644 --- a/protocols/SkypeWeb/src/requests/capabilities.h +++ b/protocols/SkypeWeb/src/requests/capabilities.h @@ -22,7 +22,7 @@ class SendCapabilitiesRequest : public HttpRequest { public: SendCapabilitiesRequest(const char *hostname, LoginInfo &li) : - HttpRequest(REQUEST_PUT, FORMAT, "%s/v1/users/ME/endpoints/%s/presenceDocs/messagingService", li.endpoint.szServer, ptrA(mir_urlEncode(li.endpoint.szId))) + HttpRequest(REQUEST_PUT, FORMAT, "%s/v1/users/ME/endpoints/%s/presenceDocs/messagingService", li.endpoint.szServer, mir_urlEncode(li.endpoint.szId).c_str()) { Headers << CHAR_VALUE("Accept", "application/json, text/javascript") diff --git a/protocols/SkypeWeb/src/requests/endpoint.h b/protocols/SkypeWeb/src/requests/endpoint.h index fb75857195..70cc922fcd 100644 --- a/protocols/SkypeWeb/src/requests/endpoint.h +++ b/protocols/SkypeWeb/src/requests/endpoint.h @@ -37,7 +37,7 @@ class DeleteEndpointRequest : public HttpRequest { public: DeleteEndpointRequest(LoginInfo &li) : - HttpRequest(REQUEST_DELETE, FORMAT, "%s/v1/users/ME/endpoints/%s", li.endpoint.szServer, ptrA(mir_urlEncode(li.endpoint.szId))) + HttpRequest(REQUEST_DELETE, FORMAT, "%s/v1/users/ME/endpoints/%s", li.endpoint.szServer, mir_urlEncode(li.endpoint.szId).c_str()) { Headers << CHAR_VALUE("Accept", "application/json, text/javascript") diff --git a/protocols/SkypeWeb/src/requests/history.h b/protocols/SkypeWeb/src/requests/history.h index 28a4816c02..2f82821b31 100644 --- a/protocols/SkypeWeb/src/requests/history.h +++ b/protocols/SkypeWeb/src/requests/history.h @@ -50,7 +50,7 @@ class GetHistoryRequest : public HttpRequest { public: GetHistoryRequest(const char *username, int pageSize, bool isChat, LONGLONG timestamp, LoginInfo &li) : - HttpRequest(REQUEST_GET, FORMAT, "%s/v1/users/ME/conversations/%d:%s/messages", li.endpoint.szServer, isChat ? 19 : 8, ptrA(mir_urlEncode(username))) + HttpRequest(REQUEST_GET, FORMAT, "%s/v1/users/ME/conversations/%d:%s/messages", li.endpoint.szServer, isChat ? 19 : 8, mir_urlEncode(username).c_str()) { Url << LONG_VALUE("startTime", timestamp) diff --git a/protocols/SkypeWeb/src/requests/login.h b/protocols/SkypeWeb/src/requests/login.h index 703cc89f62..a76dd3d15d 100644 --- a/protocols/SkypeWeb/src/requests/login.h +++ b/protocols/SkypeWeb/src/requests/login.h @@ -32,9 +32,9 @@ public: Body << CHAR_VALUE("scopes", "client") - << CHAR_VALUE("clientVersion", ptrA(mir_urlEncode("0/7.4.85.102/259/"))) - << CHAR_VALUE("username", ptrA(mir_urlEncode(username))) - << CHAR_VALUE("passwordHash", pass_ptrA(mir_urlEncode(ptrA(mir_base64_encode(digest, sizeof(digest)))))); + << CHAR_VALUE("clientVersion", mir_urlEncode("0/7.4.85.102/259/").c_str()) + << CHAR_VALUE("username", mir_urlEncode(username).c_str()) + << CHAR_VALUE("passwordHash", mir_urlEncode(ptrA(mir_base64_encode(digest, sizeof(digest)))).c_str()); } }; diff --git a/protocols/SkypeWeb/src/requests/messages.h b/protocols/SkypeWeb/src/requests/messages.h index 6e020d0a4c..d2cf5d69dc 100644 --- a/protocols/SkypeWeb/src/requests/messages.h +++ b/protocols/SkypeWeb/src/requests/messages.h @@ -70,7 +70,7 @@ class SendTypingRequest : public HttpRequest { public: SendTypingRequest(const char *username, int iState, LoginInfo &li) : - HttpRequest(REQUEST_POST, FORMAT, "%s/v1/users/ME/conversations/8:%s/messages", li.endpoint.szServer, ptrA(mir_urlEncode(username))) + HttpRequest(REQUEST_POST, FORMAT, "%s/v1/users/ME/conversations/8:%s/messages", li.endpoint.szServer, mir_urlEncode(username).c_str()) { Headers << CHAR_VALUE("Accept", "application/json, text/javascript") diff --git a/protocols/SkypeWeb/src/requests/mslogin.h b/protocols/SkypeWeb/src/requests/mslogin.h index cbfd5815a1..7064847454 100644 --- a/protocols/SkypeWeb/src/requests/mslogin.h +++ b/protocols/SkypeWeb/src/requests/mslogin.h @@ -28,7 +28,7 @@ public: Url << INT_VALUE ("client_id", 578134) - << CHAR_VALUE ("redirect_uri", ptrA(mir_urlEncode("https://web.skype.com"))); + << CHAR_VALUE ("redirect_uri", mir_urlEncode("https://web.skype.com")); } LoginMSRequest(const char *login, const char *password, const char *cookies_str, const char *ppft) : HttpRequest(REQUEST_POST, "login.live.com/ppsecure/post.srf") @@ -42,8 +42,8 @@ public: << CHAR_VALUE ("Cookie", cookies_str); Body - << CHAR_VALUE ("login", ptrA(mir_urlEncode(login))) - << CHAR_VALUE ("passwd", ptrA(mir_urlEncode(password))) + << CHAR_VALUE ("login", mir_urlEncode(login)) + << CHAR_VALUE ("passwd", mir_urlEncode(password)) << CHAR_VALUE ("PPFT", ppft); } LoginMSRequest(const char *t) : @@ -51,16 +51,16 @@ public: { Url << INT_VALUE ("client_id", 578134) - << CHAR_VALUE ("redirect_uri", ptrA(mir_urlEncode("https://web.skype.com"))); + << CHAR_VALUE ("redirect_uri", mir_urlEncode("https://web.skype.com")); Headers << CHAR_VALUE ("Content-Type", "application/x-www-form-urlencoded"); Body - << CHAR_VALUE ("t", ptrA(mir_urlEncode(t))) + << CHAR_VALUE ("t", mir_urlEncode(t)) << INT_VALUE ("oauthPartner", 999) << INT_VALUE ("client_id", 578134) - << CHAR_VALUE ("redirect_uri", ptrA(mir_urlEncode("https://web.skype.com"))); + << CHAR_VALUE ("redirect_uri", mir_urlEncode("https://web.skype.com")); } LoginMSRequest(const char *t, int) : @@ -68,16 +68,16 @@ public: { Url << INT_VALUE ("client_id", 578134) - << CHAR_VALUE ("redirect_uri", ptrA(mir_urlEncode("https://web.skype.com"))); + << CHAR_VALUE ("redirect_uri", mir_urlEncode("https://web.skype.com")); Headers << CHAR_VALUE ("Content-Type", "application/x-www-form-urlencoded"); Body - << CHAR_VALUE ("t", ptrA(mir_urlEncode(t))) + << CHAR_VALUE ("t", mir_urlEncode(t)) << INT_VALUE ("oauthPartner", 999) << INT_VALUE ("client_id", 578134) - << CHAR_VALUE ("redirect_uri", ptrA(mir_urlEncode("https://web.skype.com"))); + << CHAR_VALUE ("redirect_uri", mir_urlEncode("https://web.skype.com")); } LoginMSRequest(const char *url, const char *login, const char *cookies_str, const char *ppft, const char *code) : @@ -88,9 +88,9 @@ public: Body << CHAR_VALUE ("oct", code) << INT_VALUE ("AdTD", 1) - << CHAR_VALUE ("login", ptrA(mir_urlEncode(login))) + << CHAR_VALUE ("login", mir_urlEncode(login)) << INT_VALUE ("type", 19) - << CHAR_VALUE ("PPFT", ptrA(mir_urlEncode(ppft))); + << CHAR_VALUE ("PPFT", mir_urlEncode(ppft)); } }; diff --git a/protocols/SkypeWeb/src/requests/oauth.h b/protocols/SkypeWeb/src/requests/oauth.h index 6b5fba438d..b633e04db8 100644 --- a/protocols/SkypeWeb/src/requests/oauth.h +++ b/protocols/SkypeWeb/src/requests/oauth.h @@ -47,8 +47,8 @@ public: << CHAR_VALUE("Cookie", cookies); Body - << CHAR_VALUE("login", ptrA(mir_urlEncode(login))) - << CHAR_VALUE("passwd", ptrA(mir_urlEncode(password))) + << CHAR_VALUE("login", mir_urlEncode(login)) + << CHAR_VALUE("passwd", mir_urlEncode(password)) << CHAR_VALUE("PPFT", ppft); } @@ -59,7 +59,7 @@ public: << CHAR_VALUE ("Content-Type", "application/x-www-form-urlencoded"); Body - << CHAR_VALUE ("t", ptrA(mir_urlEncode(t))) + << CHAR_VALUE ("t", mir_urlEncode(t)) << CHAR_VALUE("site_name", "lw.skype.com") << INT_VALUE ("oauthPartner", 999); } diff --git a/protocols/SkypeWeb/src/requests/trouter.h b/protocols/SkypeWeb/src/requests/trouter.h index 5441b4092a..7373a4ec57 100644 --- a/protocols/SkypeWeb/src/requests/trouter.h +++ b/protocols/SkypeWeb/src/requests/trouter.h @@ -118,7 +118,7 @@ public: << CHAR_VALUE("v", "v2") << INT_VALUE("p", 443) << CHAR_VALUE("ccid", ccid.c_str()) - << CHAR_VALUE("tc", ptrA(mir_urlEncode("{\"cv\":\"2014.8.26\",\"hr\":\"\",\"ua\":\"Miranda_NG\",\"v\":\"\"}"))) + << CHAR_VALUE("tc", mir_urlEncode("{\"cv\":\"2014.8.26\",\"hr\":\"\",\"ua\":\"Miranda_NG\",\"v\":\"\"}")) << LONG_VALUE("t", time(NULL) * 1000); Headers @@ -146,7 +146,7 @@ public: << CHAR_VALUE("v", "v2") << INT_VALUE("p", 443) << CHAR_VALUE("ccid", ccid.c_str()) - << CHAR_VALUE("tc", ptrA(mir_urlEncode("{\"cv\":\"2014.8.26\",\"hr\":\"\",\"ua\":\"Miranda_NG\",\"v\":\"\"}"))) + << CHAR_VALUE("tc", mir_urlEncode("{\"cv\":\"2014.8.26\",\"hr\":\"\",\"ua\":\"Miranda_NG\",\"v\":\"\"}")) << LONG_VALUE("t", time(NULL) * 1000); Headers diff --git a/protocols/SkypeWeb/src/skype_search.cpp b/protocols/SkypeWeb/src/skype_search.cpp index eac043d5d4..28a3a32344 100644 --- a/protocols/SkypeWeb/src/skype_search.cpp +++ b/protocols/SkypeWeb/src/skype_search.cpp @@ -27,8 +27,7 @@ void CSkypeProto::SearchBasicThread(void* id) { debugLogA("CSkypeProto::OnSearchBasicThread"); if (IsOnline()) { - ptrA szString(mir_urlEncode(T2Utf((wchar_t*)id))); - SendRequest(new GetSearchRequest(szString, li), &CSkypeProto::OnSearch); + SendRequest(new GetSearchRequest(mir_urlEncode(T2Utf((wchar_t*)id)), li), &CSkypeProto::OnSearch); } } diff --git a/protocols/SkypeWeb/src/stdafx.h b/protocols/SkypeWeb/src/stdafx.h index bf477f5cd3..bf98658877 100644 --- a/protocols/SkypeWeb/src/stdafx.h +++ b/protocols/SkypeWeb/src/stdafx.h @@ -49,7 +49,6 @@ along with this program. If not, see . #include #include #include -#include #include #include #include diff --git a/protocols/Steam/src/http_request.h b/protocols/Steam/src/http_request.h index 3d87defe43..7e8213b87d 100644 --- a/protocols/Steam/src/http_request.h +++ b/protocols/Steam/src/http_request.h @@ -80,7 +80,7 @@ public: HttpUri &operator<<(const CHAR_PARAM ¶m) { - AppendFormat("%s=%s", param.szName, ptrA(mir_urlEncode(param.szValue))); + AppendFormat("%s=%s", param.szName, mir_urlEncode(param.szValue).c_str()); return *this; } }; @@ -269,7 +269,7 @@ __forceinline FormUrlEncodedContent* operator<<(FormUrlEncodedContent *content, __forceinline FormUrlEncodedContent* operator<<(FormUrlEncodedContent *content, const CHAR_PARAM ¶m) { - content->AppendFormat("%s=%s", param.szName, ptrA(mir_urlEncode(param.szValue))); + content->AppendFormat("%s=%s", param.szName, mir_urlEncode(param.szValue).c_str()); return content; } diff --git a/protocols/Steam/src/stdafx.h b/protocols/Steam/src/stdafx.h index 9eb34490c8..0783ee01e4 100644 --- a/protocols/Steam/src/stdafx.h +++ b/protocols/Steam/src/stdafx.h @@ -24,7 +24,6 @@ #include #include #include -#include #include #include #include diff --git a/protocols/Twitter/src/http.cpp b/protocols/Twitter/src/http.cpp index 892dca34ca..200a3d0adb 100644 --- a/protocols/Twitter/src/http.cpp +++ b/protocols/Twitter/src/http.cpp @@ -21,5 +21,5 @@ along with this program. If not, see . std::string http::url_encode(const std::string &s) { - return (char*)ptrA(mir_urlEncode(s.c_str())); + return mir_urlEncode(s.c_str()); } diff --git a/protocols/VKontakte/src/misc.cpp b/protocols/VKontakte/src/misc.cpp index 582aa00481..6951a76f56 100644 --- a/protocols/VKontakte/src/misc.cpp +++ b/protocols/VKontakte/src/misc.cpp @@ -462,7 +462,7 @@ bool CVkProto::AutoFillForm(char *pBody, CMStringA &szAction, CMStringA& szResul if (!result.IsEmpty()) result.AppendChar('&'); result += name + "="; - result += ptrA(mir_urlEncode(value)); + result += mir_urlEncode(value); } } diff --git a/protocols/VKontakte/src/stdafx.h b/protocols/VKontakte/src/stdafx.h index 2fbaf54151..d55c2bd606 100644 --- a/protocols/VKontakte/src/stdafx.h +++ b/protocols/VKontakte/src/stdafx.h @@ -35,7 +35,6 @@ along with this program. If not, see . #include #include #include -#include #include #include #include diff --git a/src/core/stdcrypt/src/stdafx.h b/src/core/stdcrypt/src/stdafx.h index 2ae40fe576..6ce79cf7e1 100644 --- a/src/core/stdcrypt/src/stdafx.h +++ b/src/core/stdcrypt/src/stdafx.h @@ -58,7 +58,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include #include #include -#include #include #include "version.h" diff --git a/src/core/stdfile/src/stdafx.h b/src/core/stdfile/src/stdafx.h index 31e8c09be0..acd785ff7c 100644 --- a/src/core/stdfile/src/stdafx.h +++ b/src/core/stdfile/src/stdafx.h @@ -66,7 +66,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include #include #include -#include #include "version.h" diff --git a/src/mir_app/src/MHttpRequest.cpp b/src/mir_app/src/MHttpRequest.cpp index 0ffd73f894..832b087bc5 100644 --- a/src/mir_app/src/MHttpRequest.cpp +++ b/src/mir_app/src/MHttpRequest.cpp @@ -78,7 +78,7 @@ MIR_APP_DLL(MHttpRequest*) operator<<(MHttpRequest *pReq, const CHAR_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, mir_urlEncode(param.szValue).c_str()); return pReq; } @@ -88,6 +88,6 @@ MIR_APP_DLL(MHttpRequest*) operator<<(MHttpRequest *pReq, const WCHAR_PARAM &par 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, mir_urlEncode(szValue).c_str()); return pReq; } diff --git a/src/mir_app/src/stdafx.h b/src/mir_app/src/stdafx.h index f9c6d70b84..17179644b5 100644 --- a/src/mir_app/src/stdafx.h +++ b/src/mir_app/src/stdafx.h @@ -61,7 +61,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include #include -#include #include #include #include diff --git a/src/mir_core/src/http.cpp b/src/mir_core/src/http.cpp index d1386e4519..312647405e 100755 --- a/src/mir_core/src/http.cpp +++ b/src/mir_core/src/http.cpp @@ -21,71 +21,49 @@ along with this program. If not, see . static const char szHexDigits[] = "0123456789ABCDEF"; -MIR_CORE_DLL(char*) mir_urlDecode(const char *szUrl) +MIR_CORE_DLL(CMStringA) mir_urlDecode(const char *szUrl) { if (szUrl == nullptr) - return nullptr; - - char *ret = mir_strdup(szUrl); + return CMStringA(); - for (char *p = ret; *p; p++) { - switch (*p) { - case '%': - int ii; - sscanf(p+1, "%2x", &ii); - strdel(p, 2); - *p = ii; - break; + CMStringA ret(szUrl); + ret.Replace("+", " "); - case '+': - *p = ' '; - break; - } + for (int i = ret.Find("%", 0); i != -1; i = ret.Find("%", i)) { + int ii; + sscanf(ret.c_str()+i+1, "%2x", &ii); + ret.Delete(i, 3); + ret.Insert(i, ii); } return ret; } -MIR_CORE_DLL(char*) mir_urlEncode(const char *szUrl) +MIR_CORE_DLL(CMStringA) mir_urlEncode(const char *szUrl) { if (szUrl == nullptr) - return nullptr; + return CMStringA(); - const BYTE *s; - int outputLen; - for (outputLen = 0, s = (const BYTE*)szUrl; *s; s++) { - if (('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 == nullptr) - return nullptr; + CMStringA ret; - char *d = szOutput; - for (s = (const BYTE*)szUrl; *s; s++) { - if (('0' <= *s && *s <= '9') || //0-9 - ('A' <= *s && *s <= 'Z') || //ABC...XYZ - ('a' <= *s && *s <= 'z') || //abc...xyz + for (const BYTE *s = (const BYTE*)szUrl; *s; s++) { + if (('0' <= *s && *s <= '9') || // 0-9 + ('A' <= *s && *s <= 'Z') || // ABC...XYZ + ('a' <= *s && *s <= 'z') || // abc...xyz *s == '-' || *s == '_' || *s == '.' || *s == '~') { - *d++ = *s; + ret.AppendChar(*s); } else if (*s == ' ') { - *d++ = '+'; + ret.AppendChar('+'); } else { - *d++ = '%'; - *d++ = szHexDigits[*s >> 4]; - *d++ = szHexDigits[*s & 0xF]; + ret.AppendChar('%'); + ret.AppendChar(szHexDigits[*s >> 4]); + ret.AppendChar(szHexDigits[*s & 0xF]); } } - *d = '\0'; - return szOutput; + + return ret; } ///////////////////////////////////////////////////////////////////////////////////////// diff --git a/src/mir_core/src/stdafx.h b/src/mir_core/src/stdafx.h index 60155a4846..6486e2fbfa 100644 --- a/src/mir_core/src/stdafx.h +++ b/src/mir_core/src/stdafx.h @@ -56,7 +56,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include #include #include -#include #include #include #include diff --git a/utils/std_string_utils.cpp b/utils/std_string_utils.cpp index c021df51e0..bac8957325 100644 --- a/utils/std_string_utils.cpp +++ b/utils/std_string_utils.cpp @@ -21,7 +21,7 @@ along with this program. If not, see . std::string utils::url::encode(const std::string &s) { - return (char*)ptrA(mir_urlEncode(s.c_str())); + return mir_urlEncode(s.c_str()); } std::string utils::url::decode(std::string data) -- cgit v1.2.3