| OLD | NEW |
| 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 Loading... |
| 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= "), |
| 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 Loading... |
| 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 }; |
| OLD | NEW |