| 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 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 174 return ContentType::CONTENT_TYPE_XMLHTTPREQUEST; | 174 return ContentType::CONTENT_TYPE_XMLHTTPREQUEST; |
| 175 } | 175 } |
| 176 | 176 |
| 177 return ContentType::CONTENT_TYPE_OTHER; | 177 return ContentType::CONTENT_TYPE_OTHER; |
| 178 } | 178 } |
| 179 | 179 |
| 180 ContentType WBPassthruSink::GetContentTypeFromURL(const std::wstring& src) | 180 ContentType WBPassthruSink::GetContentTypeFromURL(const std::wstring& src) |
| 181 { | 181 { |
| 182 std::wstring schemeAndHierarchicalPart = GetSchemeAndHierarchicalPart(src); | 182 std::wstring schemeAndHierarchicalPart = GetSchemeAndHierarchicalPart(src); |
| 183 auto contentType = GetContentTypeFromString(schemeAndHierarchicalPart); | 183 auto contentType = GetContentTypeFromString(schemeAndHierarchicalPart); |
| 184 if (AdblockPlus::IE::InstalledMajorVersion() == 8 && | 184 if (contentType == ContentType::CONTENT_TYPE_OTHER && |
| 185 contentType == ContentType::CONTENT_TYPE_OTHER) | 185 AdblockPlus::IE::InstalledMajorVersion() == 8) |
|
Eric
2015/02/12 17:24:41
I don't think it matters all that much, but it wou
sergei
2015/02/13 15:21:56
Changed.
| |
| 186 { | 186 { |
| 187 ForEachQueryStringParameter(GetQueryString(src), | 187 std::wstring queryString = GetQueryString(src); |
|
Oleksandr
2015/02/13 03:32:16
Why can't we just use strtok here? The code would
sergei
2015/02/13 15:21:56
strtok is unsafe and I would say the using of any
Eric
2015/02/13 16:33:43
For the reasons that strtok won't work here, see h
Oleksandr
2015/02/16 06:59:28
strotok_s would actually work good here. It has a
sergei
2015/02/16 10:54:33
I agree it looks good, not as I expected.
Eric
2015/02/16 18:18:07
There are two underlying observations here. The fi
sergei
2015/02/20 11:17:03
Good, but what does it give us? We use a lot of Wi
| |
| 188 [&contentType](const std::wstring& name, const std::wstring& value)->bool | 188 wchar_t* nextToken = nullptr; |
| 189 { | 189 const wchar_t* token = wcstok_s(&queryString[0], L"&=", &nextToken); |
| 190 if (!value.empty()) | 190 while (token != nullptr) |
| 191 { | 191 { |
| 192 contentType = GetContentTypeFromString(value); | 192 contentType = GetContentTypeFromString(token); |
| 193 if (contentType != ContentType::CONTENT_TYPE_OTHER) | |
| 194 { | |
| 195 return false; | |
| 196 } | |
| 197 } | |
| 198 contentType = GetContentTypeFromString(name); | |
| 199 if (contentType != ContentType::CONTENT_TYPE_OTHER) | 193 if (contentType != ContentType::CONTENT_TYPE_OTHER) |
| 200 { | 194 { |
| 201 return false; | 195 return contentType; |
| 202 } | 196 } |
| 203 return true; | 197 token = wcstok_s(nullptr, L"&=", &nextToken); |
| 204 }); | 198 } |
| 205 } | 199 } |
| 206 return contentType; | 200 return contentType; |
| 207 } | 201 } |
| 208 | 202 |
| 209 ContentType WBPassthruSink::GetContentType(const CString& mimeType, const std::w string& domain, const std::wstring& src) | 203 ContentType WBPassthruSink::GetContentType(const CString& mimeType, const std::w string& domain, const std::wstring& src) |
| 210 { | 204 { |
| 211 // No referer or mime type | 205 // No referer or mime type |
| 212 // BINDSTRING_XDR_ORIGIN works only for IE v8+ | 206 // BINDSTRING_XDR_ORIGIN works only for IE v8+ |
| 213 if (mimeType.IsEmpty() && domain.empty() && AdblockPlus::IE::InstalledMajorVer sion() >= 8) | 207 if (mimeType.IsEmpty() && domain.empty() && AdblockPlus::IE::InstalledMajorVer sion() >= 8) |
| 214 { | 208 { |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 446 } | 440 } |
| 447 | 441 |
| 448 return OnStart(szUrl, pOIProtSink, pOIBindInfo, grfPI, dwReserved, m_spInterne tProtocol); | 442 return OnStart(szUrl, pOIProtSink, pOIBindInfo, grfPI, dwReserved, m_spInterne tProtocol); |
| 449 } | 443 } |
| 450 | 444 |
| 451 STDMETHODIMP WBPassthru::Read(/* [in, out] */ void *pv,/* [in] */ ULONG cb,/* [o ut] */ ULONG *pcbRead) | 445 STDMETHODIMP WBPassthru::Read(/* [in, out] */ void *pv,/* [in] */ ULONG cb,/* [o ut] */ ULONG *pcbRead) |
| 452 { | 446 { |
| 453 WBPassthruSink* pSink = GetSink(); | 447 WBPassthruSink* pSink = GetSink(); |
| 454 return pSink->OnRead(pv, cb, pcbRead); | 448 return pSink->OnRead(pv, cb, pcbRead); |
| 455 } | 449 } |
| LEFT | RIGHT |