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 #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) |
Oleksandr
2014/10/01 09:15:39
I personally don't like yoda conditions, and I thi
| |
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)) | |
Oleksandr
2014/10/01 09:15:39
Comment about yoda conditions applies here as well
| |
202 { | |
203 isBlocked = true; | |
204 } | |
222 | 205 |
223 if (contentType == CFilter::contentTypeDocument) type = "DOCUMENT"; | 206 // For IE6 and earlier there is iframe back button issue, so avoid it. |
224 else if (contentType == CFilter::contentTypeObject) type = "OBJECT"; | 207 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 { | 208 { |
235 CPluginDebug::DebugResultBlocking(type, src, boundDomain); | 209 handled = true; |
236 } | 210 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 { | 211 { |
248 BaseClass::OnStart(szUrl, pOIProtSink, pOIBindInfo, grfPI, dwReserved, pTa rgetProtocol); | 212 BaseClass::OnStart(szUrl, pOIProtSink, pOIBindInfo, grfPI, dwReserved, pTa rgetProtocol); |
249 handled = true; | |
250 // IE shows a cross that img is not loaded | 213 // IE shows a cross that img is not loaded |
251 return INET_E_REDIRECT_FAILED; | 214 return INET_E_REDIRECT_FAILED; |
252 } | 215 } |
253 if (contentType == CFilter::contentTypeSubdocument && isBlocked) | 216 if (CFilter::EContentType::contentTypeSubdocument == m_contentType) |
254 { | 217 { |
255 PassthroughAPP::CustomSinkStartPolicy<WBPassthru, WBPassthruSink>::GetProt ocol(this)->m_shouldSupplyCustomContent = true; | 218 PassthroughAPP::CustomSinkStartPolicy<WBPassthru, WBPassthruSink>::GetProt ocol(this)->m_shouldSupplyCustomContent = true; |
256 BaseClass::OnStart(szUrl, pOIProtSink, pOIBindInfo, grfPI, dwReserved, pTa rgetProtocol); | 219 BaseClass::OnStart(szUrl, pOIProtSink, pOIBindInfo, grfPI, dwReserved, pTa rgetProtocol); |
257 | |
258 m_spInternetProtocolSink->ReportProgress(BINDSTATUS_MIMETYPEAVAILABLE, L"t ext/html"); | 220 m_spInternetProtocolSink->ReportProgress(BINDSTATUS_MIMETYPEAVAILABLE, L"t ext/html"); |
259 m_spInternetProtocolSink->ReportData(BSCF_FIRSTDATANOTIFICATION, 0, static _cast<ULONG>(g_myPageBlocked.size())); | 221 m_spInternetProtocolSink->ReportData(BSCF_FIRSTDATANOTIFICATION, 0, static _cast<ULONG>(g_myPageBlocked.size())); |
260 handled = true; | |
261 return S_OK; | 222 return S_OK; |
262 } | 223 } |
263 if (contentType == CFilter::contentTypeScript && isBlocked) | 224 if (CFilter::EContentType::contentTypeScript == m_contentType) |
264 { | 225 { |
265 BaseClass::OnStart(szUrl, pOIProtSink, pOIBindInfo, grfPI, dwReserved, pTa rgetProtocol); | 226 BaseClass::OnStart(szUrl, pOIProtSink, pOIBindInfo, grfPI, dwReserved, pTa rgetProtocol); |
266 m_spInternetProtocolSink->ReportProgress(BINDSTATUS_MIMETYPEAVAILABLE, L"t ext/javascript"); | 227 m_spInternetProtocolSink->ReportProgress(BINDSTATUS_MIMETYPEAVAILABLE, L"t ext/javascript"); |
267 m_spInternetProtocolSink->ReportResult(INET_E_REDIRECTING, 301, L"data:"); | 228 m_spInternetProtocolSink->ReportResult(INET_E_REDIRECTING, 301, L"data:"); |
268 handled = true; | |
269 return INET_E_REDIRECT_FAILED; | 229 return INET_E_REDIRECT_FAILED; |
270 } | 230 } |
271 if (contentType == CFilter::contentTypeXmlHttpRequest && isBlocked) | 231 if (CFilter::EContentType::contentTypeXmlHttpRequest == m_contentType) |
Oleksandr
2014/10/01 09:15:39
Looks like we don't need a special case for conten
| |
272 { | 232 { |
273 BaseClass::OnStart(szUrl, pOIProtSink, pOIBindInfo, grfPI, dwReserved, pTa rgetProtocol); | 233 BaseClass::OnStart(szUrl, pOIProtSink, pOIBindInfo, grfPI, dwReserved, pTa rgetProtocol); |
274 m_spInternetProtocolSink->ReportResult(INET_E_REDIRECTING, 301, L"data:"); | 234 m_spInternetProtocolSink->ReportResult(INET_E_REDIRECTING, 301, L"data:"); |
275 handled = true; | |
276 return INET_E_REDIRECT_FAILED; | 235 return INET_E_REDIRECT_FAILED; |
277 } | 236 } |
278 if (isBlocked) | 237 if (CFilter::EContentType::contentTypeAny != m_contentType) |
279 { | 238 { |
280 BaseClass::OnStart(szUrl, pOIProtSink, pOIBindInfo, grfPI, dwReserved, pTa rgetProtocol); | 239 BaseClass::OnStart(szUrl, pOIProtSink, pOIBindInfo, grfPI, dwReserved, pTa rgetProtocol); |
281 m_spInternetProtocolSink->ReportResult(S_FALSE, 0, L""); | 240 m_spInternetProtocolSink->ReportResult(INET_E_REDIRECTING, 301, L"data:"); |
Oleksandr
2014/10/01 09:15:39
I don't think redirecting all requests to 'data:'
| |
282 handled = true; | |
283 return INET_E_REDIRECT_FAILED; | 241 return INET_E_REDIRECT_FAILED; |
284 } | 242 } |
285 } | 243 } |
286 #endif // SUPPORT_FILTER | 244 #endif // SUPPORT_FILTER |
287 | 245 |
288 return isBlocked ? S_FALSE : BaseClass::OnStart(szUrl, pOIProtSink, pOIBindInf o, grfPI, dwReserved, pTargetProtocol); | 246 return isBlocked ? S_FALSE : BaseClass::OnStart(szUrl, pOIProtSink, pOIBindInf o, grfPI, dwReserved, pTargetProtocol); |
289 } | 247 } |
290 | 248 |
291 | |
292 HRESULT WBPassthruSink::OnRead(void* pv, ULONG cb, ULONG* pcbRead) | 249 HRESULT WBPassthruSink::OnRead(void* pv, ULONG cb, ULONG* pcbRead) |
293 { | 250 { |
294 if (nullptr == pv) | 251 if (nullptr == pv) |
295 { | 252 { |
296 return E_POINTER; | 253 return E_POINTER; |
297 } | 254 } |
298 if (nullptr == pcbRead) | 255 if (nullptr == pcbRead) |
299 { | 256 { |
300 return E_POINTER; | 257 return E_POINTER; |
301 } | 258 } |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
347 PROTOCOLDATA::grfFlags, eventually URLMon will turn around and call | 304 PROTOCOLDATA::grfFlags, eventually URLMon will turn around and call |
348 IInternetProtocol::Continue on the main thread. | 305 IInternetProtocol::Continue on the main thread. |
349 | 306 |
350 Or, if you happen to have a window handy that was created on the main | 307 Or, if you happen to have a window handy that was created on the main |
351 thread, you can post yourself a message. | 308 thread, you can post yourself a message. |
352 " | 309 " |
353 */ | 310 */ |
354 return m_spInternetProtocolSink ? m_spInternetProtocolSink->Switch(pProtocolDa ta) : E_UNEXPECTED; | 311 return m_spInternetProtocolSink ? m_spInternetProtocolSink->Switch(pProtocolDa ta) : E_UNEXPECTED; |
355 } | 312 } |
356 | 313 |
357 STDMETHODIMP WBPassthruSink::BeginningTransaction(LPCWSTR szURL, LPCWSTR szHeade rs, DWORD dwReserved, LPWSTR *pszAdditionalHeaders) | 314 STDMETHODIMP WBPassthruSink::BeginningTransaction(LPCWSTR szURL, LPCWSTR szHeade rs, DWORD dwReserved, LPWSTR* pszAdditionalHeaders) |
358 { | 315 { |
359 if (pszAdditionalHeaders) | 316 if (pszAdditionalHeaders) |
360 { | 317 { |
361 *pszAdditionalHeaders = 0; | 318 *pszAdditionalHeaders = nullptr; |
362 } | 319 } |
363 | 320 |
321 CPluginClient* client = nullptr; | |
322 if (CFilter::EContentType::contentTypeAny == m_contentType && (client = CPlugi nClient::GetInstance())) | |
323 { | |
324 auto acceptHeader = [&]() -> std::string | |
325 { | |
326 ATL::CComPtr<IWinInetHttpInfo> winInetHttpInfo; | |
327 HRESULT hr = m_spTargetProtocol->QueryInterface(&winInetHttpInfo); | |
328 if(FAILED(hr)) | |
329 { | |
330 return ""; | |
331 } | |
332 DWORD size = 0; | |
333 DWORD flags = 0; | |
334 hr = winInetHttpInfo->QueryInfo(HTTP_QUERY_RAW_HEADERS_CRLF | HTTP_QUERY_F LAG_REQUEST_HEADERS, | |
335 /*buffer*/nullptr, /* get size */&size, &flags, /*reserved*/ 0); | |
336 if(FAILED(hr)) | |
337 { | |
338 return ""; | |
339 } | |
340 std::string buf(size, '\0'); | |
341 hr = winInetHttpInfo->QueryInfo(HTTP_QUERY_RAW_HEADERS_CRLF | HTTP_QUERY_F LAG_REQUEST_HEADERS, | |
342 &buf[0], &size, &flags, 0); | |
343 if(FAILED(hr)) | |
344 { | |
345 return ""; | |
346 } | |
347 char acceptHeader[] = "Accept:"; | |
348 auto acceptHeaderBeginsAt = buf.find(acceptHeader); | |
349 if (std::string::npos == acceptHeaderBeginsAt) | |
350 { | |
351 return ""; | |
352 } | |
353 acceptHeaderBeginsAt += sizeof(acceptHeader); | |
354 auto acceptHeaderEndsAt = buf.find("\n", acceptHeaderBeginsAt); | |
355 if (std::string::npos == acceptHeaderEndsAt) | |
356 { | |
357 return ""; | |
358 } | |
359 return buf.substr(acceptHeaderBeginsAt, acceptHeaderEndsAt - acceptHeaderB eginsAt); | |
360 }(); | |
361 m_contentType = GetContentTypeFromMimeType(ATL::CString(acceptHeader.c_str() )); | |
362 bool isBlocked = client->ShouldBlock(szURL, m_contentType, m_boundDomain, /* debug flag but must be set*/true); | |
363 if (isBlocked) | |
364 { | |
365 return E_ABORT; | |
366 } | |
367 } | |
364 CComPtr<IHttpNegotiate> spHttpNegotiate; | 368 CComPtr<IHttpNegotiate> spHttpNegotiate; |
365 QueryServiceFromClient(&spHttpNegotiate); | 369 QueryServiceFromClient(&spHttpNegotiate); |
366 return spHttpNegotiate ? spHttpNegotiate->BeginningTransaction(szURL, szHeader s,dwReserved, pszAdditionalHeaders) : S_OK; | 370 return spHttpNegotiate ? spHttpNegotiate->BeginningTransaction(szURL, szHeader s,dwReserved, pszAdditionalHeaders) : S_OK; |
367 } | 371 } |
368 | 372 |
369 STDMETHODIMP WBPassthruSink::OnResponse(DWORD dwResponseCode, LPCWSTR szResponse Headers, LPCWSTR szRequestHeaders, LPWSTR *pszAdditionalRequestHeaders) | 373 STDMETHODIMP WBPassthruSink::OnResponse(DWORD dwResponseCode, LPCWSTR szResponse Headers, LPCWSTR szRequestHeaders, LPWSTR *pszAdditionalRequestHeaders) |
370 { | 374 { |
371 if (pszAdditionalRequestHeaders) | 375 if (pszAdditionalRequestHeaders) |
372 { | 376 { |
373 *pszAdditionalRequestHeaders = 0; | 377 *pszAdditionalRequestHeaders = 0; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
417 } | 421 } |
418 | 422 |
419 STDMETHODIMP WBPassthru::UnlockRequest() | 423 STDMETHODIMP WBPassthru::UnlockRequest() |
420 { | 424 { |
421 if (m_shouldSupplyCustomContent) | 425 if (m_shouldSupplyCustomContent) |
422 { | 426 { |
423 return S_OK; | 427 return S_OK; |
424 } | 428 } |
425 return PassthroughAPP::CInternetProtocol<WBStartPolicy>::UnlockRequest(); | 429 return PassthroughAPP::CInternetProtocol<WBStartPolicy>::UnlockRequest(); |
426 } | 430 } |
OLD | NEW |