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

Side by Side Diff: test/filterClasses.js

Issue 29801609: Issue 6733 - Allow empty values in filter options (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Rebase and simplify Created June 25, 2018, 1:08 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
« lib/filterClasses.js ('K') | « lib/filterClasses.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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-present eyeo GmbH 3 * Copyright (C) 2006-present 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 465 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 "text=" + normalized, 476 "text=" + normalized,
477 "csp=c s p", 477 "csp=c s p",
478 "domains=domain.com|foo.com", 478 "domains=domain.com|foo.com",
479 "sitekeys=FOO", 479 "sitekeys=FOO",
480 "regexp=b\\$la", 480 "regexp=b\\$la",
481 "contentType=" + t.CSP 481 "contentType=" + t.CSP
482 ] 482 ]
483 ); 483 );
484 484
485 // Some $csp edge cases 485 // Some $csp edge cases
486 test.equal(Filter.normalize("$csp= "),
Manish Jethani 2018/06/25 13:13:44 This is important now because we want to return In
487 "$csp=");
486 test.equal(Filter.normalize("$csp= c s p"), 488 test.equal(Filter.normalize("$csp= c s p"),
487 "$csp=c s p"); 489 "$csp=c s p");
488 test.equal(Filter.normalize("$$csp= c s p"), 490 test.equal(Filter.normalize("$$csp= c s p"),
489 "$$csp=c s p"); 491 "$$csp=c s p");
490 test.equal(Filter.normalize("$$$csp= c s p"), 492 test.equal(Filter.normalize("$$$csp= c s p"),
491 "$$$csp=c s p"); 493 "$$$csp=c s p");
492 test.equal(Filter.normalize("foo?csp=b a r$csp=script-src 'self'"), 494 test.equal(Filter.normalize("foo?csp=b a r$csp=script-src 'self'"),
493 "foo?csp=bar$csp=script-src 'self'"); 495 "foo?csp=bar$csp=script-src 'self'");
494 test.equal(Filter.normalize("foo$bar=c s p = ba z,cs p = script-src 'self'"), 496 test.equal(Filter.normalize("foo$bar=c s p = ba z,cs p = script-src 'self'"),
495 "foo$bar=csp=baz,csp=script-src 'self'"); 497 "foo$bar=csp=baz,csp=script-src 'self'");
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
549 // Example from https://github.com/uBlockOrigin/uBlock-issues/issues/46#issuec omment-391190533 551 // Example from https://github.com/uBlockOrigin/uBlock-issues/issues/46#issuec omment-391190533
550 // The rewrite shouldn't happen. 552 // The rewrite shouldn't happen.
551 let rewriteEvil = "/(^https?:\\/\\/[^/])/$script,rewrite=$1.evil.com"; 553 let rewriteEvil = "/(^https?:\\/\\/[^/])/$script,rewrite=$1.evil.com";
552 let filterEvil = Filter.fromText(rewriteEvil); 554 let filterEvil = Filter.fromText(rewriteEvil);
553 555
554 test.equal( 556 test.equal(
555 filterEvil.rewriteUrl("https://www.adblockplus.org/script.js"), 557 filterEvil.rewriteUrl("https://www.adblockplus.org/script.js"),
556 "https://www.adblockplus.org/script.js" 558 "https://www.adblockplus.org/script.js"
557 ); 559 );
558 560
561 // Strip.
562 let rewriteStrip = "tag$rewrite=";
563 let filterStrip = Filter.fromText(rewriteStrip);
564
565 test.equal(filterStrip.rewrite, "");
566 test.equal(
567 filterStrip.rewriteUrl("http://example.com/?tag"),
568 "http://example.com/?"
569 );
570
559 test.done(); 571 test.done();
560 }; 572 };
OLDNEW
« lib/filterClasses.js ('K') | « lib/filterClasses.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld