| Left: | ||
| Right: |
| OLD | NEW |
|---|---|
| 1 #include "PluginStdAfx.h" | 1 #include "PluginStdAfx.h" |
| 2 | 2 |
| 3 #include "PluginWbPassThrough.h" | 3 #include "PluginWbPassThrough.h" |
| 4 #include "PluginClient.h" | 4 #include "PluginClient.h" |
| 5 #include "PluginClientFactory.h" | 5 #include "PluginClientFactory.h" |
| 6 #include "PluginFilter.h" | 6 #include "PluginFilter.h" |
| 7 #include "PluginSettings.h" | 7 #include "PluginSettings.h" |
| 8 #include "PluginClass.h" | 8 #include "PluginClass.h" |
| 9 #include "PluginSystem.h" | 9 #include "PluginSystem.h" |
| 10 | 10 |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 38 } | 38 } |
| 39 // It is important to have this check last, since it is rather generic, and mi ght overlay text/html, for example | 39 // It is important to have this check last, since it is rather generic, and mi ght overlay text/html, for example |
| 40 if (mimeType.Find(L"xml") >= 0) | 40 if (mimeType.Find(L"xml") >= 0) |
| 41 { | 41 { |
| 42 return CFilter::contentTypeXmlHttpRequest; | 42 return CFilter::contentTypeXmlHttpRequest; |
| 43 } | 43 } |
| 44 | 44 |
| 45 return CFilter::contentTypeAny; | 45 return CFilter::contentTypeAny; |
| 46 } | 46 } |
| 47 | 47 |
| 48 int WBPassthruSink::GetContentTypeFromURL(CString src) | 48 int WBPassthruSink::GetContentTypeFromURL(std::wstring src) |
|
sergei
2014/10/17 10:10:12
`const std::wstring&`
| |
| 49 { | 49 { |
| 50 CString srcExt = src; | 50 CString srcLegacy = ToCString(src); |
| 51 CString srcExt = srcLegacy; | |
| 51 | 52 |
| 52 int pos = 0; | 53 int pos = 0; |
| 53 if ((pos = src.Find('?')) > 0) | 54 if ((pos = srcLegacy.Find('?')) > 0) |
| 54 { | 55 { |
| 55 srcExt = src.Left(pos); | 56 srcExt = srcLegacy.Left(pos); |
| 56 } | 57 } |
| 57 | 58 |
| 58 int lastDotIndex = srcExt.ReverseFind('.'); | 59 int lastDotIndex = srcExt.ReverseFind('.'); |
| 59 if (lastDotIndex < 0) | 60 if (lastDotIndex < 0) |
| 60 return CFilter::contentTypeAny; | 61 return CFilter::contentTypeAny; |
| 61 CString ext = srcExt.Mid(lastDotIndex); | 62 CString ext = srcExt.Mid(lastDotIndex); |
| 62 if (ext == L".jpg" || ext == L".gif" || ext == L".png" || ext == L".jpeg") | 63 if (ext == L".jpg" || ext == L".gif" || ext == L".png" || ext == L".jpeg") |
| 63 { | 64 { |
| 64 return CFilter::contentTypeImage; | 65 return CFilter::contentTypeImage; |
| 65 } | 66 } |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 83 { | 84 { |
| 84 return CFilter::contentTypeSubdocument; | 85 return CFilter::contentTypeSubdocument; |
| 85 } | 86 } |
| 86 else | 87 else |
| 87 { | 88 { |
| 88 return CFilter::contentTypeAny & ~CFilter::contentTypeSubdocument; | 89 return CFilter::contentTypeAny & ~CFilter::contentTypeSubdocument; |
| 89 } | 90 } |
| 90 | 91 |
| 91 } | 92 } |
| 92 | 93 |
| 93 int WBPassthruSink::GetContentType(CString mimeType, std::wstring domain, CStrin g src) | 94 int WBPassthruSink::GetContentType(CString mimeType, std::wstring domain, std::w string src) |
|
sergei
2014/10/17 10:10:12
const ATL::CString&, const std::wstring&
| |
| 94 { | 95 { |
| 95 // No referer or mime type | 96 // No referer or mime type |
| 96 // BINDSTRING_XDR_ORIGIN works only for IE v8+ | 97 // BINDSTRING_XDR_ORIGIN works only for IE v8+ |
| 97 if (mimeType.IsEmpty() && domain.empty() && CPluginClient::GetInstance()->GetI EVersion() >= 8) | 98 if (mimeType.IsEmpty() && domain.empty() && CPluginClient::GetInstance()->GetI EVersion() >= 8) |
| 98 { | 99 { |
| 99 return CFilter::contentTypeXmlHttpRequest; | 100 return CFilter::contentTypeXmlHttpRequest; |
| 100 } | 101 } |
| 101 int contentType = GetContentTypeFromMimeType(mimeType); | 102 int contentType = GetContentTypeFromMimeType(mimeType); |
| 102 if (contentType == CFilter::contentTypeAny) | 103 if (contentType == CFilter::contentTypeAny) |
| 103 { | 104 { |
| 104 contentType = GetContentTypeFromURL(src); | 105 contentType = GetContentTypeFromURL(src); |
| 105 } | 106 } |
| 106 return contentType; | 107 return contentType; |
| 107 } | 108 } |
| 108 | 109 |
| 109 //////////////////////////////////////////////////////////////////////////////// //////// | 110 //////////////////////////////////////////////////////////////////////////////// //////// |
| 110 //WBPassthruSink | 111 //WBPassthruSink |
| 111 //Monitor and/or cancel every request and responde | 112 //Monitor and/or cancel every request and responde |
| 112 //WB makes, including images, sounds, scripts, etc | 113 //WB makes, including images, sounds, scripts, etc |
| 113 //////////////////////////////////////////////////////////////////////////////// //////// | 114 //////////////////////////////////////////////////////////////////////////////// //////// |
| 114 HRESULT WBPassthruSink::OnStart(LPCWSTR szUrl, IInternetProtocolSink *pOIProtSin k, | 115 HRESULT WBPassthruSink::OnStart(LPCWSTR szUrl, IInternetProtocolSink *pOIProtSin k, |
| 115 IInternetBindInfo *pOIBindInfo, DWORD grfPI, HAN DLE_PTR dwReserved, | 116 IInternetBindInfo *pOIBindInfo, DWORD grfPI, HAN DLE_PTR dwReserved, |
| 116 IInternetProtocol* pTargetProtocol) | 117 IInternetProtocol* pTargetProtocol) |
| 117 { | 118 { |
| 118 | 119 |
| 119 m_pTargetProtocol = pTargetProtocol; | 120 m_pTargetProtocol = pTargetProtocol; |
| 120 bool isBlocked = false; | 121 bool isBlocked = false; |
| 121 m_shouldBlock = false; | 122 m_shouldBlock = false; |
| 122 m_lastDataReported = false; | 123 m_lastDataReported = false; |
| 123 CString src; | 124 std::wstring src(szUrl); |
| 124 src.Append(szUrl); | 125 DEBUG_GENERAL(ToCString(src)); |
| 125 DEBUG_GENERAL(src); | 126 UnescapeUrl(src); |
| 126 CPluginClient::UnescapeUrl(src); | |
| 127 | 127 |
| 128 std::wstring boundDomain; | 128 std::wstring boundDomain; |
| 129 CString mimeType; | 129 CString mimeType; |
| 130 LPOLESTR mime[10]; | 130 LPOLESTR mime[10]; |
| 131 if (pOIBindInfo) | 131 if (pOIBindInfo) |
| 132 { | 132 { |
| 133 ULONG resLen = 0; | 133 ULONG resLen = 0; |
| 134 | 134 |
| 135 // Apparently IE will report random mime type if there's more then 1 in the list. | 135 // Apparently IE will report random mime type if there's more then 1 in the list. |
| 136 // So we get the whole list and just use the first one (top priority one) | 136 // So we get the whole list and just use the first one (top priority one) |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 158 ULONG len2 = 2048; | 158 ULONG len2 = 2048; |
| 159 | 159 |
| 160 int contentType = CFilter::contentTypeAny; | 160 int contentType = CFilter::contentTypeAny; |
| 161 | 161 |
| 162 CPluginTab* tab = CPluginClass::GetTab(::GetCurrentThreadId()); | 162 CPluginTab* tab = CPluginClass::GetTab(::GetCurrentThreadId()); |
| 163 CPluginClient* client = CPluginClient::GetInstance(); | 163 CPluginClient* client = CPluginClient::GetInstance(); |
| 164 | 164 |
| 165 | 165 |
| 166 if (tab && client) | 166 if (tab && client) |
| 167 { | 167 { |
| 168 CString documentUrl = tab->GetDocumentUrl(); | 168 std::wstring documentUrl = tab->GetDocumentUrl(); |
| 169 // Page is identical to document => don't block | 169 // Page is identical to document => don't block |
| 170 if (documentUrl == src) | 170 if (documentUrl == src) |
| 171 { | 171 { |
| 172 // fall through | 172 // fall through |
| 173 } | 173 } |
| 174 else if (CPluginSettings::GetInstance()->IsPluginEnabled() && !client->IsWhi telistedUrl(to_wstring(documentUrl))) | 174 else if (CPluginSettings::GetInstance()->IsPluginEnabled() && !client->IsWhi telistedUrl(documentUrl)) |
| 175 { | 175 { |
| 176 boundDomain = to_wstring(tab->GetDocumentUrl()); | 176 boundDomain = tab->GetDocumentUrl(); |
| 177 contentType = CFilter::contentTypeAny; | 177 contentType = CFilter::contentTypeAny; |
| 178 if ((tab != 0) && (tab->IsFrameCached(src))) | 178 if ((tab != 0) && (tab->IsFrameCached(src))) |
| 179 { | 179 { |
| 180 contentType = CFilter::contentTypeSubdocument; | 180 contentType = CFilter::contentTypeSubdocument; |
| 181 } | 181 } |
| 182 else | 182 else |
| 183 { | 183 { |
| 184 contentType = GetContentType(mimeType, boundDomain, src); | 184 contentType = GetContentType(mimeType, boundDomain, src); |
| 185 } | 185 } |
| 186 if (client->ShouldBlock(to_wstring(src), contentType, boundDomain, true)) | 186 if (client->ShouldBlock(src, contentType, boundDomain, true)) |
| 187 { | 187 { |
| 188 isBlocked = true; | 188 isBlocked = true; |
| 189 DEBUG_BLOCKER("Blocker::Blocking Http-request:" + src); | 189 DEBUG_BLOCKER("Blocker::Blocking Http-request:" + ToCString(src)); |
| 190 } | 190 } |
| 191 } | 191 } |
| 192 if (!isBlocked) | 192 if (!isBlocked) |
| 193 { | 193 { |
| 194 DEBUG_BLOCKER("Blocker::Ignoring Http-request:" + src) | 194 DEBUG_BLOCKER("Blocker::Ignoring Http-request:" + ToCString(src)) |
| 195 } | 195 } |
| 196 } | 196 } |
| 197 | 197 |
| 198 | 198 |
| 199 if (tab == NULL) | 199 if (tab == NULL) |
| 200 { | 200 { |
| 201 contentType = GetContentType(mimeType, boundDomain, src); | 201 contentType = GetContentType(mimeType, boundDomain, src); |
| 202 if (client->ShouldBlock(to_wstring(src), contentType, boundDomain, true)) | 202 if (client->ShouldBlock(src, contentType, boundDomain, true)) |
| 203 { | 203 { |
| 204 isBlocked = true; | 204 isBlocked = true; |
| 205 } | 205 } |
| 206 } | 206 } |
| 207 | 207 |
| 208 #ifdef _DEBUG | 208 #ifdef _DEBUG |
| 209 CString type; | 209 CString type; |
| 210 | 210 |
| 211 if (contentType == CFilter::contentTypeDocument) type = "DOCUMENT"; | 211 if (contentType == CFilter::contentTypeDocument) type = "DOCUMENT"; |
| 212 else if (contentType == CFilter::contentTypeObject) type = "OBJECT"; | 212 else if (contentType == CFilter::contentTypeObject) type = "OBJECT"; |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 387 return OnStart(szUrl, pOIProtSink, pOIBindInfo, grfPI, | 387 return OnStart(szUrl, pOIProtSink, pOIBindInfo, grfPI, |
| 388 dwReserved, m_spInternetProtocol); | 388 dwReserved, m_spInternetProtocol); |
| 389 } | 389 } |
| 390 | 390 |
| 391 STDMETHODIMP WBPassthru::Read( /* [in, out] */ void *pv,/* [in] */ ULONG cb,/* [out] */ ULONG *pcbRead) | 391 STDMETHODIMP WBPassthru::Read( /* [in, out] */ void *pv,/* [in] */ ULONG cb,/* [out] */ ULONG *pcbRead) |
| 392 { | 392 { |
| 393 | 393 |
| 394 WBPassthruSink* pSink = GetSink(); | 394 WBPassthruSink* pSink = GetSink(); |
| 395 return pSink->Read(pv, cb, pcbRead); | 395 return pSink->Read(pv, cb, pcbRead); |
| 396 } | 396 } |
| OLD | NEW |