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

Delta Between Two Patch Sets: src/shared/Utils.cpp

Issue 5921969115496448: Issue 1115 - Some yahoo page not correctly shown on IE8 when ABP enabled (Closed)
Left Patch Set: simplify processing of query string Created Feb. 16, 2015, 10:48 a.m.
Right Patch Set: fix and rebase Created March 4, 2015, 1:21 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « src/shared/Utils.h ('k') | test/UtilGetQueryStringTest.cpp » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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-2015 Eyeo GmbH 3 * Copyright (C) 2006-2015 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
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 if (length == 0) 74 if (length == 0)
75 return std::wstring(); 75 return std::wstring();
76 76
77 int utf16StringLength = MultiByteToWideChar(CP_UTF8, 0, str.c_str(), length, N ULL, 0); 77 int utf16StringLength = MultiByteToWideChar(CP_UTF8, 0, str.c_str(), length, N ULL, 0);
78 if (utf16StringLength == 0) 78 if (utf16StringLength == 0)
79 throw std::runtime_error("ToUTF16String failed. Can't determine the length o f the buffer needed."); 79 throw std::runtime_error("ToUTF16String failed. Can't determine the length o f the buffer needed.");
80 80
81 std::wstring utf16String(utf16StringLength, L'\0'); 81 std::wstring utf16String(utf16StringLength, L'\0');
82 MultiByteToWideChar(CP_UTF8, 0, str.c_str(), length, &utf16String[0], utf16Str ingLength); 82 MultiByteToWideChar(CP_UTF8, 0, str.c_str(), length, &utf16String[0], utf16Str ingLength);
83 return utf16String; 83 return utf16String;
84 }
85
86 std::vector<std::wstring> ToUtf16Strings(const std::vector<std::string>& values)
87 {
88 std::vector<std::wstring> result;
89 result.reserve(values.size());
90 transform(values.begin(), values.end(), back_inserter(result), ToUtf16String);
91 return result;
84 } 92 }
85 93
86 std::wstring GetDllDir() 94 std::wstring GetDllDir()
87 { 95 {
88 std::vector<WCHAR> path(MAX_PATH); 96 std::vector<WCHAR> path(MAX_PATH);
89 int length = GetModuleFileNameW((HINSTANCE)&__ImageBase, &path[0], static_cast <DWORD>(path.size())); 97 int length = GetModuleFileNameW((HINSTANCE)&__ImageBase, &path[0], static_cast <DWORD>(path.size()));
90 98
91 while (length == path.size()) 99 while (length == path.size())
92 { 100 {
93 // Buffer too small, double buffer size 101 // Buffer too small, double buffer size
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 { 173 {
166 return L""; 174 return L"";
167 } 175 }
168 auto queryStringBeginsAt = questionSignPos + 1; 176 auto queryStringBeginsAt = questionSignPos + 1;
169 auto endQueryStringPos = url.find(L'#', queryStringBeginsAt); 177 auto endQueryStringPos = url.find(L'#', queryStringBeginsAt);
170 if (endQueryStringPos == std::wstring::npos) 178 if (endQueryStringPos == std::wstring::npos)
171 { 179 {
172 endQueryStringPos = url.length(); 180 endQueryStringPos = url.length();
173 } 181 }
174 return url.substr(queryStringBeginsAt, endQueryStringPos - queryStringBeginsAt ); 182 return url.substr(queryStringBeginsAt, endQueryStringPos - queryStringBeginsAt );
175 } 183 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld