| OLD | NEW | 
|---|
| 1 /* | 1 /* | 
| 2  * This file is part of Adblock Plus <https://adblockplus.org/>, | 2  * This file is part of Adblock Plus <https://adblockplus.org/>, | 
| 3  * Copyright (C) 2006-2016 Eyeo GmbH | 3  * Copyright (C) 2006-2016 Eyeo GmbH | 
| 4  * | 4  * | 
| 5  * Adblock Plus is free software: you can redistribute it and/or modify | 5  * Adblock Plus is free software: you can redistribute it and/or modify | 
| 6  * it under the terms of the GNU General Public License version 3 as | 6  * it under the terms of the GNU General Public License version 3 as | 
| 7  * published by the Free Software Foundation. | 7  * published by the Free Software Foundation. | 
| 8  * | 8  * | 
| 9  * Adblock Plus is distributed in the hope that it will be useful, | 9  * Adblock Plus is distributed in the hope that it will be useful, | 
| 10  * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10  * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
| 11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
| 12  * GNU General Public License for more details. | 12  * GNU General Public License for more details. | 
| 13  * | 13  * | 
| 14  * You should have received a copy of the GNU General Public License | 14  * You should have received a copy of the GNU General Public License | 
| 15  * along with Adblock Plus.  If not, see <http://www.gnu.org/licenses/>. | 15  * along with Adblock Plus.  If not, see <http://www.gnu.org/licenses/>. | 
| 16  */ | 16  */ | 
| 17 | 17 | 
| 18 #include <memory> | 18 #include <memory> | 
| 19 #include <stdexcept> | 19 #include <stdexcept> | 
| 20 #include <vector> | 20 #include <vector> | 
| 21 | 21 | 
| 22 #include <Windows.h> | 22 #include <Windows.h> | 
| 23 #include <ShlObj.h> | 23 #include <ShlObj.h> | 
| 24 #include <Shlwapi.h> | 24 #include <Shlwapi.h> | 
|  | 25 #include <WinInet.h> | 
| 25 | 26 | 
| 26 #include "Utils.h" | 27 #include "Utils.h" | 
| 27 | 28 | 
| 28 namespace | 29 namespace | 
| 29 { | 30 { | 
| 30   // See http://blogs.msdn.com/b/oldnewthing/archive/2004/10/25/247180.aspx | 31   // See http://blogs.msdn.com/b/oldnewthing/archive/2004/10/25/247180.aspx | 
| 31   EXTERN_C IMAGE_DOS_HEADER __ImageBase; | 32   EXTERN_C IMAGE_DOS_HEADER __ImageBase; | 
| 32 | 33 | 
| 33   std::wstring appDataPath; | 34   std::wstring appDataPath; | 
| 34 | 35 | 
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 201   auto endQueryStringPos = url.find(L'#', queryStringBeginsAt); | 202   auto endQueryStringPos = url.find(L'#', queryStringBeginsAt); | 
| 202   if (endQueryStringPos == std::wstring::npos) | 203   if (endQueryStringPos == std::wstring::npos) | 
| 203   { | 204   { | 
| 204     endQueryStringPos = url.length(); | 205     endQueryStringPos = url.length(); | 
| 205   } | 206   } | 
| 206   return url.substr(queryStringBeginsAt, endQueryStringPos - queryStringBeginsAt
     ); | 207   return url.substr(queryStringBeginsAt, endQueryStringPos - queryStringBeginsAt
     ); | 
| 207 } | 208 } | 
| 208 | 209 | 
| 209 std::wstring CanonicalizeUrl(const std::wstring& url) | 210 std::wstring CanonicalizeUrl(const std::wstring& url) | 
| 210 { | 211 { | 
| 211   std::wstring urlCanonicalized; | 212   std::wstring urlCanonical; | 
| 212   urlCanonicalized.resize(url.length() * 2); | 213   DWORD urlSize = INTERNET_MAX_URL_LENGTH; | 
| 213   DWORD urlSize = urlCanonicalized.length(); | 214   urlCanonical.resize(urlSize); | 
| 214   UrlCanonicalizeW(url.c_str(), &urlCanonicalized[0], &urlSize, 0); | 215   if ((UrlCanonicalizeW(url.c_str(), &urlCanonical[0], &urlSize, URL_UNESCAPE) !
     = S_OK) || (urlSize <= 0)) | 
| 215   urlCanonicalized.resize(urlSize); | 216     return L""; | 
| 216   return urlCanonicalized; | 217   urlCanonical.resize(urlSize); | 
|  | 218   return urlCanonical; | 
| 217 } | 219 } | 
| 218 |  | 
| 219 std::wstring EscapeUrl(const std::wstring& url) |  | 
| 220 { |  | 
| 221   std::wstring urlEscaped; |  | 
| 222   urlEscaped.resize(url.length() * 2); |  | 
| 223   DWORD urlSize = urlEscaped.length(); |  | 
| 224   UrlEscapeW(url.c_str(), &urlEscaped[0], &urlSize, 0); |  | 
| 225   urlEscaped.resize(urlSize); |  | 
| 226   return urlEscaped; |  | 
| 227 } |  | 
| 228 |  | 
| OLD | NEW | 
|---|