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

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

Issue 10948032: Fix domain-based whitelisting (Closed)
Patch Set: Created June 14, 2013, 2:44 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
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 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 159
160 return hasError; 160 return hasError;
161 } 161 }
162 162
163 // ============================================================================ 163 // ============================================================================
164 // Whitelisting 164 // Whitelisting
165 // ============================================================================ 165 // ============================================================================
166 166
167 #ifdef SUPPORT_WHITELIST 167 #ifdef SUPPORT_WHITELIST
168 168
169 void CPluginClientBase::CacheWhiteListedUrl(const CString& url, bool isWhitelist ed)
170 {
171 m_criticalSectionWhitelist.Lock();
172 {
173 m_cacheWhitelistedUrls[url] = isWhitelisted;
174 }
175 m_criticalSectionWhitelist.Unlock();
176 }
177
178 bool CPluginClientBase::IsUrlWhiteListed(const CString& url) 169 bool CPluginClientBase::IsUrlWhiteListed(const CString& url)
179 { 170 {
180 if (url.IsEmpty()) 171 if (url.IsEmpty())
181 { 172 {
182 return false; 173 return false;
183 } 174 }
184 175
185 bool isWhitelisted = false; 176 int pos = 0;
186 bool isCached = false; 177 CString http = url.Find('/',pos) >= 0 ? url.Tokenize(L"/", pos) : L"";
Wladimir Palant 2013/06/17 09:33:56 I know that this isn't your code but that variable
Felix Dahlke 2013/06/17 11:19:01 Done.
187 178 CString domain = ExtractDomain(url);
188 m_criticalSectionWhitelist.Lock(); 179 if (http == L"res:" || http == L"file:")
189 { 180 {
190 std::map<CString,bool>::iterator it = m_cacheWhitelistedUrls.find(url); 181 return true;
191
192 isCached = it != m_cacheWhitelistedUrls.end();
193 if (isCached)
194 {
195 isWhitelisted = it->second;
196 }
197 }
198 m_criticalSectionWhitelist.Unlock();
199
200 if (!isCached)
201 {
202 int pos = 0;
203 CString http = url.Find('/',pos) >= 0 ? url.Tokenize(L"/", pos) : L"";
204 CString domain = ExtractDomain(url);
205 if (http == L"res:" || http == L"file:")
206 {
207 isWhitelisted = true;
208 }
209 else
210 {
211 isWhitelisted = CPluginSettings::GetInstance()->IsWhiteListedDomain(domain );
212 }
213
214 CacheWhiteListedUrl(url, isWhitelisted);
215 } 182 }
216 183
217 return isWhitelisted; 184 CPluginSettings* pluginSettings = CPluginSettings::GetInstance();
185 pluginSettings->RefreshWhitelist();
186 return pluginSettings->IsWhiteListedDomain(domain);
Wladimir Palant 2013/06/17 09:33:56 Retrieving all exception domains from the engine j
Felix Dahlke 2013/06/17 11:19:01 Yes, I agree. I frankly didn't dare to change too
218 } 187 }
219 188
220 void CPluginClientBase::ClearWhiteListCache()
221 {
222 m_criticalSectionWhitelist.Lock();
223 {
224 m_cacheWhitelistedUrls.clear();
225 }
226 m_criticalSectionWhitelist.Unlock();
227 }
228
229
230 #endif // SUPPORT_WHITELIST 189 #endif // SUPPORT_WHITELIST
OLDNEW

Powered by Google App Engine
This is Rietveld