| 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-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 |
| 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 "PluginStdAfx.h" | 18 #include "PluginStdAfx.h" |
| 19 #include "../shared/Utils.h" |
| 20 #include <memory> |
| 19 #include <algorithm> | 21 #include <algorithm> |
| 20 #include <stdexcept> | 22 #include <stdexcept> |
| 21 #include <vector> | 23 #include <vector> |
| 22 | 24 #include <WinInet.h> |
| 23 #include "../shared/Utils.h" | 25 #include <shlwapi.h> |
| 24 #include "PluginUtil.h" | 26 #include "PluginUtil.h" |
| 25 #include "PluginSettings.h" | 27 #include "PluginSettings.h" |
| 26 | 28 |
| 27 std::wstring HtmlFolderPath() | 29 std::wstring HtmlFolderPath() |
| 28 { | 30 { |
| 29 return GetDllDir() + L"html\\templates\\"; | 31 return GetDllDir() + L"html\\templates\\"; |
| 30 } | 32 } |
| 31 | 33 |
| 32 std::wstring UserSettingsFileUrl() | 34 std::wstring UserSettingsFileUrl() |
| 33 { | 35 { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 47 } | 49 } |
| 48 | 50 |
| 49 std::wstring GetLocationUrl(IWebBrowser2& browser) | 51 std::wstring GetLocationUrl(IWebBrowser2& browser) |
| 50 { | 52 { |
| 51 ATL::CComBSTR locationUrl; | 53 ATL::CComBSTR locationUrl; |
| 52 if (FAILED(browser.get_LocationURL(&locationUrl)) || !locationUrl) | 54 if (FAILED(browser.get_LocationURL(&locationUrl)) || !locationUrl) |
| 53 { | 55 { |
| 54 return std::wstring(); | 56 return std::wstring(); |
| 55 } | 57 } |
| 56 return std::wstring(locationUrl, locationUrl.Length()); | 58 return std::wstring(locationUrl, locationUrl.Length()); |
| 57 } | 59 } |
| 60 |
| 61 void UnescapeUrl(std::wstring& url) |
| 62 { |
| 63 try |
| 64 { |
| 65 DWORD result_length = INTERNET_MAX_URL_LENGTH; |
| 66 std::unique_ptr<wchar_t[]> result(new wchar_t[result_length]); |
| 67 HRESULT hr = UrlUnescapeW(const_cast<wchar_t*>(url.c_str()), result.get(), &
result_length, 0); |
| 68 if (hr == S_OK) |
| 69 { |
| 70 url = std::wstring(result.get(), result_length); |
| 71 } |
| 72 /* |
| 73 * Do nothing. This masks error return values from UrlUnescape without loggi
ng the error. |
| 74 */ |
| 75 } |
| 76 catch(std::bad_alloc e) |
| 77 { |
| 78 /* |
| 79 * When the code has a systematic way of handling bad_alloc, we'll rethrow (
probably). |
| 80 * Until then, we mask the exception and make no modification. |
| 81 */ |
| 82 } |
| 83 catch(...) |
| 84 { |
| 85 // no modification if any other exception |
| 86 } |
| 87 } |
| OLD | NEW |