| 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 "PluginClientBase.h" | 18 #include "PluginClientBase.h" |
| 19 | 19 |
| 20 #include <memory> | |
| 21 #include <WinInet.h> | |
| 22 #include <shlwapi.h> | |
| 23 | |
| 24 #include "PluginSettings.h" | 20 #include "PluginSettings.h" |
| 25 #include "Config.h" | 21 #include "Config.h" |
| 26 #include "PluginDebug.h" | 22 #include "PluginDebug.h" |
| 27 | 23 |
| 28 CComAutoCriticalSection LogQueue::s_criticalSectionQueue; | 24 CComAutoCriticalSection LogQueue::s_criticalSectionQueue; |
| 29 std::vector<CPluginError> LogQueue::s_pluginErrors; | 25 std::vector<CPluginError> LogQueue::s_pluginErrors; |
| 30 | 26 |
| 31 | |
| 32 void UnescapeUrl(std::wstring& url) | |
| 33 { | |
| 34 try | |
| 35 { | |
| 36 DWORD result_length = INTERNET_MAX_URL_LENGTH; | |
| 37 std::unique_ptr<wchar_t[]> result(new wchar_t[result_length]); | |
| 38 HRESULT hr = UrlUnescapeW(const_cast<wchar_t*>(url.c_str()), result.get(), &
result_length, 0); | |
| 39 if (hr == S_OK) | |
| 40 { | |
| 41 url = std::wstring(result.get(), result_length); | |
| 42 } | |
| 43 /* | |
| 44 * Do nothing. This masks error return values from UrlUnescape without loggi
ng the error. | |
| 45 */ | |
| 46 } | |
| 47 catch(std::bad_alloc e) | |
| 48 { | |
| 49 /* | |
| 50 * When the code has a systematic way of handling bad_alloc, we'll rethrow (
probably). | |
| 51 * Until then, we mask the exception and make no modification. | |
| 52 */ | |
| 53 } | |
| 54 catch(...) | |
| 55 { | |
| 56 // no modification if any other exception | |
| 57 } | |
| 58 } | |
| 59 | |
| 60 void LogQueue::LogPluginError(DWORD errorCode, int errorId, int errorSubid, cons
t std::string& description, bool isAsync, DWORD dwProcessId, DWORD dwThreadId) | 27 void LogQueue::LogPluginError(DWORD errorCode, int errorId, int errorSubid, cons
t std::string& description, bool isAsync, DWORD dwProcessId, DWORD dwThreadId) |
| 61 { | 28 { |
| 62 // Prevent circular references | 29 // Prevent circular references |
| 63 if (CPluginSettings::HasInstance() && isAsync) | 30 if (CPluginSettings::HasInstance() && isAsync) |
| 64 { | 31 { |
| 65 DEBUG_ERROR_CODE_EX(errorCode, description, dwProcessId, dwThreadId); | 32 DEBUG_ERROR_CODE_EX(errorCode, description, dwProcessId, dwThreadId); |
| 66 | 33 |
| 67 CString pluginError; | 34 CString pluginError; |
| 68 pluginError.Format(L"%2.2d%2.2d", errorId, errorSubid); | 35 pluginError.Format(L"%2.2d%2.2d", errorId, errorSubid); |
| 69 | 36 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 | 75 |
| 109 hasError = true; | 76 hasError = true; |
| 110 | 77 |
| 111 s_pluginErrors.erase(it); | 78 s_pluginErrors.erase(it); |
| 112 } | 79 } |
| 113 } | 80 } |
| 114 s_criticalSectionQueue.Unlock(); | 81 s_criticalSectionQueue.Unlock(); |
| 115 | 82 |
| 116 return hasError; | 83 return hasError; |
| 117 } | 84 } |
| OLD | NEW |