Index: src/shared/Utils.cpp |
=================================================================== |
--- a/src/shared/Utils.cpp |
+++ b/src/shared/Utils.cpp |
@@ -22,6 +22,7 @@ |
#include <Windows.h> |
#include <ShlObj.h> |
#include <Shlwapi.h> |
+#include <WinInet.h> |
#include "Utils.h" |
@@ -208,21 +209,11 @@ |
std::wstring CanonicalizeUrl(const std::wstring& url) |
{ |
- std::wstring urlCanonicalized; |
- urlCanonicalized.resize(url.length() * 2); |
- DWORD urlSize = urlCanonicalized.length(); |
- UrlCanonicalizeW(url.c_str(), &urlCanonicalized[0], &urlSize, 0); |
- urlCanonicalized.resize(urlSize); |
- return urlCanonicalized; |
+ std::wstring urlCanonical; |
+ DWORD urlSize = INTERNET_MAX_URL_LENGTH; |
+ urlCanonical.resize(urlSize); |
+ if ((UrlCanonicalizeW(url.c_str(), &urlCanonical[0], &urlSize, URL_UNESCAPE) != S_OK) || (urlSize <= 0)) |
+ return L""; |
+ urlCanonical.resize(urlSize); |
+ return urlCanonical; |
} |
- |
-std::wstring EscapeUrl(const std::wstring& url) |
-{ |
- std::wstring urlEscaped; |
- urlEscaped.resize(url.length() * 2); |
- DWORD urlSize = urlEscaped.length(); |
- UrlEscapeW(url.c_str(), &urlEscaped[0], &urlSize, 0); |
- urlEscaped.resize(urlSize); |
- return urlEscaped; |
-} |
- |