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 #ifdef SUPPORT_FILTER | 6 #ifdef SUPPORT_FILTER |
7 #include "PluginFilter.h" | 7 #include "PluginFilter.h" |
8 #endif | 8 #endif |
9 #include "PluginSettings.h" | 9 #include "PluginSettings.h" |
10 #include "PluginClass.h" | 10 #include "PluginClass.h" |
11 #include "PluginSystem.h" | 11 #include "PluginSystem.h" |
12 | 12 #include <WinInet.h> |
13 #include "wtypes.h" | 13 #include "wtypes.h" |
14 | 14 |
15 EXTERN_C IMAGE_DOS_HEADER __ImageBase; | |
16 | |
17 namespace | 15 namespace |
18 { | 16 { |
19 std::string g_myPageBlocked = "<!DOCTYPE html>" | 17 std::string g_myPageBlocked = "<!DOCTYPE html>" |
20 "<html>" | 18 "<html>" |
21 "<body>" | 19 "<body>" |
22 "<!-- blocked by AdblockPlus -->" | 20 "<!-- blocked by AdblockPlus -->" |
23 "</body>" | 21 "</body>" |
24 "</html>"; | 22 "</html>"; |
25 } | 23 } |
26 | 24 |
27 int WBPassthruSink::GetContentTypeFromMimeType(CString mimeType) | 25 WBPassthruSink::WBPassthruSink() |
| 26 : m_currentPositionOfSentPage(0) |
| 27 , m_contentType(CFilter::EContentType::contentTypeAny) |
| 28 { |
| 29 } |
| 30 |
| 31 int WBPassthruSink::GetContentTypeFromMimeType(const CString& mimeType) |
28 { | 32 { |
29 if (mimeType.Find(L"image/") >= 0) | 33 if (mimeType.Find(L"image/") >= 0) |
30 { | 34 { |
31 return CFilter::contentTypeImage; | 35 return CFilter::contentTypeImage; |
32 } | 36 } |
33 if (mimeType.Find(L"text/css") >= 0) | 37 if (mimeType.Find(L"text/css") >= 0) |
34 { | 38 { |
35 return CFilter::contentTypeStyleSheet; | 39 return CFilter::contentTypeStyleSheet; |
36 } | 40 } |
37 if ((mimeType.Find(L"application/javascript") >= 0) || (mimeType.Find(L"applic
ation/json") >= 0)) | 41 if ((mimeType.Find(L"application/javascript") >= 0) || (mimeType.Find(L"applic
ation/json") >= 0)) |
(...skipping 10 matching lines...) Expand all Loading... |
48 } | 52 } |
49 // It is important to have this check last, since it is rather generic, and mi
ght overlay text/html, for example | 53 // It is important to have this check last, since it is rather generic, and mi
ght overlay text/html, for example |
50 if (mimeType.Find(L"xml") >= 0) | 54 if (mimeType.Find(L"xml") >= 0) |
51 { | 55 { |
52 return CFilter::contentTypeXmlHttpRequest; | 56 return CFilter::contentTypeXmlHttpRequest; |
53 } | 57 } |
54 | 58 |
55 return CFilter::contentTypeAny; | 59 return CFilter::contentTypeAny; |
56 } | 60 } |
57 | 61 |
58 int WBPassthruSink::GetContentTypeFromURL(CString src) | 62 int WBPassthruSink::GetContentTypeFromURL(const CString& src) |
59 { | 63 { |
60 CString srcExt = src; | 64 CString srcExt = src; |
61 | 65 |
62 int pos = 0; | 66 int pos = 0; |
63 if ((pos = src.Find('?')) > 0) | 67 if ((pos = src.Find('?')) > 0) |
64 { | 68 { |
65 srcExt = src.Left(pos); | 69 srcExt = src.Left(pos); |
66 } | 70 } |
67 | 71 |
68 int lastDotIndex = srcExt.ReverseFind('.'); | 72 int lastDotIndex = srcExt.ReverseFind('.'); |
(...skipping 17 matching lines...) Expand all Loading... |
86 return CFilter::contentTypeXmlHttpRequest; | 90 return CFilter::contentTypeXmlHttpRequest; |
87 } | 91 } |
88 else if (ext == L".swf") | 92 else if (ext == L".swf") |
89 { | 93 { |
90 return CFilter::contentTypeObject; | 94 return CFilter::contentTypeObject; |
91 } | 95 } |
92 else if (ext == L".jsp" || ext == L".php" || ext == L".html") | 96 else if (ext == L".jsp" || ext == L".php" || ext == L".html") |
93 { | 97 { |
94 return CFilter::contentTypeSubdocument; | 98 return CFilter::contentTypeSubdocument; |
95 } | 99 } |
96 else | 100 return CFilter::contentTypeAny; |
97 { | |
98 return CFilter::contentTypeAny & ~CFilter::contentTypeSubdocument; | |
99 } | |
100 | |
101 } | 101 } |
102 | 102 |
103 int WBPassthruSink::GetContentType(CString mimeType, CString domain, CString src
) | 103 int WBPassthruSink::GetContentType(const CString& mimeType, const CString& domai
n, const CString& src) |
104 { | 104 { |
105 // No referer or mime type | 105 // No referer or mime type |
106 // BINDSTRING_XDR_ORIGIN works only for IE v8+ | 106 // BINDSTRING_XDR_ORIGIN works only for IE v8+ |
107 if (mimeType.IsEmpty() && domain.IsEmpty() && CPluginClient::GetInstance()->Ge
tIEVersion() >= 8) | 107 if (mimeType.IsEmpty() && domain.IsEmpty() && CPluginClient::GetInstance()->Ge
tIEVersion() >= 8) |
108 { | 108 { |
109 return CFilter::contentTypeXmlHttpRequest; | 109 return CFilter::contentTypeXmlHttpRequest; |
110 } | 110 } |
111 int contentType = GetContentTypeFromMimeType(mimeType); | 111 int contentType = GetContentTypeFromMimeType(mimeType); |
112 if (contentType == CFilter::contentTypeAny) | 112 if (contentType == CFilter::contentTypeAny) |
113 { | 113 { |
114 contentType = GetContentTypeFromURL(src); | 114 contentType = GetContentTypeFromURL(src); |
115 } | 115 } |
116 return contentType; | 116 return contentType; |
117 } | 117 } |
118 | 118 |
119 ////////////////////////////////////////////////////////////////////////////////
//////// | 119 ////////////////////////////////////////////////////////////////////////////////
//////// |
120 //WBPassthruSink | 120 //WBPassthruSink |
121 //Monitor and/or cancel every request and responde | 121 //Monitor and/or cancel every request and responde |
122 //WB makes, including images, sounds, scripts, etc | 122 //WB makes, including images, sounds, scripts, etc |
123 ////////////////////////////////////////////////////////////////////////////////
//////// | 123 ////////////////////////////////////////////////////////////////////////////////
//////// |
124 HRESULT WBPassthruSink::OnStart(LPCWSTR szUrl, IInternetProtocolSink *pOIProtSin
k, | 124 HRESULT WBPassthruSink::OnStart(LPCWSTR szUrl, IInternetProtocolSink *pOIProtSin
k, |
125 IInternetBindInfo *pOIBindInfo, DWORD grfPI, HAN
DLE_PTR dwReserved, | 125 IInternetBindInfo *pOIBindInfo, DWORD grfPI, HAN
DLE_PTR dwReserved, |
126 IInternetProtocol* pTargetProtocol, bool& handle
d) | 126 IInternetProtocol* pTargetProtocol, bool& handle
d) |
127 { | 127 { |
128 m_pTargetProtocol = pTargetProtocol; | 128 m_pTargetProtocol = pTargetProtocol; |
129 bool isBlocked = false; | 129 bool isBlocked = false; |
130 m_currentPositionOfSentPage = 0; | 130 CString src = szUrl; |
131 CString src; | |
132 src.Append(szUrl); | |
133 DEBUG_GENERAL(src); | 131 DEBUG_GENERAL(src); |
134 CPluginClient::UnescapeUrl(src); | 132 CPluginClient::UnescapeUrl(src); |
135 | 133 |
136 CString boundDomain; | |
137 CString mimeType; | 134 CString mimeType; |
138 LPOLESTR mime[10]; | |
139 if (pOIBindInfo) | 135 if (pOIBindInfo) |
140 { | 136 { |
141 ULONG resLen = 0; | 137 ULONG resLen = 0; |
142 | 138 |
143 // Apparently IE will report random mime type if there's more then 1 in the
list. | 139 // Apparently IE will report random mime type if there's more then 1 in the
list. |
144 // So we get the whole list and just use the first one (top priority one) | 140 // So we get the whole list and just use the first one (top priority one) |
| 141 LPOLESTR mime[10]; |
145 pOIBindInfo->GetBindString(BINDSTRING_ACCEPT_MIMES, mime, 10, &resLen); | 142 pOIBindInfo->GetBindString(BINDSTRING_ACCEPT_MIMES, mime, 10, &resLen); |
146 if (mime && resLen > 0) | 143 if (mime && resLen > 0) |
147 { | 144 { |
148 mimeType.SetString(mime[0]); | 145 mimeType.SetString(mime[0]); |
149 } | 146 } |
150 LPOLESTR bindToObject = 0; | 147 LPOLESTR bindToObject = nullptr; |
151 pOIBindInfo->GetBindString(BINDSTRING_FLAG_BIND_TO_OBJECT, &bindToObject, 1,
&resLen); | 148 pOIBindInfo->GetBindString(BINDSTRING_FLAG_BIND_TO_OBJECT, &bindToObject, 1,
&resLen); |
152 LPOLESTR domainRetrieved = 0; | 149 LPOLESTR domainRetrieved = nullptr; |
153 if (resLen == 0 || wcscmp(bindToObject, L"FALSE") == 0) | 150 if (resLen == 0 || wcscmp(bindToObject, L"FALSE") == 0) |
154 { | 151 { |
155 HRESULT hr = pOIBindInfo->GetBindString(BINDSTRING_XDR_ORIGIN, &domainRetr
ieved, 1, &resLen); | 152 HRESULT hr = pOIBindInfo->GetBindString(BINDSTRING_XDR_ORIGIN, &domainRetr
ieved, 1, &resLen); |
156 | |
157 if ((hr == S_OK) && domainRetrieved && (resLen > 0)) | 153 if ((hr == S_OK) && domainRetrieved && (resLen > 0)) |
158 { | 154 { |
159 boundDomain.SetString(domainRetrieved); | 155 m_boundDomain = domainRetrieved; |
160 } | 156 } |
161 } | 157 } |
162 } | 158 } |
163 | 159 |
164 CString cookie; | 160 CString cookie; |
165 ULONG len1 = 2048; | 161 ULONG len1 = 2048; |
166 ULONG len2 = 2048; | 162 ULONG len2 = 2048; |
167 | 163 |
168 #ifdef SUPPORT_FILTER | 164 #ifdef SUPPORT_FILTER |
169 int contentType = CFilter::contentTypeAny; | |
170 | |
171 CPluginTab* tab = CPluginClass::GetTab(::GetCurrentThreadId()); | 165 CPluginTab* tab = CPluginClass::GetTab(::GetCurrentThreadId()); |
172 CPluginClient* client = CPluginClient::GetInstance(); | 166 CPluginClient* client = CPluginClient::GetInstance(); |
173 | 167 |
174 | |
175 if (tab && client) | 168 if (tab && client) |
176 { | 169 { |
177 CString documentUrl = tab->GetDocumentUrl(); | 170 CString documentUrl = tab->GetDocumentUrl(); |
178 // Page is identical to document => don't block | 171 // Page is identical to document => don't block |
179 if (documentUrl == src) | 172 if (documentUrl == src) |
180 { | 173 { |
181 // fall through | 174 // fall through |
182 } | 175 } |
183 else if (CPluginSettings::GetInstance()->IsPluginEnabled() && !client->IsWhi
telistedUrl(std::wstring(documentUrl))) | 176 else if (CPluginSettings::GetInstance()->IsPluginEnabled() && !client->IsWhi
telistedUrl(std::wstring(documentUrl))) |
184 { | 177 { |
185 boundDomain = tab->GetDocumentUrl(); | 178 m_boundDomain = tab->GetDocumentUrl(); |
186 | 179 m_contentType = CFilter::contentTypeAny; |
187 contentType = CFilter::contentTypeAny; | |
188 | |
189 #ifdef SUPPORT_FRAME_CACHING | 180 #ifdef SUPPORT_FRAME_CACHING |
190 if ((tab != 0) && (tab->IsFrameCached(src))) | 181 if (nullptr != tab && tab->IsFrameCached(src)) |
191 { | 182 { |
192 contentType = CFilter::contentTypeSubdocument; | 183 m_contentType = CFilter::contentTypeSubdocument; |
193 } | 184 } |
194 else | 185 else |
195 #endif // SUPPORT_FRAME_CACHING | 186 #endif // SUPPORT_FRAME_CACHING |
196 contentType = GetContentType(mimeType, boundDomain, src); | |
197 if (client->ShouldBlock(src, contentType, boundDomain, true)) | |
198 { | 187 { |
199 isBlocked = true; | 188 m_contentType = GetContentType(mimeType, m_boundDomain, src); |
200 | |
201 DEBUG_BLOCKER("Blocker::Blocking Http-request:" + src); | |
202 } | 189 } |
203 } | 190 } |
204 if (!isBlocked) | 191 |
205 { | |
206 DEBUG_BLOCKER("Blocker::Ignoring Http-request:" + src) | |
207 } | |
208 } | 192 } |
209 | 193 |
210 | 194 if (nullptr == tab) |
211 if (tab == NULL) | |
212 { | 195 { |
213 contentType = GetContentType(mimeType, boundDomain, src); | 196 m_contentType = GetContentType(mimeType, m_boundDomain, src); |
214 if (client->ShouldBlock(src, contentType, boundDomain, true)) | |
215 { | |
216 isBlocked = true; | |
217 } | |
218 } | 197 } |
219 | 198 |
220 #ifdef _DEBUG | 199 if (nullptr != client |
221 CString type; | 200 && CFilter::EContentType::contentTypeAny != m_contentType |
| 201 && client->ShouldBlock(src, m_contentType, m_boundDomain, true)) |
| 202 { |
| 203 isBlocked = true; |
| 204 DEBUG_BLOCKER("Blocker::Blocking Http-request:" + src); |
| 205 } |
| 206 if (!isBlocked) |
| 207 { |
| 208 DEBUG_BLOCKER("Blocker::Ignoring Http-request:" + src) |
| 209 } |
222 | 210 |
223 if (contentType == CFilter::contentTypeDocument) type = "DOCUMENT"; | 211 // For IE6 and earlier there is iframe back button issue, so avoid it. |
224 else if (contentType == CFilter::contentTypeObject) type = "OBJECT"; | 212 if (isBlocked && client->GetIEVersion() > 6) |
225 else if (contentType == CFilter::contentTypeImage) type = "IMAGE"; | |
226 else if (contentType == CFilter::contentTypeScript) type = "SCRIPT"; | |
227 else if (contentType == CFilter::contentTypeOther) type = "OTHER"; | |
228 else if (contentType == CFilter::contentTypeUnknown) type = "OTHER"; | |
229 else if (contentType == CFilter::contentTypeSubdocument) type = "SUBDOCUMENT"; | |
230 else if (contentType == CFilter::contentTypeStyleSheet) type = "STYLESHEET"; | |
231 else type = "OTHER"; | |
232 | |
233 if (isBlocked) | |
234 { | 213 { |
235 CPluginDebug::DebugResultBlocking(type, src, boundDomain); | 214 handled = true; |
236 } | 215 if (CFilter::EContentType::contentTypeImage == m_contentType) |
237 else | |
238 { | |
239 CPluginDebug::DebugResultIgnoring(type, src, boundDomain); | |
240 } | |
241 #endif | |
242 | |
243 //Fixes the iframe back button issue | |
244 if (client->GetIEVersion() > 6) | |
245 { | |
246 if (contentType == CFilter::contentTypeImage && isBlocked) | |
247 { | 216 { |
248 BaseClass::OnStart(szUrl, pOIProtSink, pOIBindInfo, grfPI, dwReserved, pTa
rgetProtocol); | 217 BaseClass::OnStart(szUrl, pOIProtSink, pOIBindInfo, grfPI, dwReserved, pTa
rgetProtocol); |
249 handled = true; | |
250 // IE shows a cross that img is not loaded | 218 // IE shows a cross that img is not loaded |
251 return INET_E_REDIRECT_FAILED; | 219 return INET_E_REDIRECT_FAILED; |
252 } | 220 } |
253 if (contentType == CFilter::contentTypeSubdocument && isBlocked) | 221 if (CFilter::EContentType::contentTypeSubdocument == m_contentType) |
254 { | 222 { |
255 PassthroughAPP::CustomSinkStartPolicy<WBPassthru, WBPassthruSink>::GetProt
ocol(this)->m_shouldSupplyCustomContent = true; | 223 PassthroughAPP::CustomSinkStartPolicy<WBPassthru, WBPassthruSink>::GetProt
ocol(this)->m_shouldSupplyCustomContent = true; |
256 BaseClass::OnStart(szUrl, pOIProtSink, pOIBindInfo, grfPI, dwReserved, pTa
rgetProtocol); | 224 BaseClass::OnStart(szUrl, pOIProtSink, pOIBindInfo, grfPI, dwReserved, pTa
rgetProtocol); |
257 | |
258 m_spInternetProtocolSink->ReportProgress(BINDSTATUS_MIMETYPEAVAILABLE, L"t
ext/html"); | 225 m_spInternetProtocolSink->ReportProgress(BINDSTATUS_MIMETYPEAVAILABLE, L"t
ext/html"); |
259 m_spInternetProtocolSink->ReportData(BSCF_FIRSTDATANOTIFICATION, 0, static
_cast<ULONG>(g_myPageBlocked.size())); | 226 m_spInternetProtocolSink->ReportData(BSCF_FIRSTDATANOTIFICATION, 0, static
_cast<ULONG>(g_myPageBlocked.size())); |
260 handled = true; | |
261 return S_OK; | 227 return S_OK; |
262 } | 228 } |
263 if (contentType == CFilter::contentTypeScript && isBlocked) | 229 if (CFilter::EContentType::contentTypeScript == m_contentType) |
264 { | 230 { |
265 BaseClass::OnStart(szUrl, pOIProtSink, pOIBindInfo, grfPI, dwReserved, pTa
rgetProtocol); | 231 BaseClass::OnStart(szUrl, pOIProtSink, pOIBindInfo, grfPI, dwReserved, pTa
rgetProtocol); |
266 m_spInternetProtocolSink->ReportProgress(BINDSTATUS_MIMETYPEAVAILABLE, L"t
ext/javascript"); | 232 m_spInternetProtocolSink->ReportProgress(BINDSTATUS_MIMETYPEAVAILABLE, L"t
ext/javascript"); |
267 m_spInternetProtocolSink->ReportResult(INET_E_REDIRECTING, 301, L"data:"); | 233 m_spInternetProtocolSink->ReportResult(INET_E_REDIRECTING, 301, L"data:"); |
268 handled = true; | |
269 return INET_E_REDIRECT_FAILED; | 234 return INET_E_REDIRECT_FAILED; |
270 } | 235 } |
271 if (contentType == CFilter::contentTypeXmlHttpRequest && isBlocked) | 236 if (CFilter::EContentType::contentTypeXmlHttpRequest == m_contentType) |
272 { | 237 { |
273 BaseClass::OnStart(szUrl, pOIProtSink, pOIBindInfo, grfPI, dwReserved, pTa
rgetProtocol); | 238 BaseClass::OnStart(szUrl, pOIProtSink, pOIBindInfo, grfPI, dwReserved, pTa
rgetProtocol); |
274 m_spInternetProtocolSink->ReportResult(INET_E_REDIRECTING, 301, L"data:"); | 239 m_spInternetProtocolSink->ReportResult(INET_E_REDIRECTING, 301, L"data:"); |
275 handled = true; | |
276 return INET_E_REDIRECT_FAILED; | |
277 } | |
278 if (isBlocked) | |
279 { | |
280 BaseClass::OnStart(szUrl, pOIProtSink, pOIBindInfo, grfPI, dwReserved, pTa
rgetProtocol); | |
281 m_spInternetProtocolSink->ReportResult(S_FALSE, 0, L""); | |
282 handled = true; | |
283 return INET_E_REDIRECT_FAILED; | 240 return INET_E_REDIRECT_FAILED; |
284 } | 241 } |
285 } | 242 } |
286 #endif // SUPPORT_FILTER | 243 #endif // SUPPORT_FILTER |
287 | 244 |
288 return isBlocked ? S_FALSE : BaseClass::OnStart(szUrl, pOIProtSink, pOIBindInf
o, grfPI, dwReserved, pTargetProtocol); | 245 return isBlocked ? S_FALSE : BaseClass::OnStart(szUrl, pOIProtSink, pOIBindInf
o, grfPI, dwReserved, pTargetProtocol); |
289 } | 246 } |
290 | 247 |
291 | |
292 HRESULT WBPassthruSink::OnRead(void* pv, ULONG cb, ULONG* pcbRead) | 248 HRESULT WBPassthruSink::OnRead(void* pv, ULONG cb, ULONG* pcbRead) |
293 { | 249 { |
294 if (nullptr == pv) | 250 if (nullptr == pv) |
295 { | 251 { |
296 return E_POINTER; | 252 return E_POINTER; |
297 } | 253 } |
298 if (nullptr == pcbRead) | 254 if (nullptr == pcbRead) |
299 { | 255 { |
300 return E_POINTER; | 256 return E_POINTER; |
301 } | 257 } |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
347 PROTOCOLDATA::grfFlags, eventually URLMon will turn around and call | 303 PROTOCOLDATA::grfFlags, eventually URLMon will turn around and call |
348 IInternetProtocol::Continue on the main thread. | 304 IInternetProtocol::Continue on the main thread. |
349 | 305 |
350 Or, if you happen to have a window handy that was created on the main | 306 Or, if you happen to have a window handy that was created on the main |
351 thread, you can post yourself a message. | 307 thread, you can post yourself a message. |
352 " | 308 " |
353 */ | 309 */ |
354 return m_spInternetProtocolSink ? m_spInternetProtocolSink->Switch(pProtocolDa
ta) : E_UNEXPECTED; | 310 return m_spInternetProtocolSink ? m_spInternetProtocolSink->Switch(pProtocolDa
ta) : E_UNEXPECTED; |
355 } | 311 } |
356 | 312 |
357 STDMETHODIMP WBPassthruSink::BeginningTransaction(LPCWSTR szURL, LPCWSTR szHeade
rs, DWORD dwReserved, LPWSTR *pszAdditionalHeaders) | 313 STDMETHODIMP WBPassthruSink::BeginningTransaction(LPCWSTR szURL, LPCWSTR szHeade
rs, DWORD dwReserved, LPWSTR* pszAdditionalHeaders) |
358 { | 314 { |
359 if (pszAdditionalHeaders) | 315 if (pszAdditionalHeaders) |
360 { | 316 { |
361 *pszAdditionalHeaders = 0; | 317 *pszAdditionalHeaders = nullptr; |
362 } | 318 } |
363 | 319 |
| 320 CPluginClient* client = nullptr; |
| 321 if (CFilter::EContentType::contentTypeAny == m_contentType && (client = CPlugi
nClient::GetInstance())) |
| 322 { |
| 323 auto acceptHeader = [&]() -> std::string |
| 324 { |
| 325 ATL::CComPtr<IWinInetHttpInfo> winInetHttpInfo; |
| 326 HRESULT hr = m_spTargetProtocol->QueryInterface(&winInetHttpInfo); |
| 327 if(FAILED(hr)) |
| 328 { |
| 329 return ""; |
| 330 } |
| 331 DWORD size = 0; |
| 332 DWORD flags = 0; |
| 333 hr = winInetHttpInfo->QueryInfo(HTTP_QUERY_RAW_HEADERS_CRLF | HTTP_QUERY_F
LAG_REQUEST_HEADERS, |
| 334 /*buffer*/nullptr, /* get size */&size, &flags, /*reserved*/ 0); |
| 335 if(FAILED(hr)) |
| 336 { |
| 337 return ""; |
| 338 } |
| 339 std::string buf(size, '\0'); |
| 340 hr = winInetHttpInfo->QueryInfo(HTTP_QUERY_RAW_HEADERS_CRLF | HTTP_QUERY_F
LAG_REQUEST_HEADERS, |
| 341 &buf[0], &size, &flags, 0); |
| 342 if(FAILED(hr)) |
| 343 { |
| 344 return ""; |
| 345 } |
| 346 char acceptHeader[] = "Accept:"; |
| 347 auto acceptHeaderBeginsAt = buf.find(acceptHeader); |
| 348 if (std::string::npos == acceptHeaderBeginsAt) |
| 349 { |
| 350 return ""; |
| 351 } |
| 352 acceptHeaderBeginsAt += sizeof(acceptHeader); |
| 353 auto acceptHeaderEndsAt = buf.find("\n", acceptHeaderBeginsAt); |
| 354 if (std::string::npos == acceptHeaderEndsAt) |
| 355 { |
| 356 return ""; |
| 357 } |
| 358 return buf.substr(acceptHeaderBeginsAt, acceptHeaderEndsAt - acceptHeaderB
eginsAt); |
| 359 }(); |
| 360 m_contentType = GetContentTypeFromMimeType(ATL::CString(acceptHeader.c_str()
)); |
| 361 bool isBlocked = client->ShouldBlock(szURL, m_contentType, |
| 362 //client->GetHostFromUrl(m_boundDomain.operator LPCWSTR()).c_str(), /*debu
g flag but must be set*/true); |
| 363 m_boundDomain, /*debug flag but must be set*/true); |
| 364 if (isBlocked) |
| 365 { |
| 366 return E_ABORT; |
| 367 } |
| 368 } |
364 CComPtr<IHttpNegotiate> spHttpNegotiate; | 369 CComPtr<IHttpNegotiate> spHttpNegotiate; |
365 QueryServiceFromClient(&spHttpNegotiate); | 370 QueryServiceFromClient(&spHttpNegotiate); |
366 return spHttpNegotiate ? spHttpNegotiate->BeginningTransaction(szURL, szHeader
s,dwReserved, pszAdditionalHeaders) : S_OK; | 371 return spHttpNegotiate ? spHttpNegotiate->BeginningTransaction(szURL, szHeader
s,dwReserved, pszAdditionalHeaders) : S_OK; |
367 } | 372 } |
368 | 373 |
369 STDMETHODIMP WBPassthruSink::OnResponse(DWORD dwResponseCode, LPCWSTR szResponse
Headers, LPCWSTR szRequestHeaders, LPWSTR *pszAdditionalRequestHeaders) | 374 STDMETHODIMP WBPassthruSink::OnResponse(DWORD dwResponseCode, LPCWSTR szResponse
Headers, LPCWSTR szRequestHeaders, LPWSTR *pszAdditionalRequestHeaders) |
370 { | 375 { |
371 if (pszAdditionalRequestHeaders) | 376 if (pszAdditionalRequestHeaders) |
372 { | 377 { |
373 *pszAdditionalRequestHeaders = 0; | 378 *pszAdditionalRequestHeaders = 0; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
417 } | 422 } |
418 | 423 |
419 STDMETHODIMP WBPassthru::UnlockRequest() | 424 STDMETHODIMP WBPassthru::UnlockRequest() |
420 { | 425 { |
421 if (m_shouldSupplyCustomContent) | 426 if (m_shouldSupplyCustomContent) |
422 { | 427 { |
423 return S_OK; | 428 return S_OK; |
424 } | 429 } |
425 return PassthroughAPP::CInternetProtocol<WBStartPolicy>::UnlockRequest(); | 430 return PassthroughAPP::CInternetProtocol<WBStartPolicy>::UnlockRequest(); |
426 } | 431 } |
OLD | NEW |