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

Side by Side Diff: src/plugin/PluginClientBase.cpp

Issue 6012307226230784: Issue #1234 - std::wstring version of UnescapeUrl (Closed)
Patch Set: Created Sept. 30, 2014, 3:21 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/plugin/PluginClientBase.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 #include "PluginStdAfx.h" 1 #include "PluginStdAfx.h"
2 2
3 // Internet / FTP 3 // Internet / FTP
4 #include <wininet.h> 4 #include <wininet.h>
5 5
6 // IP adapter 6 // IP adapter
7 #include <iphlpapi.h> 7 #include <iphlpapi.h>
8 8
9 #include "PluginSettings.h" 9 #include "PluginSettings.h"
10 #include "PluginSystem.h" 10 #include "PluginSystem.h"
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 unescapedUrl.ReleaseBuffer(); 59 unescapedUrl.ReleaseBuffer();
60 unescapedUrl.Truncate(cb); 60 unescapedUrl.Truncate(cb);
61 61
62 url.ReleaseBuffer(); 62 url.ReleaseBuffer();
63 url = unescapedUrl; 63 url = unescapedUrl;
64 } 64 }
65 65
66 return url; 66 return url;
67 } 67 }
68 68
69 void UnescapeUrl(std::wstring& url)
70 {
71 try
72 {
73 DWORD result_length = INTERNET_MAX_URL_LENGTH;
74 std::unique_ptr<wchar_t[]> result(new wchar_t[result_length]);
75 /*
76 * Casting away const here is harmless because we're not using the in-place modification mode of UrlUnescape
77 */
78 HRESULT hr = UrlUnescapeW(const_cast<wchar_t*>(url.c_str()), result.get(), & result_length, 0);
79 if (hr == S_OK)
80 {
81 url = std::wstring(result.get(), result_length);
82 }
83 /*
84 * Do nothing. This masks error return values from UrlUnescape without loggi ng the error.
85 */
86 }
87 catch(std::bad_alloc e)
88 {
89 /*
90 * When the code has a systematic way of handling bad_alloc, we'll rethrow ( probably).
91 * Until then, we mask the exception and make no modification.
92 */
93 }
94 catch(...)
95 {
96 // no modification if any other exception
97 }
98 }
69 99
70 void CPluginClientBase::LogPluginError(DWORD errorCode, int errorId, int errorSu bid, const CString& description, bool isAsync, DWORD dwProcessId, DWORD dwThread Id) 100 void CPluginClientBase::LogPluginError(DWORD errorCode, int errorId, int errorSu bid, const CString& description, bool isAsync, DWORD dwProcessId, DWORD dwThread Id)
71 { 101 {
72 // Prevent circular references 102 // Prevent circular references
73 if (CPluginSettings::HasInstance() && isAsync) 103 if (CPluginSettings::HasInstance() && isAsync)
74 { 104 {
75 DEBUG_ERROR_CODE_EX(errorCode, description, dwProcessId, dwThreadId); 105 DEBUG_ERROR_CODE_EX(errorCode, description, dwProcessId, dwThreadId);
76 106
77 CString pluginError; 107 CString pluginError;
78 pluginError.Format(L"%2.2d%2.2d", errorId, errorSubid); 108 pluginError.Format(L"%2.2d%2.2d", errorId, errorSubid);
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 148
119 hasError = true; 149 hasError = true;
120 150
121 s_pluginErrors.erase(it); 151 s_pluginErrors.erase(it);
122 } 152 }
123 } 153 }
124 s_criticalSectionLocal.Unlock(); 154 s_criticalSectionLocal.Unlock();
125 155
126 return hasError; 156 return hasError;
127 } 157 }
OLDNEW
« no previous file with comments | « src/plugin/PluginClientBase.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld