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

Side by Side Diff: lib/filterClasses.js

Issue 5840485868371968: Issue 616 - Add $generichide + $genericblock filter options and enforce them. (Closed)
Patch Set: Removed duplicate comment Created Sept. 22, 2015, 1:15 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
« no previous file with comments | « lib/contentPolicy.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-2015 Eyeo GmbH 3 * Copyright (C) 2006-2015 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 460 matching lines...) Expand 10 before | Expand all | Expand 10 after
471 docDomain = docDomain.toUpperCase(); 471 docDomain = docDomain.toUpperCase();
472 472
473 for (let domain in this.domains) 473 for (let domain in this.domains)
474 if (this.domains[domain] && domain != docDomain && (domain.length <= docDo main.length || domain.indexOf("." + docDomain) != domain.length - docDomain.leng th - 1)) 474 if (this.domains[domain] && domain != docDomain && (domain.length <= docDo main.length || domain.indexOf("." + docDomain) != domain.length - docDomain.leng th - 1))
475 return false; 475 return false;
476 476
477 return true; 477 return true;
478 }, 478 },
479 479
480 /** 480 /**
481 * Checks whether this filter is generic or specific
482 */
483 isGeneric: function() /**Boolean*/
484 {
485 return (!(this.sitekeys && this.sitekeys.length) &&
Felix Dahlke 2015/09/28 08:28:45 Nit: Superfluous parentheses around the expression
kzar 2015/09/28 10:16:12 Done.
486 (!this.domains || this.domains[""]));
487 },
488
489 /**
481 * See Filter.serialize() 490 * See Filter.serialize()
482 */ 491 */
483 serialize: function(buffer) 492 serialize: function(buffer)
484 { 493 {
485 if (this._disabled || this._hitCount || this._lastHit) 494 if (this._disabled || this._hitCount || this._lastHit)
486 { 495 {
487 Filter.prototype.serialize.call(this, buffer); 496 Filter.prototype.serialize.call(this, buffer);
488 if (this._disabled) 497 if (this._disabled)
489 buffer.push("disabled=true"); 498 buffer.push("disabled=true");
490 if (this._hitCount) 499 if (this._hitCount)
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
747 PING: 1, 756 PING: 1,
748 XMLHTTPREQUEST: 2048, 757 XMLHTTPREQUEST: 2048,
749 OBJECT_SUBREQUEST: 4096, 758 OBJECT_SUBREQUEST: 4096,
750 DTD: 1, 759 DTD: 1,
751 MEDIA: 16384, 760 MEDIA: 16384,
752 FONT: 32768, 761 FONT: 32768,
753 762
754 BACKGROUND: 4, // Backwards compat, same as IMAGE 763 BACKGROUND: 4, // Backwards compat, same as IMAGE
755 764
756 POPUP: 0x10000000, 765 POPUP: 0x10000000,
757 ELEMHIDE: 0x40000000 766 GENERICBLOCK: 0x20000000,
767 ELEMHIDE: 0x40000000,
768 GENERICHIDE: 0x80000000
758 }; 769 };
759 770
760 // DOCUMENT, ELEMHIDE, POPUP options shouldn't be there by default 771 // DOCUMENT, ELEMHIDE, POPUP, GENERICHIDE and GENERICBLOCK options shouldn't
761 RegExpFilter.prototype.contentType &= ~(RegExpFilter.typeMap.DOCUMENT | RegExpFi lter.typeMap.ELEMHIDE | RegExpFilter.typeMap.POPUP); 772 // be there by default
773 RegExpFilter.prototype.contentType &= ~(RegExpFilter.typeMap.DOCUMENT |
774 RegExpFilter.typeMap.ELEMHIDE |
775 RegExpFilter.typeMap.POPUP |
776 RegExpFilter.typeMap.GENERICHIDE |
777 RegExpFilter.typeMap.GENERICBLOCK);
762 778
763 /** 779 /**
764 * Class for blocking filters 780 * Class for blocking filters
765 * @param {String} text see Filter() 781 * @param {String} text see Filter()
766 * @param {String} regexpSource see RegExpFilter() 782 * @param {String} regexpSource see RegExpFilter()
767 * @param {Number} contentType see RegExpFilter() 783 * @param {Number} contentType see RegExpFilter()
768 * @param {Boolean} matchCase see RegExpFilter() 784 * @param {Boolean} matchCase see RegExpFilter()
769 * @param {String} domains see RegExpFilter() 785 * @param {String} domains see RegExpFilter()
770 * @param {Boolean} thirdParty see RegExpFilter() 786 * @param {Boolean} thirdParty see RegExpFilter()
771 * @param {String} sitekeys see RegExpFilter() 787 * @param {String} sitekeys see RegExpFilter()
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
1021 // several times on Safari, due to WebKit bug 132872 1037 // several times on Safari, due to WebKit bug 132872
1022 let prop = Object.getOwnPropertyDescriptor(this, "regexpString"); 1038 let prop = Object.getOwnPropertyDescriptor(this, "regexpString");
1023 if (prop) 1039 if (prop)
1024 return prop.value; 1040 return prop.value;
1025 1041
1026 let regexp = Filter.toRegExp(this.regexpSource); 1042 let regexp = Filter.toRegExp(this.regexpSource);
1027 Object.defineProperty(this, "regexpString", {value: regexp}); 1043 Object.defineProperty(this, "regexpString", {value: regexp});
1028 return regexp; 1044 return regexp;
1029 } 1045 }
1030 }; 1046 };
OLDNEW
« no previous file with comments | « lib/contentPolicy.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld