Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: src/shared/Utils.cpp

Issue 29351560: Issue 4395 - Setting page is loaded non-populated on some systems
Patch Set: Use 0 instead of NULL Created Sept. 7, 2016, 9:11 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« src/plugin/PluginTabBase.cpp ('K') | « src/shared/Utils.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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);
Eric 2016/09/07 16:50:53 Canonicalization can add escape sequences, so sizi
Oleksandr 2016/09/08 02:51:15 Done.
213 DWORD urlSize = urlCanonicalized.length();
214 UrlCanonicalizeW(url.c_str(), &urlCanonicalized[0], &urlSize, 0);
Eric 2016/09/07 16:50:53 You can call this function with argument 'dwFlags'
Eric 2016/09/07 16:50:53 Need to verify the return value here, just in case
Oleksandr 2016/09/08 02:51:15 Done.
Oleksandr 2016/09/08 02:51:15 Done.
215 urlCanonicalized.resize(urlSize);
216 return urlCanonicalized;
217 }
218
219 std::wstring EscapeUrl(const std::wstring& url)
Eric 2016/09/07 16:50:53 If we don't compare using escaped URL forms, we do
Oleksandr 2016/09/08 02:51:15 Done.
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
OLDNEW
« src/plugin/PluginTabBase.cpp ('K') | « src/shared/Utils.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld