| Left: | ||
| Right: |
| 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 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 233 return beforeOptions + "$" + options.join(); | 233 return beforeOptions + "$" + options.join(); |
| 234 }; | 234 }; |
| 235 | 235 |
| 236 /** | 236 /** |
| 237 * @see filterToRegExp | 237 * @see filterToRegExp |
| 238 */ | 238 */ |
| 239 Filter.toRegExp = filterToRegExp; | 239 Filter.toRegExp = filterToRegExp; |
| 240 | 240 |
| 241 /** | 241 /** |
| 242 * Class for invalid filters | 242 * Class for invalid filters |
| 243 * @param {string} text see Filter() | 243 * @param {string} text see {@link Filter Filter()} |
| 244 * @param {string} reason Reason why this filter is invalid | 244 * @param {string} reason Reason why this filter is invalid |
| 245 * @constructor | 245 * @constructor |
| 246 * @augments Filter | 246 * @augments Filter |
| 247 */ | 247 */ |
| 248 function InvalidFilter(text, reason) | 248 function InvalidFilter(text, reason) |
| 249 { | 249 { |
| 250 Filter.call(this, text); | 250 Filter.call(this, text); |
| 251 | 251 |
| 252 this.reason = reason; | 252 this.reason = reason; |
| 253 } | 253 } |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 264 | 264 |
| 265 /** | 265 /** |
| 266 * See Filter.serialize() | 266 * See Filter.serialize() |
| 267 * @inheritdoc | 267 * @inheritdoc |
| 268 */ | 268 */ |
| 269 serialize(buffer) {} | 269 serialize(buffer) {} |
| 270 }); | 270 }); |
| 271 | 271 |
| 272 /** | 272 /** |
| 273 * Class for comments | 273 * Class for comments |
| 274 * @param {string} text see Filter() | 274 * @param {string} text see {@link Filter Filter()} |
| 275 * @constructor | 275 * @constructor |
| 276 * @augments Filter | 276 * @augments Filter |
| 277 */ | 277 */ |
| 278 function CommentFilter(text) | 278 function CommentFilter(text) |
| 279 { | 279 { |
| 280 Filter.call(this, text); | 280 Filter.call(this, text); |
| 281 } | 281 } |
| 282 exports.CommentFilter = CommentFilter; | 282 exports.CommentFilter = CommentFilter; |
| 283 | 283 |
| 284 CommentFilter.prototype = extend(Filter, { | 284 CommentFilter.prototype = extend(Filter, { |
| 285 type: "comment", | 285 type: "comment", |
| 286 | 286 |
| 287 /** | 287 /** |
| 288 * See Filter.serialize() | 288 * See Filter.serialize() |
| 289 * @inheritdoc | 289 * @inheritdoc |
| 290 */ | 290 */ |
| 291 serialize(buffer) {} | 291 serialize(buffer) {} |
| 292 }); | 292 }); |
| 293 | 293 |
| 294 /** | 294 /** |
| 295 * Abstract base class for filters that can get hits | 295 * Abstract base class for filters that can get hits |
| 296 * @param {string} text | 296 * @param {string} text |
| 297 * see Filter() | 297 * see {@link Filter Filter()} |
| 298 * @param {string} [domains] | 298 * @param {string} [domains] |
| 299 * Domains that the filter is restricted to separated by domainSeparator | 299 * Domains that the filter is restricted to separated by domainSeparator |
| 300 * e.g. "foo.com|bar.com|~baz.com" | 300 * e.g. "foo.com|bar.com|~baz.com" |
| 301 * @constructor | 301 * @constructor |
| 302 * @augments Filter | 302 * @augments Filter |
| 303 */ | 303 */ |
| 304 function ActiveFilter(text, domains) | 304 function ActiveFilter(text, domains) |
| 305 { | 305 { |
| 306 Filter.call(this, text); | 306 Filter.call(this, text); |
| 307 | 307 |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 380 domainSource: null, | 380 domainSource: null, |
| 381 | 381 |
| 382 /** | 382 /** |
| 383 * Separator character used in domainSource property, must be | 383 * Separator character used in domainSource property, must be |
| 384 * overridden by subclasses | 384 * overridden by subclasses |
| 385 * @type {string} | 385 * @type {string} |
| 386 */ | 386 */ |
| 387 domainSeparator: null, | 387 domainSeparator: null, |
| 388 | 388 |
| 389 /** | 389 /** |
| 390 * Determines whether domainSource is already upper-case, | 390 * Determines whether domainSource is already lower-case, |
| 391 * can be overridden by subclasses. | 391 * can be overridden by subclasses. |
| 392 * @type {boolean} | 392 * @type {boolean} |
| 393 */ | 393 */ |
| 394 domainSourceIsUpperCase: false, | 394 domainSourceIsLowerCase: false, |
| 395 | 395 |
| 396 /** | 396 /** |
| 397 * Map containing domains that this filter should match on/not match | 397 * Map containing domains that this filter should match on/not match |
| 398 * on or null if the filter should match on all domains | 398 * on or null if the filter should match on all domains |
| 399 * @type {?Map.<string,boolean>} | 399 * @type {?Map.<string,boolean>} |
| 400 */ | 400 */ |
| 401 get domains() | 401 get domains() |
| 402 { | 402 { |
| 403 let domains = null; | 403 let domains = null; |
| 404 | 404 |
| 405 if (this.domainSource) | 405 if (this.domainSource) |
| 406 { | 406 { |
| 407 let source = this.domainSource; | 407 let source = this.domainSource; |
| 408 if (!this.domainSourceIsUpperCase) | 408 if (!this.domainSourceIsLowerCase) |
| 409 { | 409 { |
| 410 // RegExpFilter already have uppercase domains | 410 // RegExpFilter already have lowercase domains |
| 411 source = source.toUpperCase(); | 411 source = source.toLowerCase(); |
| 412 } | 412 } |
| 413 let list = source.split(this.domainSeparator); | 413 let list = source.split(this.domainSeparator); |
| 414 if (list.length == 1 && list[0][0] != "~") | 414 if (list.length == 1 && list[0][0] != "~") |
| 415 { | 415 { |
| 416 // Fast track for the common one-domain scenario | 416 // Fast track for the common one-domain scenario |
| 417 domains = new Map([["", false], [list[0], true]]); | 417 domains = new Map([["", false], [list[0], true]]); |
| 418 } | 418 } |
| 419 else | 419 else |
| 420 { | 420 { |
| 421 let hasIncludes = false; | 421 let hasIncludes = false; |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 478 | 478 |
| 479 // If no domains are set the rule matches everywhere | 479 // If no domains are set the rule matches everywhere |
| 480 if (!this.domains) | 480 if (!this.domains) |
| 481 return true; | 481 return true; |
| 482 | 482 |
| 483 // If the document has no host name, match only if the filter | 483 // If the document has no host name, match only if the filter |
| 484 // isn't restricted to specific domains | 484 // isn't restricted to specific domains |
| 485 if (!docDomain) | 485 if (!docDomain) |
| 486 return this.domains.get(""); | 486 return this.domains.get(""); |
| 487 | 487 |
| 488 docDomain = docDomain.replace(/\.+$/, "").toUpperCase(); | 488 docDomain = docDomain.replace(/\.+$/, "").toLowerCase(); |
| 489 | 489 |
| 490 while (true) | 490 while (true) |
| 491 { | 491 { |
| 492 let isDomainIncluded = this.domains.get(docDomain); | 492 let isDomainIncluded = this.domains.get(docDomain); |
| 493 if (typeof isDomainIncluded != "undefined") | 493 if (typeof isDomainIncluded != "undefined") |
| 494 return isDomainIncluded; | 494 return isDomainIncluded; |
| 495 | 495 |
| 496 let nextDot = docDomain.indexOf("."); | 496 let nextDot = docDomain.indexOf("."); |
| 497 if (nextDot < 0) | 497 if (nextDot < 0) |
| 498 break; | 498 break; |
| 499 docDomain = docDomain.substr(nextDot + 1); | 499 docDomain = docDomain.substr(nextDot + 1); |
| 500 } | 500 } |
| 501 return this.domains.get(""); | 501 return this.domains.get(""); |
| 502 }, | 502 }, |
| 503 | 503 |
| 504 /** | 504 /** |
| 505 * Checks whether this filter is active only on a domain and its subdomains. | 505 * Checks whether this filter is active only on a domain and its subdomains. |
| 506 * @param {string} docDomain | 506 * @param {string} docDomain |
| 507 * @return {boolean} | 507 * @return {boolean} |
| 508 */ | 508 */ |
| 509 isActiveOnlyOnDomain(docDomain) | 509 isActiveOnlyOnDomain(docDomain) |
| 510 { | 510 { |
| 511 if (!docDomain || !this.domains || this.domains.get("")) | 511 if (!docDomain || !this.domains || this.domains.get("")) |
| 512 return false; | 512 return false; |
| 513 | 513 |
| 514 docDomain = docDomain.replace(/\.+$/, "").toUpperCase(); | 514 docDomain = docDomain.replace(/\.+$/, "").toLowerCase(); |
| 515 | 515 |
| 516 for (let [domain, isIncluded] of this.domains) | 516 for (let [domain, isIncluded] of this.domains) |
| 517 { | 517 { |
| 518 if (isIncluded && domain != docDomain) | 518 if (isIncluded && domain != docDomain) |
| 519 { | 519 { |
| 520 if (domain.length <= docDomain.length) | 520 if (domain.length <= docDomain.length) |
| 521 return false; | 521 return false; |
| 522 | 522 |
| 523 if (!domain.endsWith("." + docDomain)) | 523 if (!domain.endsWith("." + docDomain)) |
| 524 return false; | 524 return false; |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 552 if (this._hitCount) | 552 if (this._hitCount) |
| 553 buffer.push("hitCount=" + this._hitCount); | 553 buffer.push("hitCount=" + this._hitCount); |
| 554 if (this._lastHit) | 554 if (this._lastHit) |
| 555 buffer.push("lastHit=" + this._lastHit); | 555 buffer.push("lastHit=" + this._lastHit); |
| 556 } | 556 } |
| 557 } | 557 } |
| 558 }); | 558 }); |
| 559 | 559 |
| 560 /** | 560 /** |
| 561 * Abstract base class for RegExp-based filters | 561 * Abstract base class for RegExp-based filters |
| 562 * @param {string} text see Filter() | 562 * @param {string} text see {@link Filter Filter()} |
| 563 * @param {string} regexpSource | 563 * @param {string} regexpSource |
| 564 * filter part that the regular expression should be build from | 564 * filter part that the regular expression should be build from |
| 565 * @param {number} [contentType] | 565 * @param {number} [contentType] |
| 566 * Content types the filter applies to, combination of values from | 566 * Content types the filter applies to, combination of values from |
| 567 * RegExpFilter.typeMap | 567 * RegExpFilter.typeMap |
| 568 * @param {boolean} [matchCase] | 568 * @param {boolean} [matchCase] |
| 569 * Defines whether the filter should distinguish between lower and upper case | 569 * Defines whether the filter should distinguish between lower and upper case |
| 570 * letters | 570 * letters |
| 571 * @param {string} [domains] | 571 * @param {string} [domains] |
| 572 * Domains that the filter is restricted to, e.g. "foo.com|bar.com|~baz.com" | 572 * Domains that the filter is restricted to, e.g. "foo.com|bar.com|~baz.com" |
| 573 * @param {boolean} [thirdParty] | 573 * @param {boolean} [thirdParty] |
| 574 * Defines whether the filter should apply to third-party or first-party | 574 * Defines whether the filter should apply to third-party or first-party |
| 575 * content only | 575 * content only |
| 576 * @param {string} [sitekeys] | 576 * @param {string} [sitekeys] |
| 577 * Public keys of websites that this filter should apply to | 577 * Public keys of websites that this filter should apply to |
| 578 * @constructor | 578 * @constructor |
| 579 * @augments ActiveFilter | 579 * @augments ActiveFilter |
| 580 */ | 580 */ |
| 581 function RegExpFilter(text, regexpSource, contentType, matchCase, domains, | 581 function RegExpFilter(text, regexpSource, contentType, matchCase, domains, |
| 582 thirdParty, sitekeys) | 582 thirdParty, sitekeys) |
| 583 { | 583 { |
| 584 ActiveFilter.call(this, text, domains, sitekeys); | 584 ActiveFilter.call(this, text, domains, sitekeys); |
| 585 | 585 |
| 586 if (contentType != null) | 586 if (contentType != null) |
| 587 this.contentType = contentType; | 587 this.contentType = contentType; |
| 588 if (matchCase) | 588 if (matchCase) |
| 589 this.matchCase = matchCase; | 589 this.matchCase = matchCase; |
| 590 if (thirdParty != null) | 590 if (thirdParty != null) |
| 591 this.thirdParty = thirdParty; | 591 this.thirdParty = thirdParty; |
| 592 if (sitekeys) | 592 if (sitekeys != null) |
| 593 this.sitekeySource = sitekeys; | 593 this.sitekeySource = sitekeys; |
| 594 | 594 |
| 595 if (regexpSource.length >= 2 && | 595 if (regexpSource.length >= 2 && |
| 596 regexpSource[0] == "/" && | 596 regexpSource[0] == "/" && |
| 597 regexpSource[regexpSource.length - 1] == "/") | 597 regexpSource[regexpSource.length - 1] == "/") |
| 598 { | 598 { |
| 599 // The filter is a regular expression - convert it immediately to | 599 // The filter is a regular expression - convert it immediately to |
| 600 // catch syntax errors | 600 // catch syntax errors |
| 601 let regexp = new RegExp(regexpSource.substr(1, regexpSource.length - 2), | 601 let regexp = new RegExp(regexpSource.substr(1, regexpSource.length - 2), |
| 602 this.matchCase ? "" : "i"); | 602 this.matchCase ? "" : "i"); |
| 603 Object.defineProperty(this, "regexp", {value: regexp}); | 603 Object.defineProperty(this, "regexp", {value: regexp}); |
| 604 } | 604 } |
| 605 else | 605 else |
| 606 { | 606 { |
| 607 // No need to convert this filter to regular expression yet, do it on demand | 607 // No need to convert this filter to regular expression yet, do it on demand |
| 608 this.regexpSource = regexpSource; | 608 this.regexpSource = regexpSource; |
| 609 } | 609 } |
| 610 } | 610 } |
| 611 exports.RegExpFilter = RegExpFilter; | 611 exports.RegExpFilter = RegExpFilter; |
| 612 | 612 |
| 613 RegExpFilter.prototype = extend(ActiveFilter, { | 613 RegExpFilter.prototype = extend(ActiveFilter, { |
| 614 /** | 614 /** |
| 615 * @see ActiveFilter.domainSourceIsUpperCase | 615 * @see ActiveFilter.domainSourceIsLowerCase |
| 616 */ | 616 */ |
| 617 domainSourceIsUpperCase: true, | 617 domainSourceIsLowerCase: true, |
| 618 | 618 |
| 619 /** | 619 /** |
| 620 * Number of filters contained, will always be 1 (required to | 620 * Number of filters contained, will always be 1 (required to |
| 621 * optimize Matcher). | 621 * optimize Matcher). |
| 622 * @type {number} | 622 * @type {number} |
| 623 */ | 623 */ |
| 624 length: 1, | 624 length: 1, |
| 625 | 625 |
| 626 /** | 626 /** |
| 627 * @see ActiveFilter.domainSeparator | 627 * @see ActiveFilter.domainSeparator |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 719 | 719 |
| 720 /** | 720 /** |
| 721 * Creates a RegExp filter from its text representation | 721 * Creates a RegExp filter from its text representation |
| 722 * @param {string} text same as in Filter() | 722 * @param {string} text same as in Filter() |
| 723 * @return {Filter} | 723 * @return {Filter} |
| 724 */ | 724 */ |
| 725 RegExpFilter.fromText = function(text) | 725 RegExpFilter.fromText = function(text) |
| 726 { | 726 { |
| 727 let blocking = true; | 727 let blocking = true; |
| 728 let origText = text; | 728 let origText = text; |
| 729 if (text.indexOf("@@") == 0) | 729 if (text[0] == "@" && text[1] == "@") |
| 730 { | 730 { |
| 731 blocking = false; | 731 blocking = false; |
| 732 text = text.substr(2); | 732 text = text.substr(2); |
| 733 } | 733 } |
| 734 | 734 |
| 735 let contentType = null; | 735 let contentType = null; |
| 736 let matchCase = null; | 736 let matchCase = null; |
| 737 let domains = null; | 737 let domains = null; |
| 738 let sitekeys = null; | 738 let sitekeys = null; |
| 739 let thirdParty = null; | 739 let thirdParty = null; |
| 740 let collapse = null; | 740 let collapse = null; |
| 741 let csp = null; | 741 let csp = null; |
| 742 let rewrite = null; | 742 let rewrite = null; |
| 743 let options; | 743 let options; |
| 744 let match = text.includes("$") ? Filter.optionsRegExp.exec(text) : null; | 744 let match = text.includes("$") ? Filter.optionsRegExp.exec(text) : null; |
| 745 if (match) | 745 if (match) |
| 746 { | 746 { |
| 747 options = match[1].split(","); | 747 options = match[1].split(","); |
| 748 text = match.input.substr(0, match.index); | 748 text = match.input.substr(0, match.index); |
| 749 for (let option of options) | 749 for (let option of options) |
| 750 { | 750 { |
| 751 let value = null; | 751 let value = null; |
| 752 let separatorIndex = option.indexOf("="); | 752 let separatorIndex = option.indexOf("="); |
| 753 if (separatorIndex >= 0) | 753 if (separatorIndex >= 0) |
| 754 { | 754 { |
| 755 value = option.substr(separatorIndex + 1); | 755 value = option.substr(separatorIndex + 1); |
| 756 option = option.substr(0, separatorIndex); | 756 option = option.substr(0, separatorIndex); |
| 757 } | 757 } |
| 758 option = option.replace(/-/, "_").toUpperCase(); | 758 |
| 759 if (option in RegExpFilter.typeMap) | 759 let inverse = option[0] == "~"; |
| 760 if (inverse) | |
| 761 option = option.substr(1); | |
| 762 | |
| 763 let type = RegExpFilter.typeMap[option.replace(/-/, "_").toUpperCase()]; | |
| 764 if (type) | |
| 760 { | 765 { |
| 761 if (contentType == null) | 766 if (inverse) |
| 762 contentType = 0; | 767 { |
| 763 contentType |= RegExpFilter.typeMap[option]; | 768 if (contentType == null) |
| 764 | 769 ({contentType} = RegExpFilter.prototype); |
| 765 if (option == "CSP" && value) | 770 contentType &= ~type; |
| 766 csp = value; | 771 } |
| 772 else | |
| 773 { | |
| 774 contentType |= type; | |
| 775 | |
| 776 if (type == RegExpFilter.typeMap.CSP && value) | |
| 777 csp = value; | |
| 778 } | |
| 767 } | 779 } |
| 768 else if (option[0] == "~" && option.substr(1) in RegExpFilter.typeMap) | 780 else |
| 769 { | 781 { |
| 770 if (contentType == null) | 782 switch (option.toLowerCase()) |
| 771 ({contentType} = RegExpFilter.prototype); | 783 { |
| 772 contentType &= ~RegExpFilter.typeMap[option.substr(1)]; | 784 case "match-case": |
| 785 matchCase = !inverse; | |
| 786 break; | |
| 787 case "domain": | |
| 788 if (!value) | |
| 789 return new InvalidFilter(origText, "filter_unknown_option"); | |
| 790 domains = value.toLowerCase(); | |
| 791 break; | |
| 792 case "third-party": | |
| 793 thirdParty = !inverse; | |
| 794 break; | |
| 795 case "collapse": | |
| 796 collapse = !inverse; | |
| 797 break; | |
| 798 case "sitekey": | |
| 799 if (!value) | |
| 800 return new InvalidFilter(origText, "filter_unknown_option"); | |
| 801 sitekeys = value.toUpperCase(); | |
| 802 break; | |
| 803 case "rewrite": | |
| 804 if (value == null) | |
|
Manish Jethani
2018/06/25 13:13:44
Blank value is allowed for $rewrite here while sti
kzar
2018/07/12 10:36:13
So by checking for `value == null` instead of `!va
Manish Jethani
2018/07/12 10:52:55
Yes, we're allowing $rewrite= but not $rewrite, be
kzar
2018/07/12 11:04:20
Ah right I see, we anticipate the confusion about
Manish Jethani
2018/07/12 11:11:12
Yup.
| |
| 805 return new InvalidFilter(origText, "filter_unknown_option"); | |
| 806 rewrite = value; | |
| 807 break; | |
| 808 default: | |
| 809 return new InvalidFilter(origText, "filter_unknown_option"); | |
| 810 } | |
| 773 } | 811 } |
| 774 else if (option == "MATCH_CASE") | |
| 775 matchCase = true; | |
| 776 else if (option == "~MATCH_CASE") | |
| 777 matchCase = false; | |
| 778 else if (option == "DOMAIN" && value != null) | |
| 779 domains = value.toUpperCase(); | |
| 780 else if (option == "THIRD_PARTY") | |
| 781 thirdParty = true; | |
| 782 else if (option == "~THIRD_PARTY") | |
| 783 thirdParty = false; | |
| 784 else if (option == "COLLAPSE") | |
| 785 collapse = true; | |
| 786 else if (option == "~COLLAPSE") | |
| 787 collapse = false; | |
| 788 else if (option == "SITEKEY" && value != null) | |
| 789 sitekeys = value.toUpperCase(); | |
| 790 else if (option == "REWRITE" && value != null) | |
|
kzar
2018/06/07 13:21:56
Come to think of it, why don't we just allow the $
Manish Jethani
2018/06/25 13:13:44
We could do that but it would be weird to allow $r
| |
| 791 rewrite = value; | |
| 792 else | |
| 793 return new InvalidFilter(origText, "filter_unknown_option"); | |
| 794 } | 812 } |
| 795 } | 813 } |
| 796 | 814 |
| 797 // For security reasons, never match $rewrite filters | 815 // For security reasons, never match $rewrite filters |
| 798 // against requests that might load any code to be executed. | 816 // against requests that might load any code to be executed. |
| 799 if (rewrite != null) | 817 if (rewrite != null) |
| 800 { | 818 { |
| 801 if (contentType == null) | 819 if (contentType == null) |
| 802 ({contentType} = RegExpFilter.prototype); | 820 ({contentType} = RegExpFilter.prototype); |
| 803 contentType &= ~(RegExpFilter.typeMap.SCRIPT | | 821 contentType &= ~(RegExpFilter.typeMap.SCRIPT | |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 859 // shouldn't be there by default | 877 // shouldn't be there by default |
| 860 RegExpFilter.prototype.contentType &= ~(RegExpFilter.typeMap.CSP | | 878 RegExpFilter.prototype.contentType &= ~(RegExpFilter.typeMap.CSP | |
| 861 RegExpFilter.typeMap.DOCUMENT | | 879 RegExpFilter.typeMap.DOCUMENT | |
| 862 RegExpFilter.typeMap.ELEMHIDE | | 880 RegExpFilter.typeMap.ELEMHIDE | |
| 863 RegExpFilter.typeMap.POPUP | | 881 RegExpFilter.typeMap.POPUP | |
| 864 RegExpFilter.typeMap.GENERICHIDE | | 882 RegExpFilter.typeMap.GENERICHIDE | |
| 865 RegExpFilter.typeMap.GENERICBLOCK); | 883 RegExpFilter.typeMap.GENERICBLOCK); |
| 866 | 884 |
| 867 /** | 885 /** |
| 868 * Class for blocking filters | 886 * Class for blocking filters |
| 869 * @param {string} text see Filter() | 887 * @param {string} text see {@link Filter Filter()} |
| 870 * @param {string} regexpSource see RegExpFilter() | 888 * @param {string} regexpSource see {@link RegExpFilter RegExpFilter()} |
| 871 * @param {number} [contentType] see RegExpFilter() | 889 * @param {number} [contentType] see {@link RegExpFilter RegExpFilter()} |
| 872 * @param {boolean} [matchCase] see RegExpFilter() | 890 * @param {boolean} [matchCase] see {@link RegExpFilter RegExpFilter()} |
| 873 * @param {string} [domains] see RegExpFilter() | 891 * @param {string} [domains] see {@link RegExpFilter RegExpFilter()} |
| 874 * @param {boolean} [thirdParty] see RegExpFilter() | 892 * @param {boolean} [thirdParty] see {@link RegExpFilter RegExpFilter()} |
| 875 * @param {string} [sitekeys] see RegExpFilter() | 893 * @param {string} [sitekeys] see {@link RegExpFilter RegExpFilter()} |
| 876 * @param {boolean} [collapse] | 894 * @param {boolean} [collapse] |
| 877 * defines whether the filter should collapse blocked content, can be null | 895 * defines whether the filter should collapse blocked content, can be null |
| 878 * @param {string} [csp] | 896 * @param {string} [csp] |
| 879 * Content Security Policy to inject when the filter matches | 897 * Content Security Policy to inject when the filter matches |
| 880 * @param {?string} [rewrite] | 898 * @param {?string} [rewrite] |
| 881 * The (optional) rule specifying how to rewrite the URL. See | 899 * The (optional) rule specifying how to rewrite the URL. See |
| 882 * BlockingFilter.prototype.rewrite. | 900 * BlockingFilter.prototype.rewrite. |
| 883 * @constructor | 901 * @constructor |
| 884 * @augments RegExpFilter | 902 * @augments RegExpFilter |
| 885 */ | 903 */ |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 939 catch (e) | 957 catch (e) |
| 940 { | 958 { |
| 941 } | 959 } |
| 942 | 960 |
| 943 return url; | 961 return url; |
| 944 } | 962 } |
| 945 }); | 963 }); |
| 946 | 964 |
| 947 /** | 965 /** |
| 948 * Class for whitelist filters | 966 * Class for whitelist filters |
| 949 * @param {string} text see Filter() | 967 * @param {string} text see {@link Filter Filter()} |
| 950 * @param {string} regexpSource see RegExpFilter() | 968 * @param {string} regexpSource see {@link RegExpFilter RegExpFilter()} |
| 951 * @param {number} [contentType] see RegExpFilter() | 969 * @param {number} [contentType] see {@link RegExpFilter RegExpFilter()} |
| 952 * @param {boolean} [matchCase] see RegExpFilter() | 970 * @param {boolean} [matchCase] see {@link RegExpFilter RegExpFilter()} |
| 953 * @param {string} [domains] see RegExpFilter() | 971 * @param {string} [domains] see {@link RegExpFilter RegExpFilter()} |
| 954 * @param {boolean} [thirdParty] see RegExpFilter() | 972 * @param {boolean} [thirdParty] see {@link RegExpFilter RegExpFilter()} |
| 955 * @param {string} [sitekeys] see RegExpFilter() | 973 * @param {string} [sitekeys] see {@link RegExpFilter RegExpFilter()} |
| 956 * @constructor | 974 * @constructor |
| 957 * @augments RegExpFilter | 975 * @augments RegExpFilter |
| 958 */ | 976 */ |
| 959 function WhitelistFilter(text, regexpSource, contentType, matchCase, domains, | 977 function WhitelistFilter(text, regexpSource, contentType, matchCase, domains, |
| 960 thirdParty, sitekeys) | 978 thirdParty, sitekeys) |
| 961 { | 979 { |
| 962 RegExpFilter.call(this, text, regexpSource, contentType, matchCase, domains, | 980 RegExpFilter.call(this, text, regexpSource, contentType, matchCase, domains, |
| 963 thirdParty, sitekeys); | 981 thirdParty, sitekeys); |
| 964 } | 982 } |
| 965 exports.WhitelistFilter = WhitelistFilter; | 983 exports.WhitelistFilter = WhitelistFilter; |
| 966 | 984 |
| 967 WhitelistFilter.prototype = extend(RegExpFilter, { | 985 WhitelistFilter.prototype = extend(RegExpFilter, { |
| 968 type: "whitelist" | 986 type: "whitelist" |
| 969 }); | 987 }); |
| 970 | 988 |
| 971 /** | 989 /** |
| 972 * Base class for element hiding filters | 990 * Base class for element hiding filters |
| 973 * @param {string} text see Filter() | 991 * @param {string} text see {@link Filter Filter()} |
| 974 * @param {string} [domains] Host names or domains the filter should be | 992 * @param {string} [domains] Host names or domains the filter should be |
| 975 * restricted to | 993 * restricted to |
| 976 * @param {string} selector CSS selector for the HTML elements that should be | 994 * @param {string} selector CSS selector for the HTML elements that should be |
| 977 * hidden | 995 * hidden |
| 978 * @constructor | 996 * @constructor |
| 979 * @augments ActiveFilter | 997 * @augments ActiveFilter |
| 980 */ | 998 */ |
| 981 function ElemHideBase(text, domains, selector) | 999 function ElemHideBase(text, domains, selector) |
| 982 { | 1000 { |
| 983 ActiveFilter.call(this, text, domains || null); | 1001 ActiveFilter.call(this, text, domains || null); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1031 return new InvalidFilter(text, "filter_elemhideemulation_nodomain"); | 1049 return new InvalidFilter(text, "filter_elemhideemulation_nodomain"); |
| 1032 | 1050 |
| 1033 return new ElemHideEmulationFilter(text, domains, selector); | 1051 return new ElemHideEmulationFilter(text, domains, selector); |
| 1034 } | 1052 } |
| 1035 | 1053 |
| 1036 return new ElemHideFilter(text, domains, selector); | 1054 return new ElemHideFilter(text, domains, selector); |
| 1037 }; | 1055 }; |
| 1038 | 1056 |
| 1039 /** | 1057 /** |
| 1040 * Class for element hiding filters | 1058 * Class for element hiding filters |
| 1041 * @param {string} text see Filter() | 1059 * @param {string} text see {@link Filter Filter()} |
| 1042 * @param {string} [domains] see ElemHideBase() | 1060 * @param {string} [domains] see {@link ElemHideBase ElemHideBase()} |
| 1043 * @param {string} selector see ElemHideBase() | 1061 * @param {string} selector see {@link ElemHideBase ElemHideBase()} |
| 1044 * @constructor | 1062 * @constructor |
| 1045 * @augments ElemHideBase | 1063 * @augments ElemHideBase |
| 1046 */ | 1064 */ |
| 1047 function ElemHideFilter(text, domains, selector) | 1065 function ElemHideFilter(text, domains, selector) |
| 1048 { | 1066 { |
| 1049 ElemHideBase.call(this, text, domains, selector); | 1067 ElemHideBase.call(this, text, domains, selector); |
| 1050 } | 1068 } |
| 1051 exports.ElemHideFilter = ElemHideFilter; | 1069 exports.ElemHideFilter = ElemHideFilter; |
| 1052 | 1070 |
| 1053 ElemHideFilter.prototype = extend(ElemHideBase, { | 1071 ElemHideFilter.prototype = extend(ElemHideBase, { |
| 1054 type: "elemhide" | 1072 type: "elemhide" |
| 1055 }); | 1073 }); |
| 1056 | 1074 |
| 1057 /** | 1075 /** |
| 1058 * Class for element hiding exceptions | 1076 * Class for element hiding exceptions |
| 1059 * @param {string} text see Filter() | 1077 * @param {string} text see {@link Filter Filter()} |
| 1060 * @param {string} [domains] see ElemHideBase() | 1078 * @param {string} [domains] see {@link ElemHideBase ElemHideBase()} |
| 1061 * @param {string} selector see ElemHideBase() | 1079 * @param {string} selector see {@link ElemHideBase ElemHideBase()} |
| 1062 * @constructor | 1080 * @constructor |
| 1063 * @augments ElemHideBase | 1081 * @augments ElemHideBase |
| 1064 */ | 1082 */ |
| 1065 function ElemHideException(text, domains, selector) | 1083 function ElemHideException(text, domains, selector) |
| 1066 { | 1084 { |
| 1067 ElemHideBase.call(this, text, domains, selector); | 1085 ElemHideBase.call(this, text, domains, selector); |
| 1068 } | 1086 } |
| 1069 exports.ElemHideException = ElemHideException; | 1087 exports.ElemHideException = ElemHideException; |
| 1070 | 1088 |
| 1071 ElemHideException.prototype = extend(ElemHideBase, { | 1089 ElemHideException.prototype = extend(ElemHideBase, { |
| 1072 type: "elemhideexception" | 1090 type: "elemhideexception" |
| 1073 }); | 1091 }); |
| 1074 | 1092 |
| 1075 /** | 1093 /** |
| 1076 * Class for element hiding emulation filters | 1094 * Class for element hiding emulation filters |
| 1077 * @param {string} text see Filter() | 1095 * @param {string} text see {@link Filter Filter()} |
| 1078 * @param {string} domains see ElemHideBase() | 1096 * @param {string} domains see {@link ElemHideBase ElemHideBase()} |
| 1079 * @param {string} selector see ElemHideBase() | 1097 * @param {string} selector see {@link ElemHideBase ElemHideBase()} |
| 1080 * @constructor | 1098 * @constructor |
| 1081 * @augments ElemHideBase | 1099 * @augments ElemHideBase |
| 1082 */ | 1100 */ |
| 1083 function ElemHideEmulationFilter(text, domains, selector) | 1101 function ElemHideEmulationFilter(text, domains, selector) |
| 1084 { | 1102 { |
| 1085 ElemHideBase.call(this, text, domains, selector); | 1103 ElemHideBase.call(this, text, domains, selector); |
| 1086 } | 1104 } |
| 1087 exports.ElemHideEmulationFilter = ElemHideEmulationFilter; | 1105 exports.ElemHideEmulationFilter = ElemHideEmulationFilter; |
| 1088 | 1106 |
| 1089 ElemHideEmulationFilter.prototype = extend(ElemHideBase, { | 1107 ElemHideEmulationFilter.prototype = extend(ElemHideBase, { |
| 1090 type: "elemhideemulation" | 1108 type: "elemhideemulation" |
| 1091 }); | 1109 }); |
| LEFT | RIGHT |