LEFT | RIGHT |
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 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
428 "! fo o## bar"); | 428 "! fo o## bar"); |
429 | 429 |
430 // Element hiding filters | 430 // Element hiding filters |
431 test.equal(Filter.normalize(" domain.c om## # sele ctor "), | 431 test.equal(Filter.normalize(" domain.c om## # sele ctor "), |
432 "domain.com### sele ctor"); | 432 "domain.com### sele ctor"); |
433 | 433 |
434 // Element hiding emulation filters | 434 // Element hiding emulation filters |
435 test.equal(Filter.normalize(" domain.c om#?# # sele ctor "), | 435 test.equal(Filter.normalize(" domain.c om#?# # sele ctor "), |
436 "domain.com#?## sele ctor"); | 436 "domain.com#?## sele ctor"); |
437 | 437 |
| 438 // Incorrect syntax: the separator "#?#" cannot contain spaces; treated as a |
| 439 // regular filter instead |
| 440 test.equal(Filter.normalize(" domain.c om# ?#. sele ctor "), |
| 441 "domain.com#?#.selector"); |
| 442 // Incorrect syntax: the separator "#?#" cannot contain spaces; treated as an |
| 443 // element hiding filter instead, because the "##" following the "?" is taken |
| 444 // to be the separator instead |
| 445 test.equal(Filter.normalize(" domain.c om# ?##sele ctor "), |
| 446 "domain.com#?##sele ctor"); |
| 447 |
438 // Element hiding exception filters | 448 // Element hiding exception filters |
439 test.equal(Filter.normalize(" domain.c om#@# # sele ctor "), | 449 test.equal(Filter.normalize(" domain.c om#@# # sele ctor "), |
440 "domain.com#@## sele ctor"); | 450 "domain.com#@## sele ctor"); |
| 451 |
| 452 // Incorrect syntax: the separator "#@#" cannot contain spaces; treated as a |
| 453 // regular filter instead (not an element hiding filter either!), because |
| 454 // unlike the case with "# ?##" the "##" following the "@" is not considered |
| 455 // to be a separator |
| 456 test.equal(Filter.normalize(" domain.c om# @## sele ctor "), |
| 457 "domain.com#@##selector"); |
441 | 458 |
442 // Regular filters | 459 // Regular filters |
443 let normalized = Filter.normalize( | 460 let normalized = Filter.normalize( |
444 " b$l a$sitekey= foo ,domain= do main.com |foo .com,c sp= c s p
" | 461 " b$l a$sitekey= foo ,domain= do main.com |foo .com,c sp= c s p
" |
445 ); | 462 ); |
446 test.equal( | 463 test.equal( |
447 normalized, | 464 normalized, |
448 "b$la$sitekey=foo,domain=domain.com|foo.com,csp=c s p" | 465 "b$la$sitekey=foo,domain=domain.com|foo.com,csp=c s p" |
449 ); | 466 ); |
450 compareFilter( | 467 compareFilter( |
(...skipping 25 matching lines...) Expand all Loading... |
476 "foo$csp=bar,$csp=c s p"); | 493 "foo$csp=bar,$csp=c s p"); |
477 test.equal(Filter.normalize(" f o o $ bar $csp=ba r"), | 494 test.equal(Filter.normalize(" f o o $ bar $csp=ba r"), |
478 "foo$bar$csp=ba r"); | 495 "foo$bar$csp=ba r"); |
479 test.equal(Filter.normalize("f $ o $ o $ csp=f o o "), | 496 test.equal(Filter.normalize("f $ o $ o $ csp=f o o "), |
480 "f$o$o$csp=f o o"); | 497 "f$o$o$csp=f o o"); |
481 test.equal(Filter.normalize("/foo$/$ csp = script-src http://example.com/?$1=
1&$2=2&$3=3"), | 498 test.equal(Filter.normalize("/foo$/$ csp = script-src http://example.com/?$1=
1&$2=2&$3=3"), |
482 "/foo$/$csp=script-src http://example.com/?$1=1&$2=2&$3=3"); | 499 "/foo$/$csp=script-src http://example.com/?$1=1&$2=2&$3=3"); |
483 | 500 |
484 test.done(); | 501 test.done(); |
485 }; | 502 }; |
LEFT | RIGHT |