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

Delta Between Two Patch Sets: src/plugin/PluginClientBase.cpp

Issue 6012307226230784: Issue #1234 - std::wstring version of UnescapeUrl (Closed)
Left Patch Set: Created Sept. 30, 2014, 3:21 p.m.
Right Patch Set: Created Oct. 1, 2014, 6:52 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/plugin/PluginClientBase.h ('k') | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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 22 matching lines...) Expand all
33 CPluginClientBase::CPluginClientBase() 33 CPluginClientBase::CPluginClientBase()
34 { 34 {
35 } 35 }
36 36
37 37
38 CPluginClientBase::~CPluginClientBase() 38 CPluginClientBase::~CPluginClientBase()
39 { 39 {
40 } 40 }
41 41
42 42
43 bool CPluginClientBase::IsValidDomain(const CString& domain)
44 {
45 return domain != L"about:blank" &&
46 domain != L"about:tabs" &&
47 domain.Find(L"javascript:") != 0 &&
48 !domain.IsEmpty();
49 }
50
51
52 CString& CPluginClientBase::UnescapeUrl(CString& url) 43 CString& CPluginClientBase::UnescapeUrl(CString& url)
53 { 44 {
54 CString unescapedUrl; 45 CString unescapedUrl;
55 DWORD cb = 2048; 46 DWORD cb = 2048;
56 47
57 if (SUCCEEDED(::UrlUnescape(url.GetBuffer(), unescapedUrl.GetBufferSetLength(c b), &cb, 0))) 48 if (SUCCEEDED(::UrlUnescape(url.GetBuffer(), unescapedUrl.GetBufferSetLength(c b), &cb, 0)))
58 { 49 {
59 unescapedUrl.ReleaseBuffer(); 50 unescapedUrl.ReleaseBuffer();
60 unescapedUrl.Truncate(cb); 51 unescapedUrl.Truncate(cb);
61 52
62 url.ReleaseBuffer(); 53 url.ReleaseBuffer();
63 url = unescapedUrl; 54 url = unescapedUrl;
64 } 55 }
65 56
66 return url; 57 return url;
67 } 58 }
68 59
69 void UnescapeUrl(std::wstring& url) 60 void UnescapeUrl(std::wstring& url)
70 { 61 {
71 try 62 try
72 { 63 {
73 DWORD result_length = INTERNET_MAX_URL_LENGTH; 64 DWORD result_length = INTERNET_MAX_URL_LENGTH;
74 std::unique_ptr<wchar_t[]> result(new wchar_t[result_length]); 65 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); 66 HRESULT hr = UrlUnescapeW(const_cast<wchar_t*>(url.c_str()), result.get(), & result_length, 0);
79 if (hr == S_OK) 67 if (hr == S_OK)
80 { 68 {
81 url = std::wstring(result.get(), result_length); 69 url = std::wstring(result.get(), result_length);
82 } 70 }
83 /* 71 /*
84 * Do nothing. This masks error return values from UrlUnescape without loggi ng the error. 72 * Do nothing. This masks error return values from UrlUnescape without loggi ng the error.
85 */ 73 */
86 } 74 }
87 catch(std::bad_alloc e) 75 catch(std::bad_alloc e)
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 136
149 hasError = true; 137 hasError = true;
150 138
151 s_pluginErrors.erase(it); 139 s_pluginErrors.erase(it);
152 } 140 }
153 } 141 }
154 s_criticalSectionLocal.Unlock(); 142 s_criticalSectionLocal.Unlock();
155 143
156 return hasError; 144 return hasError;
157 } 145 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld