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

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

Issue 5316782940225536: Issue 1557 - Update to the recent libadblockplus to reduce additional updates in the logic later. (Closed)
Left Patch Set: add hg subrepo file Created Jan. 28, 2015, 1:36 p.m.
Right Patch Set: rebase and remove member of CFilter Created Feb. 4, 2015, 12:50 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/PluginWbPassThrough.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 /* 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
(...skipping 20 matching lines...) Expand all
31 31
32 namespace 32 namespace
33 { 33 {
34 const std::string g_blockedByABPPage = "<!DOCTYPE html>" 34 const std::string g_blockedByABPPage = "<!DOCTYPE html>"
35 "<html>" 35 "<html>"
36 "<body>" 36 "<body>"
37 "<!-- blocked by AdblockPlus -->" 37 "<!-- blocked by AdblockPlus -->"
38 "</body>" 38 "</body>"
39 "</html>"; 39 "</html>";
40 40
41 template <typename T>
42 T ASCIIStringToLower(const T& text)
43 {
44 T textlower;
45 std::transform(text.begin(), text.end(), std::back_inserter(textlower),
46 [](T::value_type ch)
47 {
48 return std::tolower(ch, std::locale());
49 }
50 );
51 return textlower;
52 }
53
41 typedef AdblockPlus::FilterEngine::ContentType ContentType; 54 typedef AdblockPlus::FilterEngine::ContentType ContentType;
42 55
43 template <class T> 56 template <class T>
44 T ExtractHttpHeader(const T& allHeaders, const T& targetHeaderNameWithColon, c onst T& delimiter) 57 T ExtractHttpHeader(const T& allHeaders, const T& targetHeaderNameWithColon, c onst T& delimiter)
45 { 58 {
46 auto targetHeaderBeginsAt = allHeaders.find(targetHeaderNameWithColon); 59 const T allHeadersLower = ASCIIStringToLower(allHeaders);
60 auto targetHeaderBeginsAt = allHeadersLower.find(ASCIIStringToLower(targetHe aderNameWithColon));
47 if (targetHeaderBeginsAt == T::npos) 61 if (targetHeaderBeginsAt == T::npos)
48 { 62 {
49 return T(); 63 return T();
50 } 64 }
51 targetHeaderBeginsAt += targetHeaderNameWithColon.length(); 65 targetHeaderBeginsAt += targetHeaderNameWithColon.length();
52 auto targetHeaderEndsAt = allHeaders.find(delimiter, targetHeaderBeginsAt); 66 auto targetHeaderEndsAt = allHeadersLower.find(ASCIIStringToLower(delimiter) , targetHeaderBeginsAt);
53 if (targetHeaderEndsAt == T::npos) 67 if (targetHeaderEndsAt == T::npos)
54 { 68 {
55 return T(); 69 return T();
56 } 70 }
57 return allHeaders.substr(targetHeaderBeginsAt, targetHeaderEndsAt - targetHe aderBeginsAt); 71 return allHeaders.substr(targetHeaderBeginsAt, targetHeaderEndsAt - targetHe aderBeginsAt);
58 } 72 }
59 73
60 std::string ExtractHttpAcceptHeader(IInternetProtocol* internetProtocol) 74 std::string ExtractHttpAcceptHeader(IInternetProtocol* internetProtocol)
61 { 75 {
62 // Despite there being HTTP_QUERY_ACCEPT and other query info flags, they do n't work here, 76 // Despite there being HTTP_QUERY_ACCEPT and other query info flags, they do n't work here,
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 return false; 307 return false;
294 } 308 }
295 309
296 STDMETHODIMP WBPassthruSink::BeginningTransaction(LPCWSTR szURL, LPCWSTR szHeade rs, DWORD dwReserved, LPWSTR* pszAdditionalHeaders) 310 STDMETHODIMP WBPassthruSink::BeginningTransaction(LPCWSTR szURL, LPCWSTR szHeade rs, DWORD dwReserved, LPWSTR* pszAdditionalHeaders)
297 { 311 {
298 if (!szURL) 312 if (!szURL)
299 { 313 {
300 return E_POINTER; 314 return E_POINTER;
301 } 315 }
302 std::wstring src = szURL; 316 std::wstring src = szURL;
317 UnescapeUrl(src);
303 DEBUG_GENERAL(ToCString(src)); 318 DEBUG_GENERAL(ToCString(src));
304 319
305 std::string acceptHeader = ExtractHttpAcceptHeader(m_spTargetProtocol); 320 std::string acceptHeader = ExtractHttpAcceptHeader(m_spTargetProtocol);
306 321
307 if (pszAdditionalHeaders) 322 if (pszAdditionalHeaders)
308 { 323 {
309 *pszAdditionalHeaders = nullptr; 324 *pszAdditionalHeaders = nullptr;
310 } 325 }
311 326
312 CComPtr<IHttpNegotiate> httpNegotiate; 327 CComPtr<IHttpNegotiate> httpNegotiate;
(...skipping 13 matching lines...) Expand all
326 CPluginClient* client = CPluginClient::GetInstance(); 341 CPluginClient* client = CPluginClient::GetInstance();
327 342
328 if (tab && client) 343 if (tab && client)
329 { 344 {
330 std::wstring documentUrl = tab->GetDocumentUrl(); 345 std::wstring documentUrl = tab->GetDocumentUrl();
331 // Page is identical to document => don't block 346 // Page is identical to document => don't block
332 if (documentUrl == src) 347 if (documentUrl == src)
333 { 348 {
334 return nativeHr; 349 return nativeHr;
335 } 350 }
336 else if (CPluginSettings::GetInstance()->IsPluginEnabled() && !client->IsWhi telistedUrl(std::wstring(documentUrl))) 351 else if (CPluginSettings::GetInstance()->IsPluginEnabled() && !client->IsWhi telistedUrl(documentUrl))
337 { 352 {
338 if (tab->IsFrameCached(src)) 353 if (tab->IsFrameCached(src))
339 { 354 {
340 m_contentType = ContentType::CONTENT_TYPE_SUBDOCUMENT; 355 m_contentType = ContentType::CONTENT_TYPE_SUBDOCUMENT;
341 } 356 }
342 } 357 }
343 } 358 }
344 359
345 if (IsFlashRequest(pszAdditionalHeaders)) 360 if (IsFlashRequest(pszAdditionalHeaders))
346 { 361 {
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 } 425 }
411 426
412 return OnStart(szUrl, pOIProtSink, pOIBindInfo, grfPI, dwReserved, m_spInterne tProtocol); 427 return OnStart(szUrl, pOIProtSink, pOIBindInfo, grfPI, dwReserved, m_spInterne tProtocol);
413 } 428 }
414 429
415 STDMETHODIMP WBPassthru::Read(/* [in, out] */ void *pv,/* [in] */ ULONG cb,/* [o ut] */ ULONG *pcbRead) 430 STDMETHODIMP WBPassthru::Read(/* [in, out] */ void *pv,/* [in] */ ULONG cb,/* [o ut] */ ULONG *pcbRead)
416 { 431 {
417 WBPassthruSink* pSink = GetSink(); 432 WBPassthruSink* pSink = GetSink();
418 return pSink->OnRead(pv, cb, pcbRead); 433 return pSink->OnRead(pv, cb, pcbRead);
419 } 434 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld