OLD | NEW |
1 #include "PluginStdAfx.h" | 1 #include "PluginStdAfx.h" |
2 | 2 |
3 #include "PluginFilter.h" | 3 #include "PluginFilter.h" |
4 | 4 |
5 #if (defined PRODUCT_ADBLOCKPLUS) | 5 #if (defined PRODUCT_ADBLOCKPLUS) |
6 #include "PluginSettings.h" | 6 #include "PluginSettings.h" |
7 #include "PluginClient.h" | 7 #include "PluginClient.h" |
8 #include "PluginClientFactory.h" | 8 #include "PluginClientFactory.h" |
9 #endif | 9 #endif |
10 | 10 |
(...skipping 601 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
612 CPluginDebug::DebugResultHiding(tag, "-", tagIt->second.m_filterText); | 612 CPluginDebug::DebugResultHiding(tag, "-", tagIt->second.m_filterText); |
613 #endif | 613 #endif |
614 return true; | 614 return true; |
615 } | 615 } |
616 } | 616 } |
617 } | 617 } |
618 | 618 |
619 return false; | 619 return false; |
620 } | 620 } |
621 | 621 |
622 bool CPluginFilter::LoadHideFilters(std::vector<std::string> filters) | 622 bool CPluginFilter::LoadHideFilters(std::vector<std::wstring> filters) |
623 { | 623 { |
624 | 624 |
625 ClearFilters(); | 625 ClearFilters(); |
626 | 626 |
627 bool isRead = false; | 627 bool isRead = false; |
628 | 628 |
629 #ifdef PRODUCT_ADBLOCKPLUS | 629 #ifdef PRODUCT_ADBLOCKPLUS |
630 CPluginClient* client = CPluginClient::GetInstance(); | 630 CPluginClient* client = CPluginClient::GetInstance(); |
631 #endif | 631 #endif |
632 | 632 |
633 // Parse hide string | 633 // Parse hide string |
634 int pos = 0; | 634 int pos = 0; |
635 | 635 |
636 CriticalSection::Lock filterEngineLock(s_criticalSectionFilterMap); | 636 CriticalSection::Lock filterEngineLock(s_criticalSectionFilterMap); |
637 { | 637 { |
638 for (std::vector<std::string>::iterator it = filters.begin(); it < filters.e
nd(); ++it) | 638 for (std::vector<std::wstring>::iterator it = filters.begin(); it < filters.
end(); ++it) |
639 { | 639 { |
640 CString filter((*it).c_str()); | 640 CString filter((*it).c_str()); |
641 // If the line is not commented out | 641 // If the line is not commented out |
642 if (!filter.Trim().IsEmpty() && filter.GetAt(0) != '!' && filter.GetAt(0)
!= '[') | 642 if (!filter.Trim().IsEmpty() && filter.GetAt(0) != '!' && filter.GetAt(0)
!= '[') |
643 { | 643 { |
644 int filterType = 0; | 644 int filterType = 0; |
645 | 645 |
646 // See http://adblockplus.org/en/filters for further documentation | 646 // See http://adblockplus.org/en/filters for further documentation |
647 | 647 |
648 try | 648 try |
649 { | 649 { |
650 AddFilterElementHide(filter); | 650 AddFilterElementHide(filter); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
699 type = "OTHER"; | 699 type = "OTHER"; |
700 | 700 |
701 std::map<int,CString>::const_iterator it = m_contentMapText.find(contentType
); | 701 std::map<int,CString>::const_iterator it = m_contentMapText.find(contentType
); |
702 if (it != m_contentMapText.end()) | 702 if (it != m_contentMapText.end()) |
703 { | 703 { |
704 type = it->second; | 704 type = it->second; |
705 } | 705 } |
706 } | 706 } |
707 | 707 |
708 CPluginClient* client = CPluginClient::GetInstance(); | 708 CPluginClient* client = CPluginClient::GetInstance(); |
709 | 709 if (client->Matches(std::wstring(src), std::wstring(type), std::wstring(domain
))) |
710 std::string contentTypeString = CT2A(type, CP_UTF8); | |
711 | |
712 CT2CA srcMb(src, CP_UTF8); | |
713 std::string url(srcMb); | |
714 | |
715 std::string domainMb = CT2CA(domain); | |
716 | |
717 if (client->Matches(url, contentTypeString, domainMb)) | |
718 { | 710 { |
719 if (addDebug) | 711 if (addDebug) |
720 { | 712 { |
721 DEBUG_FILTER("Filter::ShouldBlock " + type + " YES") | 713 DEBUG_FILTER("Filter::ShouldBlock " + type + " YES") |
722 | 714 |
723 #ifdef ENABLE_DEBUG_RESULT | 715 #ifdef ENABLE_DEBUG_RESULT |
724 CPluginDebug::DebugResultBlocking(type, src, domain); | 716 CPluginDebug::DebugResultBlocking(type, src, domain); |
725 #endif | 717 #endif |
726 } | 718 } |
727 return true; | 719 return true; |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
873 if (pos > 0 && domain.GetLength() + pos == subdomain.GetLength()) | 865 if (pos > 0 && domain.GetLength() + pos == subdomain.GetLength()) |
874 { | 866 { |
875 if (subdomain.GetAt(pos - 1) == '.') | 867 if (subdomain.GetAt(pos - 1) == '.') |
876 { | 868 { |
877 return true; | 869 return true; |
878 } | 870 } |
879 } | 871 } |
880 | 872 |
881 return false; | 873 return false; |
882 } | 874 } |
OLD | NEW |