Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: src/plugin/PluginFilter.cpp

Issue 5096167658487808: [IE] Dead code (Closed)
Patch Set: Created June 20, 2014, 9:26 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/plugin/PluginFilter.h ('k') | src/plugin/PluginSettings.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 m_contentType = filter.m_contentType; 217 m_contentType = filter.m_contentType;
218 m_filterType = filter.m_filterType; 218 m_filterType = filter.m_filterType;
219 219
220 m_isFirstParty = filter.m_isFirstParty; 220 m_isFirstParty = filter.m_isFirstParty;
221 m_isThirdParty = filter.m_isThirdParty; 221 m_isThirdParty = filter.m_isThirdParty;
222 222
223 m_isMatchCase = filter.m_isMatchCase; 223 m_isMatchCase = filter.m_isMatchCase;
224 m_isFromStart = filter.m_isFromStart; 224 m_isFromStart = filter.m_isFromStart;
225 m_isFromEnd = filter.m_isFromEnd; 225 m_isFromEnd = filter.m_isFromEnd;
226 226
227 m_stringElements = filter.m_stringElements;
228
229 m_filterText = filter.m_filterText; 227 m_filterText = filter.m_filterText;
230 228
231 m_hitCount = filter.m_hitCount; 229 m_hitCount = filter.m_hitCount;
232 } 230 }
233 231
234 232
235 CFilter::CFilter() : m_isMatchCase(false), m_isFirstParty(false), m_isThirdParty (false), m_contentType(CFilter::contentTypeAny), 233 CFilter::CFilter() : m_isMatchCase(false), m_isFirstParty(false), m_isThirdParty (false), m_contentType(CFilter::contentTypeAny),
236 m_isFromStart(false), m_isFromEnd(false), m_hitCount(0) 234 m_isFromStart(false), m_isFromEnd(false), m_hitCount(0)
237 { 235 {
238 } 236 }
(...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after
711 { 709 {
712 DEBUG_FILTER("Filter::ShouldBlock " + type + " YES") 710 DEBUG_FILTER("Filter::ShouldBlock " + type + " YES")
713 711
714 #ifdef ENABLE_DEBUG_RESULT 712 #ifdef ENABLE_DEBUG_RESULT
715 CPluginDebug::DebugResultBlocking(type, src, domain); 713 CPluginDebug::DebugResultBlocking(type, src, domain);
716 #endif 714 #endif
717 } 715 }
718 return true; 716 return true;
719 } 717 }
720 return false; 718 return false;
721 } 719 }
Eric 2014/06/20 21:30:41 The last function that called FindMatch() was repl
722
723 int CPluginFilter::FindMatch(const CString& src, CString filterPart, int srcStar tPos) const
724 {
725 int filterCurrentPos = filterPart.Find('^');
726 if (filterCurrentPos >= 0)
727 {
728 int srcLength = src.GetLength();
729 int srcFilterPos = -1;
730 int srcCurrentPos = srcStartPos;
731 int srcLastTestPos = -1;
732
733 // Special char(s) as first char?
734 int nFirst = 0;
735 while (filterCurrentPos == 0)
736 {
737 filterPart = filterPart.Right(filterPart.GetLength() - 1);
738 ++nFirst;
739 filterCurrentPos = filterPart.Find('^');
740 }
741
742 // Find first part without special chars
743 CString test = filterCurrentPos >= 0 ? filterPart.Left(filterCurrentPos) : f ilterPart;
744 int testLength = test.GetLength();
745
746 while (filterCurrentPos >= 0 || testLength > 0)
747 {
748 int srcFindPos = testLength > 0 ? src.Find(test, srcCurrentPos) : srcCurre ntPos;
749 if (srcFindPos < 0)
750 {
751 // Always fail - no need to iterate
752 return -1;
753 }
754
755 if (testLength > 0)
756 {
757 srcLastTestPos = srcFindPos;
758 }
759
760 // Already found earlier part; this part must follow
761 if (srcFilterPos >= 0)
762 {
763 // Found position must be position we are at in source
764 if (srcFindPos != srcCurrentPos)
765 {
766 // Try to next iteration maybe we will find it later
767 return srcLastTestPos >= 0 ? FindMatch(src, filterPart, srcLastTestPos + 1) : -1;
768 }
769 }
770 else
771 {
772 srcCurrentPos = srcFindPos;
773 srcFilterPos = srcFindPos;
774
775 // If starting with special char, check for that
776 for (int n = 1; n <= nFirst; n++)
777 {
778 if (--srcFilterPos < 0 || srcFilterPos < srcStartPos || !IsSpecialChar (src.GetAt(srcFilterPos)))
779 {
780 // Try to next iteration maybe we will find it later
781 return srcLastTestPos >= 0 ? FindMatch(src, filterPart, srcLastTestP os + 1) : -1;
782 }
783 }
784 nFirst = 0;
785 }
786
787 srcCurrentPos += testLength;
788
789 // Next char must be special char
790 if (filterCurrentPos >= 0 && !IsSpecialChar(src.GetAt(srcCurrentPos++)))
791 {
792 // Try to next iteration maybe we will find it later
793 return srcLastTestPos >= 0 ? FindMatch(src, filterPart, srcLastTestPos + 1) : -1;
794 }
795
796 // Upate test strin and position for next loop
797 if (filterCurrentPos >= 0)
798 {
799 int filterNewPos = filterPart.Find('^', filterCurrentPos + 1);
800 test = filterNewPos >= 0 ? filterPart.Mid(filterCurrentPos + 1, filterNe wPos - filterCurrentPos - 1) : filterPart.Right(filterPart.GetLength() - filterC urrentPos - 1);
801
802 filterCurrentPos = filterNewPos;
803 }
804 else
805 {
806 test.Empty();
807 }
808 testLength = test.GetLength();
809 }
810
811 // If only special chars, check for that
812 if (nFirst > 0)
813 {
814 int nFound = 0;
815
816 srcFilterPos = srcCurrentPos;
817
818 while (nFound != nFirst && srcLength >= srcFilterPos + nFound)
819 {
820 if (IsSpecialChar(src.GetAt(srcFilterPos + nFound)))
821 {
822 nFound++;
823 }
824 else
825 {
826 if (nFound > 0)
827 {
828 nFound--;
829 }
830
831 srcFilterPos++;
832 }
833 }
834
835 if (nFound != nFirst)
836 {
837 // Always fail - no need to iterate
838 return -1;
839 }
840 }
841
842 return srcFilterPos;
843 }
844 else
845 {
846 return src.Find(filterPart, srcStartPos);
847 }
848 }
849
850 bool CPluginFilter::IsSpecialChar(TCHAR testChar) const
851 {
852 if (isalnum(testChar) || testChar == '.' || testChar == '-' || testChar == '%' )
853 {
854 return false;
855 }
856
857 return true;
858 }
859
860 bool CPluginFilter::IsSubdomain(const CString& subdomain, const CString& domain) const
861 {
862 int pos = subdomain.Find(domain);
863
864 if (pos > 0 && domain.GetLength() + pos == subdomain.GetLength())
865 {
866 if (subdomain.GetAt(pos - 1) == '.')
867 {
868 return true;
869 }
870 }
871
872 return false;
873 }
OLDNEW
« no previous file with comments | « src/plugin/PluginFilter.h ('k') | src/plugin/PluginSettings.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld