Beispiel #1
0
        private static void TestForBug20()
        {
            var col = new FilterDbCollection();

            col.ParseStoreRules(new[] { "%3D$popup,domain=nme.com" }, 1);
            col.FinalizeForRead();

            var uri = new Uri("https://vsco.co/goodvibes-vsco/media/5c2fb09c8e529d3e52b4231b?share=MTU0NjYyOTI4MA%3D%3D");

            var allRules = col.GetFiltersForDomain("nme.com");

            var nvm = new NameValueCollection();

            var len = allRules.Count();

            foreach (var wlr in allRules)
            {
                Debug.Assert(wlr.IsMatch(uri, nvm) == false);
            }

            Console.ReadKey();
        }
Beispiel #2
0
        private static void TestDomainWideException()
        {
            FilterDbCollection col = new FilterDbCollection();

            //"@@$third-party,referer=~pinterest.com"

            col.ParseStoreRules(new[] { "@@$referer=pinterest.com" }, 1);
            col.FinalizeForRead();

            var headersShouldMatch = new NameValueCollection(StringComparer.OrdinalIgnoreCase)
            {
                { "X-Requested-With", "XmlHttpRequest" },
                { "Content-Type", "script" },
                { "Referer", "https://www.pinterest.com" },
            };

            var headersShouldnt = new NameValueCollection(StringComparer.OrdinalIgnoreCase)
            {
                { "X-Requested-With", "XmlHttpRequest" },
                { "Content-Type", "script" },
                { "Referer", "https://www.silsly.com" },
            };

            var uri = new Uri("http://silly.com/stoopid/url&=b1");

            var allRules = col.GetWhitelistFiltersForDomain();

            foreach (var wlr in allRules)
            {
                Console.WriteLine("Inc R: {0}", string.Join(", ", wlr.ApplicableReferers));
                Console.WriteLine("Exc R: {0}", string.Join(", ", wlr.ExceptReferers));

                Console.WriteLine(wlr.IsMatch(uri, headersShouldMatch));
                Console.WriteLine(wlr.IsMatch(uri, headersShouldnt));
            }

            Console.ReadKey();
        }