OLD | NEW |
1 #include "PluginStdAfx.h" | 1 #include "PluginStdAfx.h" |
2 | 2 |
3 #include "PluginFilter.h" | 3 #include "PluginFilter.h" |
4 #include "PluginSettings.h" | 4 #include "PluginSettings.h" |
5 #include "PluginClient.h" | 5 #include "PluginClient.h" |
6 #include "PluginClientFactory.h" | 6 #include "PluginClientFactory.h" |
7 #include "PluginMutex.h" | 7 #include "PluginMutex.h" |
8 #include "PluginSettings.h" | 8 #include "PluginSettings.h" |
9 #include "PluginSystem.h" | 9 #include "PluginSystem.h" |
10 #include "PluginClass.h" | 10 #include "PluginClass.h" |
(...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
524 if (!id.IsEmpty()) | 524 if (!id.IsEmpty()) |
525 { | 525 { |
526 std::pair<TFilterElementHideTagsNamed::const_iterator, TFilterElementHideT
agsNamed::const_iterator> idItEnum = | 526 std::pair<TFilterElementHideTagsNamed::const_iterator, TFilterElementHideT
agsNamed::const_iterator> idItEnum = |
527 m_elementHideTagsId.equal_range(std::make_pair(tagCString, id)); | 527 m_elementHideTagsId.equal_range(std::make_pair(tagCString, id)); |
528 for (TFilterElementHideTagsNamed::const_iterator idIt = idItEnum.first; id
It != idItEnum.second; idIt ++) | 528 for (TFilterElementHideTagsNamed::const_iterator idIt = idItEnum.first; id
It != idItEnum.second; idIt ++) |
529 { | 529 { |
530 if (idIt->second.IsMatchFilterElementHide(pEl)) | 530 if (idIt->second.IsMatchFilterElementHide(pEl)) |
531 { | 531 { |
532 #ifdef ENABLE_DEBUG_RESULT | 532 #ifdef ENABLE_DEBUG_RESULT |
533 DEBUG_HIDE_EL(indent + "HideEl::Found (tag/id) filter:" + idIt->second
.m_filterText) | 533 DEBUG_HIDE_EL(indent + "HideEl::Found (tag/id) filter:" + idIt->second
.m_filterText) |
534 CPluginDebug::DebugResultHiding(tagCString, "id:" + id, idIt->second
.m_filterText); | 534 CPluginDebug::DebugResultHiding(tagCString, L"id:" + id, idIt->secon
d.m_filterText); |
535 #endif | 535 #endif |
536 return true; | 536 return true; |
537 } | 537 } |
538 } | 538 } |
539 | 539 |
540 // Search general id | 540 // Search general id |
541 idItEnum = m_elementHideTagsId.equal_range(std::make_pair("", id)); | 541 idItEnum = m_elementHideTagsId.equal_range(std::make_pair("", id)); |
542 for (TFilterElementHideTagsNamed::const_iterator idIt = idItEnum.first; id
It != idItEnum.second; idIt ++) | 542 for (TFilterElementHideTagsNamed::const_iterator idIt = idItEnum.first; id
It != idItEnum.second; idIt ++) |
543 { | 543 { |
544 if (idIt->second.IsMatchFilterElementHide(pEl)) | 544 if (idIt->second.IsMatchFilterElementHide(pEl)) |
545 { | 545 { |
546 #ifdef ENABLE_DEBUG_RESULT | 546 #ifdef ENABLE_DEBUG_RESULT |
547 DEBUG_HIDE_EL(indent + "HideEl::Found (?/id) filter:" + idIt->second.m
_filterText) | 547 DEBUG_HIDE_EL(indent + "HideEl::Found (?/id) filter:" + idIt->second.m
_filterText) |
548 CPluginDebug::DebugResultHiding(tagCString, "id:" + id, idIt->second
.m_filterText); | 548 CPluginDebug::DebugResultHiding(tagCString, L"id:" + id, idIt->secon
d.m_filterText); |
549 #endif | 549 #endif |
550 return true; | 550 return true; |
551 } | 551 } |
552 } | 552 } |
553 } | 553 } |
554 | 554 |
555 // Search tag/className filters | 555 // Search tag/className filters |
556 if (!classNames.IsEmpty()) | 556 if (!classNames.IsEmpty()) |
557 { | 557 { |
558 int pos = 0; | 558 int pos = 0; |
559 CString className = classNames.Tokenize(L" \t\n\r", pos); | 559 CString className = classNames.Tokenize(L" \t\n\r", pos); |
560 while (pos >= 0) | 560 while (pos >= 0) |
561 { | 561 { |
562 std::pair<TFilterElementHideTagsNamed::const_iterator, TFilterElementHid
eTagsNamed::const_iterator> classItEnum = | 562 std::pair<TFilterElementHideTagsNamed::const_iterator, TFilterElementHid
eTagsNamed::const_iterator> classItEnum = |
563 m_elementHideTagsClass.equal_range(std::make_pair(tagCString, classNam
e)); | 563 m_elementHideTagsClass.equal_range(std::make_pair(tagCString, classNam
e)); |
564 | 564 |
565 for (TFilterElementHideTagsNamed::const_iterator classIt = classItEnum.f
irst; classIt != classItEnum.second; ++classIt) | 565 for (TFilterElementHideTagsNamed::const_iterator classIt = classItEnum.f
irst; classIt != classItEnum.second; ++classIt) |
566 { | 566 { |
567 if (classIt->second.IsMatchFilterElementHide(pEl)) | 567 if (classIt->second.IsMatchFilterElementHide(pEl)) |
568 { | 568 { |
569 #ifdef ENABLE_DEBUG_RESULT | 569 #ifdef ENABLE_DEBUG_RESULT |
570 DEBUG_HIDE_EL(indent + "HideEl::Found (tag/class) filter:" + classIt
->second.m_filterText) | 570 DEBUG_HIDE_EL(indent + "HideEl::Found (tag/class) filter:" + classIt
->second.m_filterText) |
571 CPluginDebug::DebugResultHiding(tagCString, "class:" + className,
classIt->second.m_filterText); | 571 CPluginDebug::DebugResultHiding(tagCString, L"class:" + className,
classIt->second.m_filterText); |
572 #endif | 572 #endif |
573 return true; | 573 return true; |
574 } | 574 } |
575 } | 575 } |
576 | 576 |
577 // Search general class name | 577 // Search general class name |
578 classItEnum = m_elementHideTagsClass.equal_range(std::make_pair("", clas
sName)); | 578 classItEnum = m_elementHideTagsClass.equal_range(std::make_pair("", clas
sName)); |
579 for (TFilterElementHideTagsNamed::const_iterator classIt = classItEnum.f
irst; classIt != classItEnum.second; ++ classIt) | 579 for (TFilterElementHideTagsNamed::const_iterator classIt = classItEnum.f
irst; classIt != classItEnum.second; ++ classIt) |
580 { | 580 { |
581 if (classIt->second.IsMatchFilterElementHide(pEl)) | 581 if (classIt->second.IsMatchFilterElementHide(pEl)) |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
664 } | 664 } |
665 | 665 |
666 m_elementHideTags.clear(); | 666 m_elementHideTags.clear(); |
667 m_elementHideTagsId.clear(); | 667 m_elementHideTagsId.clear(); |
668 m_elementHideTagsClass.clear(); | 668 m_elementHideTagsClass.clear(); |
669 } | 669 } |
670 } | 670 } |
671 | 671 |
672 bool CPluginFilter::ShouldBlock(const std::wstring& src, int contentType, const
std::wstring& domain, bool addDebug) const | 672 bool CPluginFilter::ShouldBlock(const std::wstring& src, int contentType, const
std::wstring& domain, bool addDebug) const |
673 { | 673 { |
674 CString srcCString = to_CString(src); | 674 CString srcCString = ToCString(src); |
| 675 srcCString.Trim(); |
| 676 std::wstring srcTrimmed = ToWstring(srcCString); |
675 | 677 |
676 // We should not block the empty string, so all filtering does not make sense | 678 // We should not block the empty string, so all filtering does not make sense |
677 // Therefore we just return | 679 // Therefore we just return |
678 if (srcCString.Trim().IsEmpty()) | 680 if (srcTrimmed.empty()) |
679 { | 681 { |
680 return false; | 682 return false; |
681 } | 683 } |
682 | |
683 CPluginSettings* settings = CPluginSettings::GetInstance(); | 684 CPluginSettings* settings = CPluginSettings::GetInstance(); |
684 | 685 |
685 CString type; | 686 CString type; |
686 if (addDebug) | 687 if (addDebug) |
687 { | 688 { |
688 type = "OTHER"; | 689 type = "OTHER"; |
689 | 690 |
690 std::map<int,CString>::const_iterator it = m_contentMapText.find(contentType
); | 691 std::map<int,CString>::const_iterator it = m_contentMapText.find(contentType
); |
691 if (it != m_contentMapText.end()) | 692 if (it != m_contentMapText.end()) |
692 { | 693 { |
693 type = it->second; | 694 type = it->second; |
694 } | 695 } |
695 } | 696 } |
696 | 697 |
697 CPluginClient* client = CPluginClient::GetInstance(); | 698 CPluginClient* client = CPluginClient::GetInstance(); |
698 if (client->Matches(to_wstring(srcCString), to_wstring(type), domain)) | 699 if (client->Matches(srcTrimmed, to_wstring(type), domain)) |
699 { | 700 { |
700 if (addDebug) | 701 if (addDebug) |
701 { | 702 { |
702 DEBUG_FILTER("Filter::ShouldBlock " + type + " YES") | 703 DEBUG_FILTER("Filter::ShouldBlock " + type + " YES") |
703 | 704 |
704 #ifdef ENABLE_DEBUG_RESULT | 705 #ifdef ENABLE_DEBUG_RESULT |
705 CPluginDebug::DebugResultBlocking(type, srcCString, domain); | 706 CPluginDebug::DebugResultBlocking(type, srcTrimmed, domain); |
706 #endif | 707 #endif |
707 } | 708 } |
708 return true; | 709 return true; |
709 } | 710 } |
710 return false; | 711 return false; |
711 } | 712 } |
OLD | NEW |