From 1e13a939b177960b7048b8532205bc369501d399 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sun, 24 Mar 2013 22:01:00 +0000 Subject: char* mir_urlEncode(const char *szUrl) added git-svn-id: http://svn.miranda-ng.org/main/trunk@4180 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- src/modules/netlib/netlib.cpp | 38 +++++++------------------------------- 1 file changed, 7 insertions(+), 31 deletions(-) (limited to 'src/modules/netlib') diff --git a/src/modules/netlib/netlib.cpp b/src/modules/netlib/netlib.cpp index 4245a0e5d6..5758824627 100644 --- a/src/modules/netlib/netlib.cpp +++ b/src/modules/netlib/netlib.cpp @@ -409,43 +409,19 @@ INT_PTR NetlibShutdown(WPARAM wParam, LPARAM) return 0; } -static const char szHexDigits[] = "0123456789ABCDEF"; INT_PTR NetlibHttpUrlEncode(WPARAM, LPARAM lParam) { - unsigned char *szOutput, *szInput = (unsigned char*)lParam; - unsigned char *pszIn, *pszOut; - int outputLen; - - if (szInput == NULL) { + if (lParam == NULL) { SetLastError(ERROR_INVALID_PARAMETER); - return (INT_PTR)(char*)NULL; - } - for (outputLen = 0, pszIn = szInput;*pszIn;pszIn++) { - if ((48 <= *pszIn && *pszIn <= 57) || //0-9 - (65 <= *pszIn && *pszIn <= 90) || //ABC...XYZ - (97 <= *pszIn && *pszIn <= 122) || //abc...xyz - *pszIn == '-' || *pszIn == '_' || *pszIn == '.' || *pszIn == ' ') outputLen++; - else outputLen+=3; + return NULL; } - szOutput = (unsigned char*)HeapAlloc(GetProcessHeap(), 0, outputLen+1); - if (szOutput == NULL) { + + char *p = mir_urlEncode((LPCSTR)lParam); + if (p == NULL) { SetLastError(ERROR_OUTOFMEMORY); - return (INT_PTR)(unsigned char*)NULL; - } - for (pszOut = szOutput, pszIn = szInput;*pszIn;pszIn++) { - if ((48 <= *pszIn && *pszIn <= 57) || - (65 <= *pszIn && *pszIn <= 90) || - (97 <= *pszIn && *pszIn <= 122) || - *pszIn == '-' || *pszIn == '_' || *pszIn == '.') *pszOut++=*pszIn; - else if (*pszIn == ' ') *pszOut++='+'; - else { - *pszOut++='%'; - *pszOut++=szHexDigits[*pszIn>>4]; - *pszOut++=szHexDigits[*pszIn&0xF]; - } + return NULL; } - *pszOut = '\0'; - return (INT_PTR)szOutput; + return (INT_PTR)p; } static const char base64chars[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; -- cgit v1.2.3