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

Side by Side Diff: lib/filterClasses.js

Issue 29801609: Issue 6733 - Allow empty values in filter options (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Created June 7, 2018, 11:51 a.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 | « no previous file | test/filterClasses.js » ('j') | 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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 Filter.elemhideRegExp = /^([^/*|@"!]*?)#([@?])?#(.+)$/; 90 Filter.elemhideRegExp = /^([^/*|@"!]*?)#([@?])?#(.+)$/;
91 /** 91 /**
92 * Regular expression that RegExp filters specified as RegExps should match 92 * Regular expression that RegExp filters specified as RegExps should match
93 * @type {RegExp} 93 * @type {RegExp}
94 */ 94 */
95 Filter.regexpRegExp = /^(@@)?\/.*\/(?:\$~?[\w-]+(?:=[^,\s]+)?(?:,~?[\w-]+(?:=[^, \s]+)?)*)?$/; 95 Filter.regexpRegExp = /^(@@)?\/.*\/(?:\$~?[\w-]+(?:=[^,\s]+)?(?:,~?[\w-]+(?:=[^, \s]+)?)*)?$/;
96 /** 96 /**
97 * Regular expression that options on a RegExp filter should match 97 * Regular expression that options on a RegExp filter should match
98 * @type {RegExp} 98 * @type {RegExp}
99 */ 99 */
100 Filter.optionsRegExp = /\$(~?[\w-]+(?:=[^,]+)?(?:,~?[\w-]+(?:=[^,]+)?)*)$/; 100 Filter.optionsRegExp = /\$(~?[\w-]+(?:=[^,]*)?(?:,~?[\w-]+(?:=[^,]*)?)*)$/;
101 /** 101 /**
102 * Regular expression that matches an invalid Content Security Policy 102 * Regular expression that matches an invalid Content Security Policy
103 * @type {RegExp} 103 * @type {RegExp}
104 */ 104 */
105 Filter.invalidCSPRegExp = /(;|^) ?(base-uri|referrer|report-to|report-uri|upgrad e-insecure-requests)\b/i; 105 Filter.invalidCSPRegExp = /(;|^) ?(base-uri|referrer|report-to|report-uri|upgrad e-insecure-requests)\b/i;
106 106
107 /** 107 /**
108 * Creates a filter of correct type from its text representation - does the 108 * Creates a filter of correct type from its text representation - does the
109 * basic parsing and calls the right constructor then. 109 * basic parsing and calls the right constructor then.
110 * 110 *
(...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 != null) 592 if (sitekeys)
kzar 2018/06/07 13:21:56 How come you remove this check here, but add it fo
Manish Jethani 2018/06/25 13:13:44 There's an explanation, but no longer relevant.
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");
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
768 else if (option[0] == "~" && option.substr(1) in RegExpFilter.typeMap) 768 else if (option[0] == "~" && option.substr(1) in RegExpFilter.typeMap)
769 { 769 {
770 if (contentType == null) 770 if (contentType == null)
771 ({contentType} = RegExpFilter.prototype); 771 ({contentType} = RegExpFilter.prototype);
772 contentType &= ~RegExpFilter.typeMap[option.substr(1)]; 772 contentType &= ~RegExpFilter.typeMap[option.substr(1)];
773 } 773 }
774 else if (option == "MATCH_CASE") 774 else if (option == "MATCH_CASE")
775 matchCase = true; 775 matchCase = true;
776 else if (option == "~MATCH_CASE") 776 else if (option == "~MATCH_CASE")
777 matchCase = false; 777 matchCase = false;
778 else if (option == "DOMAIN" && value) 778 else if (option == "DOMAIN" && value != null)
779 domains = value.toUpperCase(); 779 domains = value.toUpperCase();
780 else if (option == "THIRD_PARTY") 780 else if (option == "THIRD_PARTY")
781 thirdParty = true; 781 thirdParty = true;
782 else if (option == "~THIRD_PARTY") 782 else if (option == "~THIRD_PARTY")
783 thirdParty = false; 783 thirdParty = false;
784 else if (option == "COLLAPSE") 784 else if (option == "COLLAPSE")
785 collapse = true; 785 collapse = true;
786 else if (option == "~COLLAPSE") 786 else if (option == "~COLLAPSE")
787 collapse = false; 787 collapse = false;
788 else if (option == "SITEKEY" && value) 788 else if (option == "SITEKEY" && value != null)
789 sitekeys = value.toUpperCase(); 789 sitekeys = value.toUpperCase();
790 else if (option == "REWRITE" && value) 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; 791 rewrite = value;
792 else 792 else
793 return new InvalidFilter(origText, "filter_unknown_option"); 793 return new InvalidFilter(origText, "filter_unknown_option");
794 } 794 }
795 } 795 }
796 796
797 // For security reasons, never match $rewrite filters 797 // For security reasons, never match $rewrite filters
798 // against requests that might load any code to be executed. 798 // against requests that might load any code to be executed.
799 if (rewrite != null) 799 if (rewrite != null)
800 { 800 {
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
1082 */ 1082 */
1083 function ElemHideEmulationFilter(text, domains, selector) 1083 function ElemHideEmulationFilter(text, domains, selector)
1084 { 1084 {
1085 ElemHideBase.call(this, text, domains, selector); 1085 ElemHideBase.call(this, text, domains, selector);
1086 } 1086 }
1087 exports.ElemHideEmulationFilter = ElemHideEmulationFilter; 1087 exports.ElemHideEmulationFilter = ElemHideEmulationFilter;
1088 1088
1089 ElemHideEmulationFilter.prototype = extend(ElemHideBase, { 1089 ElemHideEmulationFilter.prototype = extend(ElemHideBase, {
1090 type: "elemhideemulation" 1090 type: "elemhideemulation"
1091 }); 1091 });
OLDNEW
« no previous file with comments | « no previous file | test/filterClasses.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld