Left: | ||
Right: |
LEFT | RIGHT |
---|---|
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 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
135 } | 135 } |
136 } | 136 } |
137 | 137 |
138 WBPassthruSink::WBPassthruSink() | 138 WBPassthruSink::WBPassthruSink() |
139 : m_currentPositionOfSentPage(0) | 139 : m_currentPositionOfSentPage(0) |
140 , m_contentType(ContentType::CONTENT_TYPE_OTHER) | 140 , m_contentType(ContentType::CONTENT_TYPE_OTHER) |
141 , m_isCustomResponse(false) | 141 , m_isCustomResponse(false) |
142 { | 142 { |
143 } | 143 } |
144 | 144 |
145 ContentType WBPassthruSink::GetContentTypeFromMimeType(const std::wstring& mimeT ype) | 145 ContentType WBPassthruSink::GetContentTypeFromMimeType(const std::wstring& mimeT ype) |
Eric
2015/12/01 20:32:56
Here's the relevant section on the Accept header f
Oleksandr
2015/12/15 02:10:16
It is not known really if the order has any effect
Eric
2015/12/15 03:18:18
Given the data you've gathered, it seems that IE i
|
Eric
2015/12/15 03:18:18
While not strictly necessary, there are a few thin
sergei
2015/12/15 15:29:31
The same from my side.
|
146 { | 146 { |
147 if ((mimeType.find(L"text/html") != std::wstring::npos) || | |
148 (mimeType.find(L"application/xhtml+xml") != std::wstring::npos)) | |
149 { | |
150 return ContentType::CONTENT_TYPE_SUBDOCUMENT; | |
151 } | |
147 if (mimeType.find(L"image/") != std::wstring::npos) | 152 if (mimeType.find(L"image/") != std::wstring::npos) |
148 { | 153 { |
149 // Ambivalent mime type suggests both image and other types. | |
150 // Heuristically this is more likely a SUBDOCUMENT request. | |
151 if ((mimeType.find(L"text/") != std::wstring::npos) || | |
sergei
2015/12/01 10:53:59
In IE11 on my machine Accept header for "subdocume
Eric
2015/12/01 20:32:57
We don't have anything like a crawler for IE, but
Oleksandr
2015/12/15 02:10:16
I have only been able to log 2 types here:
text/ht
Eric
2015/12/15 03:18:18
These are the strings I'd like to see in a comment
| |
152 (mimeType.find(L"application/") != std::wstring::npos)) | |
153 { | |
154 return ContentType::CONTENT_TYPE_SUBDOCUMENT; | |
155 } | |
156 return ContentType::CONTENT_TYPE_IMAGE; | 154 return ContentType::CONTENT_TYPE_IMAGE; |
157 } | 155 } |
158 if (mimeType.find(L"text/css") != std::wstring::npos) | 156 if (mimeType.find(L"text/css") != std::wstring::npos) |
159 { | 157 { |
160 return ContentType::CONTENT_TYPE_STYLESHEET; | 158 return ContentType::CONTENT_TYPE_STYLESHEET; |
161 } | 159 } |
162 if ((mimeType.find(L"application/javascript") != std::wstring::npos) || (mimeT ype.find(L"application/json") != std::wstring::npos)) | 160 if ((mimeType.find(L"application/javascript") != std::wstring::npos) || (mimeT ype.find(L"application/json") != std::wstring::npos)) |
163 { | 161 { |
164 return ContentType::CONTENT_TYPE_SCRIPT; | 162 return ContentType::CONTENT_TYPE_SCRIPT; |
165 } | 163 } |
166 if (mimeType.find(L"application/x-shockwave-flash") != std::wstring::npos) | 164 if (mimeType.find(L"application/x-shockwave-flash") != std::wstring::npos) |
167 { | 165 { |
168 return ContentType::CONTENT_TYPE_OBJECT; | 166 return ContentType::CONTENT_TYPE_OBJECT; |
169 } | |
170 if (mimeType.find(L"text/html") != std::wstring::npos) | |
Eric
2015/12/01 20:32:56
Rather than testing for "text/html" when there's a
Oleksandr
2015/12/15 02:10:16
Seems like it does, based on my tests. Done.
| |
171 { | |
172 return ContentType::CONTENT_TYPE_SUBDOCUMENT; | |
173 } | 167 } |
174 // It is important to have this check last, since it is rather generic, and mi ght overlay text/html, for example | 168 // It is important to have this check last, since it is rather generic, and mi ght overlay text/html, for example |
175 if (mimeType.find(L"xml") != std::wstring::npos) | 169 if (mimeType.find(L"xml") != std::wstring::npos) |
176 { | 170 { |
177 return ContentType::CONTENT_TYPE_XMLHTTPREQUEST; | 171 return ContentType::CONTENT_TYPE_XMLHTTPREQUEST; |
178 } | 172 } |
179 | 173 |
180 return ContentType::CONTENT_TYPE_OTHER; | 174 return ContentType::CONTENT_TYPE_OTHER; |
181 } | 175 } |
182 | 176 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
219 return contentType; | 213 return contentType; |
220 } | 214 } |
221 | 215 |
222 //////////////////////////////////////////////////////////////////////////////// //////// | 216 //////////////////////////////////////////////////////////////////////////////// //////// |
223 //WBPassthruSink | 217 //WBPassthruSink |
224 //Monitor and/or cancel every request and responde | 218 //Monitor and/or cancel every request and responde |
225 //WB makes, including images, sounds, scripts, etc | 219 //WB makes, including images, sounds, scripts, etc |
226 //////////////////////////////////////////////////////////////////////////////// //////// | 220 //////////////////////////////////////////////////////////////////////////////// //////// |
227 HRESULT WBPassthruSink::OnStart(LPCWSTR szUrl, IInternetProtocolSink *pOIProtSin k, | 221 HRESULT WBPassthruSink::OnStart(LPCWSTR szUrl, IInternetProtocolSink *pOIProtSin k, |
228 IInternetBindInfo *pOIBindInfo, DWORD grfPI, HAN DLE_PTR dwReserved, | 222 IInternetBindInfo *pOIBindInfo, DWORD grfPI, HAN DLE_PTR dwReserved, |
229 IInternetProtocol* pTargetProtocol, bool& handle d) | 223 IInternetProtocol* pTargetProtocol) |
230 { | 224 { |
231 m_pTargetProtocol = pTargetProtocol; | 225 m_pTargetProtocol = pTargetProtocol; |
232 return BaseClass::OnStart(szUrl, pOIProtSink, pOIBindInfo, grfPI, dwReserved, pTargetProtocol); | 226 return BaseClass::OnStart(szUrl, pOIProtSink, pOIBindInfo, grfPI, dwReserved, pTargetProtocol); |
233 } | 227 } |
234 | 228 |
235 HRESULT WBPassthruSink::OnRead(void* pv, ULONG cb, ULONG* pcbRead) | 229 HRESULT WBPassthruSink::OnRead(void* pv, ULONG cb, ULONG* pcbRead) |
236 { | 230 { |
237 if (!pv || !pcbRead) | 231 if (!pv || !pcbRead) |
238 { | 232 { |
239 return E_POINTER; | 233 return E_POINTER; |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
440 } | 434 } |
441 | 435 |
442 return OnStart(szUrl, pOIProtSink, pOIBindInfo, grfPI, dwReserved, m_spInterne tProtocol); | 436 return OnStart(szUrl, pOIProtSink, pOIBindInfo, grfPI, dwReserved, m_spInterne tProtocol); |
443 } | 437 } |
444 | 438 |
445 STDMETHODIMP WBPassthru::Read(/* [in, out] */ void *pv,/* [in] */ ULONG cb,/* [o ut] */ ULONG *pcbRead) | 439 STDMETHODIMP WBPassthru::Read(/* [in, out] */ void *pv,/* [in] */ ULONG cb,/* [o ut] */ ULONG *pcbRead) |
446 { | 440 { |
447 WBPassthruSink* pSink = GetSink(); | 441 WBPassthruSink* pSink = GetSink(); |
448 return pSink->OnRead(pv, cb, pcbRead); | 442 return pSink->OnRead(pv, cb, pcbRead); |
449 } | 443 } |
LEFT | RIGHT |