Left: | ||
Right: |
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 | 25 |
25 #include "Utils.h" | 26 #include "Utils.h" |
26 | 27 |
27 namespace | 28 namespace |
28 { | 29 { |
29 // See http://blogs.msdn.com/b/oldnewthing/archive/2004/10/25/247180.aspx | 30 // See http://blogs.msdn.com/b/oldnewthing/archive/2004/10/25/247180.aspx |
30 EXTERN_C IMAGE_DOS_HEADER __ImageBase; | 31 EXTERN_C IMAGE_DOS_HEADER __ImageBase; |
31 | 32 |
32 std::wstring appDataPath; | 33 std::wstring appDataPath; |
33 | 34 |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
197 return L""; | 198 return L""; |
198 } | 199 } |
199 auto queryStringBeginsAt = questionSignPos + 1; | 200 auto queryStringBeginsAt = questionSignPos + 1; |
200 auto endQueryStringPos = url.find(L'#', queryStringBeginsAt); | 201 auto endQueryStringPos = url.find(L'#', queryStringBeginsAt); |
201 if (endQueryStringPos == std::wstring::npos) | 202 if (endQueryStringPos == std::wstring::npos) |
202 { | 203 { |
203 endQueryStringPos = url.length(); | 204 endQueryStringPos = url.length(); |
204 } | 205 } |
205 return url.substr(queryStringBeginsAt, endQueryStringPos - queryStringBeginsAt ); | 206 return url.substr(queryStringBeginsAt, endQueryStringPos - queryStringBeginsAt ); |
206 } | 207 } |
208 | |
209 std::wstring CanonicalizeUrl(const std::wstring& url) | |
210 { | |
211 std::wstring urlCanonicalized; | |
212 urlCanonicalized.resize(url.length() * 2); | |
213 DWORD urlSize = urlCanonicalized.length(); | |
214 UrlCanonicalizeW(url.c_str(), &urlCanonicalized[0], &urlSize, NULL); | |
sergei
2016/09/07 08:23:31
What about using of 0 instead of NULL for dwFlags
Oleksandr
2016/09/07 09:13:43
Done.
| |
215 urlCanonicalized.resize(urlSize); | |
216 return urlCanonicalized; | |
217 } | |
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, NULL); | |
225 urlEscaped.resize(urlSize); | |
226 return urlEscaped; | |
227 } | |
228 | |
OLD | NEW |