summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--plugins/CrashDumper/src/upload.cpp14
-rw-r--r--plugins/Scriver/src/utils.cpp7
-rw-r--r--plugins/Weather/src/weather_addstn.cpp11
-rw-r--r--protocols/FacebookRM/src/utils.cpp6
-rw-r--r--protocols/GTalkExt/src/handlers.cpp7
-rw-r--r--protocols/GTalkExt/src/inbox.cpp98
-rw-r--r--protocols/Omegle/src/utils.cpp7
-rw-r--r--protocols/Twitter/src/http.cpp6
8 files changed, 34 insertions, 122 deletions
diff --git a/plugins/CrashDumper/src/upload.cpp b/plugins/CrashDumper/src/upload.cpp
index a8e4f2dee5..7b50d9f866 100644
--- a/plugins/CrashDumper/src/upload.cpp
+++ b/plugins/CrashDumper/src/upload.cpp
@@ -72,19 +72,13 @@ void OpenAuthUrl(const char* url)
char user[64], pass[40];
GetLoginStr(user, sizeof(user), pass);
- if (user[0] && pass[0])
- {
+ if (user[0] && pass[0]) {
char str[256];
-
mir_snprintf(str, sizeof(str), url, user);
- char* eurl = (char*)CallService(MS_NETLIB_URLENCODE, 0, (LPARAM)str);
-
- mir_snprintf(str, sizeof(str), "http://www.miranda-vi.org/cdlogin?name=%s&pass=%s&redir=%s", user, pass, eurl);
- CallService(MS_UTILS_OPENURL, 1, (LPARAM)str);
- HeapFree(GetProcessHeap(), 0, eurl);
+ mir_snprintf(str, sizeof(str), "http://www.miranda-vi.org/cdlogin?name=%s&pass=%s&redir=%s", user, pass, mir_ptr<char>( mir_urlEncode(str)));
+ CallService(MS_UTILS_OPENURL, OUF_NEWWINDOW, (LPARAM)str);
}
- else
- CallService(MS_UTILS_OPENURL, 1, (LPARAM)"http://www.miranda-vi.org/");
+ else CallService(MS_UTILS_OPENURL, OUF_NEWWINDOW, (LPARAM)"http://www.miranda-vi.org/");
}
void CreateAuthString(char* auth)
diff --git a/plugins/Scriver/src/utils.cpp b/plugins/Scriver/src/utils.cpp
index 46bbc41530..1963baafd9 100644
--- a/plugins/Scriver/src/utils.cpp
+++ b/plugins/Scriver/src/utils.cpp
@@ -431,9 +431,8 @@ void SearchWord(TCHAR * word, int engine)
{
char szURL[4096];
if (word && word[0]) {
- char *wordUTF = mir_utf8encodeT(word);
- //char *wordURL = (char *)CallService(MS_NETLIB_URLENCODE, 0, (LPARAM)wordUTF);
- char *wordURL = url_encode(wordUTF);
+ mir_ptr<char> wordUTF( mir_utf8encodeT(word));
+ mir_ptr<char> wordURL( mir_urlEncode(wordUTF));
switch (engine) {
case SEARCHENGINE_WIKIPEDIA:
mir_snprintf(szURL, SIZEOF(szURL), "http://en.wikipedia.org/wiki/%s", wordURL);
@@ -462,8 +461,6 @@ void SearchWord(TCHAR * word, int engine)
break;
}
- mir_free(wordUTF);
- mir_free(wordURL);
CallService(MS_UTILS_OPENURL, 1, (LPARAM) szURL);
}
}
diff --git a/plugins/Weather/src/weather_addstn.cpp b/plugins/Weather/src/weather_addstn.cpp
index 22cf2b5ddc..fe315a8ad5 100644
--- a/plugins/Weather/src/weather_addstn.cpp
+++ b/plugins/Weather/src/weather_addstn.cpp
@@ -306,17 +306,12 @@ int IDSearch(TCHAR *sID, const int searchId)
// svcname = the name of the weather service that is currently searching (ie. Yahoo Weather)
int NameSearchProc(TCHAR *name, const int searchId, WINAMESEARCH *sData, TCHAR *svc, TCHAR *svcname)
{
- char loc[256];
TCHAR Name[MAX_DATA_LEN], str[MAX_DATA_LEN], sID[MAX_DATA_LEN], *szData = NULL, *search;
// replace spaces with %20
- {
- mir_ptr<char> szSearchName( mir_utf8encodeT(name));
- char *pstr = (char*)CallService(MS_NETLIB_URLENCODE, 0, (LPARAM)(char*)szSearchName);
- wsprintfA(loc, sData->SearchURL, pstr);
- HeapFree(GetProcessHeap(), 0, pstr);
- }
-
+ char loc[256];
+ mir_ptr<char> szSearchName( mir_utf8encodeT(name));
+ wsprintfA(loc, sData->SearchURL, mir_ptr<char>( mir_urlEncode(szSearchName)));
if (InternetDownloadFile(loc, NULL, &szData) == 0) {
TCHAR* szInfo = szData;
search = _tcsstr(szInfo, sData->NotFoundStr); // determine if data is available
diff --git a/protocols/FacebookRM/src/utils.cpp b/protocols/FacebookRM/src/utils.cpp
index 7b9f9c578e..77772175d9 100644
--- a/protocols/FacebookRM/src/utils.cpp
+++ b/protocols/FacebookRM/src/utils.cpp
@@ -24,11 +24,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
std::string utils::url::encode(const std::string &s)
{
- char *encoded = reinterpret_cast<char*>(CallService(MS_NETLIB_URLENCODE, 0, reinterpret_cast<LPARAM>(s.c_str())));
- std::string ret = encoded;
- HeapFree(GetProcessHeap(), 0, encoded);
-
- return ret;
+ return mir_ptr<char>( mir_urlEncode( s.c_str()));
}
std::string utils::url::decode(std::string data)
diff --git a/protocols/GTalkExt/src/handlers.cpp b/protocols/GTalkExt/src/handlers.cpp
index 6ca82693f0..e72a940d3e 100644
--- a/protocols/GTalkExt/src/handlers.cpp
+++ b/protocols/GTalkExt/src/handlers.cpp
@@ -173,11 +173,10 @@ BOOL InternalListHandler(IJabberInterface *ji, HXML node, LPCTSTR jid, LPCTSTR m
if (ReadCheckbox(0, IDC_STANDARDVIEW, settings))
FormatMessageUrl(MESSAGE_URL_FORMAT_STANDARD, (LPTSTR)url, mailboxUrl, tid);
+ else if (ReadCheckbox(0, IDC_HTMLVIEW, settings))
+ FormatMessageUrl(MESSAGE_URL_FORMAT_HTML, (LPTSTR)url, mailboxUrl, tid);
else
- if (ReadCheckbox(0, IDC_HTMLVIEW, settings))
- FormatMessageUrl(MESSAGE_URL_FORMAT_HTML, (LPTSTR)url, mailboxUrl, tid);
- else
- MakeUrlHex((LPTSTR)url, tid);
+ MakeUrlHex((LPTSTR)url, tid);
CloseNotifications(acc, url, jid, i);
UnreadThreadNotification(acc, jid, url, xi.getAttrValue(node, ATTRNAME_TOTAL_MATCHED), &mtn);
diff --git a/protocols/GTalkExt/src/inbox.cpp b/protocols/GTalkExt/src/inbox.cpp
index cff579bb4c..3e0bd96932 100644
--- a/protocols/GTalkExt/src/inbox.cpp
+++ b/protocols/GTalkExt/src/inbox.cpp
@@ -64,26 +64,6 @@ const DWORD SIZE_OF_JABBER_OPTIONS = 243 * sizeof(DWORD);
#define NLH_INVALID 0
#define NLH_USER 'USER'
-char to_hex(char code) {
- static char hex[] = "0123456789abcdef";
- return hex[code & 15];
-}
-
-char *url_encode(char *str) {
- char *pstr = str, *buf = (char*)malloc(strlen(str) * 3 + 1), *pbuf = buf;
- while (*pstr) {
- if (isalnum(*pstr) || *pstr == '-' || *pstr == '_' || *pstr == '.' || *pstr == ',' || *pstr == '~')
- *pbuf++ = *pstr;
- else if (*pstr == ' ')
- *pbuf++ = '+';
- else
- *pbuf++ = '%', *pbuf++ = to_hex(*pstr >> 4), *pbuf++ = to_hex(*pstr & 15);
- pstr++;
- }
- *pbuf = '\0';
- return buf;
-}
-
LPSTR HttpPost(HANDLE hUser, LPSTR reqUrl, LPSTR reqParams)
{
NETLIBHTTPREQUEST nlhr = {0};
@@ -100,7 +80,7 @@ LPSTR HttpPost(HANDLE hUser, LPSTR reqUrl, LPSTR reqParams)
if (!pResp) return NULL;
__try {
if (HTTP_OK == pResp->resultCode)
- return _strdup(pResp->pData);
+ return mir_strdup(pResp->pData);
else
return NULL;
}
@@ -111,26 +91,10 @@ LPSTR HttpPost(HANDLE hUser, LPSTR reqUrl, LPSTR reqParams)
LPSTR MakeRequest(HANDLE hUser, LPSTR reqUrl, LPSTR reqParamsFormat, LPSTR p1, LPSTR p2)
{
- LPSTR encodedP1 = url_encode(p1);
- __try {
- LPSTR encodedP2 = url_encode(p2);
- __try {
- LPSTR reqParams = (LPSTR)malloc(lstrlenA(reqParamsFormat) + 1 + lstrlenA(encodedP1) + lstrlenA(encodedP2));
- __try {
- sprintf(reqParams, reqParamsFormat, encodedP1, encodedP2);
- return HttpPost(hUser, reqUrl, reqParams);
- }
- __finally {
- free(reqParams);
- }
- }
- __finally {
- free(encodedP2);
- }
- }
- __finally {
- free(encodedP1);
- }
+ mir_ptr<char> encodedP1( mir_urlEncode(p1)), encodedP2( mir_urlEncode(p2));
+ LPSTR reqParams = (LPSTR)alloca(lstrlenA(reqParamsFormat) + 1 + lstrlenA(encodedP1) + lstrlenA(encodedP2));
+ sprintf(reqParams, reqParamsFormat, encodedP1, encodedP2);
+ return HttpPost(hUser, reqUrl, reqParams);
}
LPSTR FindSid(LPSTR resp, LPSTR *LSID)
@@ -155,50 +119,26 @@ LPSTR FindSid(LPSTR resp, LPSTR *LSID)
void DoOpenUrl(LPSTR tokenResp, LPSTR url)
{
- LPSTR encodedUrl = url_encode(url);
- __try {
- LPSTR encodedToken = url_encode(tokenResp);
- __try {
- LPSTR composedUrl = (LPSTR)malloc(lstrlenA(TOKEN_AUTH_URL) + 1 + lstrlenA(encodedToken) + lstrlenA(encodedUrl));
- __try {
- sprintf(composedUrl, TOKEN_AUTH_URL, encodedToken, encodedUrl);
- ShellExecuteA(0, NULL, composedUrl, NULL, NULL, SW_SHOW);
- }
- __finally {
- free(composedUrl);
- }
- }
- __finally {
- free(encodedToken);
- }
- }
- __finally {
- free(encodedUrl);
- }
+ mir_ptr<char> encodedUrl( mir_urlEncode(url)), encodedToken( mir_urlEncode(tokenResp));
+ LPSTR composedUrl = (LPSTR)alloca(lstrlenA(TOKEN_AUTH_URL) + 1 + lstrlenA(encodedToken) + lstrlenA(encodedUrl));
+ sprintf(composedUrl, TOKEN_AUTH_URL, encodedToken, encodedUrl);
+ CallService(MS_UTILS_OPENURL, 0, (LPARAM)composedUrl);
}
BOOL AuthAndOpen(HANDLE hUser, LPSTR url, LPSTR mailbox, LPSTR pwd)
{
- LPSTR authResp = MakeRequest(hUser, AUTH_REQUEST_URL, AUTH_REQUEST_PARAMS, mailbox, pwd);
- if (!authResp) return FALSE;
+ mir_ptr<char> authResp( MakeRequest(hUser, AUTH_REQUEST_URL, AUTH_REQUEST_PARAMS, mailbox, pwd));
+ if (!authResp)
+ return FALSE;
- __try {
- LPSTR LSID;
- LPSTR SID = FindSid(authResp, &LSID);
- LPSTR tokenResp = MakeRequest(hUser, ISSUE_TOKEN_REQUEST_URL, ISSUE_TOKEN_REQUEST_PARAMS, SID, LSID);
- if (!tokenResp) return FALSE;
+ LPSTR LSID;
+ LPSTR SID = FindSid(authResp, &LSID);
+ mir_ptr<char> tokenResp( MakeRequest(hUser, ISSUE_TOKEN_REQUEST_URL, ISSUE_TOKEN_REQUEST_PARAMS, SID, LSID));
+ if (!tokenResp)
+ return FALSE;
- __try {
- DoOpenUrl(tokenResp, url);
- return TRUE;
- }
- __finally {
- free(tokenResp);
- }
- }
- __finally {
- free(authResp);
- }
+ DoOpenUrl(tokenResp, url);
+ return TRUE;
}
struct OPEN_URL_HEADER {
diff --git a/protocols/Omegle/src/utils.cpp b/protocols/Omegle/src/utils.cpp
index f524dcfba1..09b6eed036 100644
--- a/protocols/Omegle/src/utils.cpp
+++ b/protocols/Omegle/src/utils.cpp
@@ -24,12 +24,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
std::string utils::url::encode(const std::string &s)
{
- char *encoded = reinterpret_cast<char*>(CallService( MS_NETLIB_URLENCODE,
- 0,reinterpret_cast<LPARAM>(s.c_str())));
- std::string ret = encoded;
- HeapFree(GetProcessHeap(),0,encoded);
-
- return ret;
+ return mir_ptr<char>( mir_urlEncode( s.c_str()));
}
void utils::text::replace_first( std::string* data, std::string from, std::string to )
diff --git a/protocols/Twitter/src/http.cpp b/protocols/Twitter/src/http.cpp
index f953ec1973..912219dfaf 100644
--- a/protocols/Twitter/src/http.cpp
+++ b/protocols/Twitter/src/http.cpp
@@ -23,9 +23,5 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
std::string http::url_encode(const std::string &s)
{
- char *encoded = reinterpret_cast<char*>(CallService( MS_NETLIB_URLENCODE,0,reinterpret_cast<LPARAM>(s.c_str())));
- std::string ret = encoded;
- HeapFree(GetProcessHeap(),0,encoded);
-
- return ret;
+ return mir_ptr<char>( mir_urlEncode( s.c_str()));
}