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

Delta Between Two Patch Sets: lib/filterClasses.js

Issue 29800595: Issue 6735 - Store domains in lower case (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Left Patch Set: Update logic to minimize code Created June 8, 2018, 4:53 a.m.
Right Patch Set: Disallow missing values in domain, sitekey, and rewrite Created June 8, 2018, 2:16 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « lib/elemHide.js ('k') | test/filterClasses.js » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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 738 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 758
759 let inverse = option[0] == "~"; 759 let inverse = option[0] == "~";
Manish Jethani 2018/06/08 05:00:41 I'm just calling it "inverse" because "option" is
kzar 2018/06/08 09:30:32 Acknowledged.
760 if (inverse) 760 if (inverse)
761 option = option.substr(1); 761 option = option.substr(1);
762 762
763 let type = RegExpFilter.typeMap[option.replace(/-/, "_").toUpperCase()]; 763 let type = RegExpFilter.typeMap[option.replace(/-/, "_").toUpperCase()];
Manish Jethani 2018/06/08 05:00:41 Lookup happens only once in the RegExpFilter.typeM
kzar 2018/06/08 09:30:32 Nice.
764 if (type) 764 if (type)
765 { 765 {
766 if (inverse) 766 if (inverse)
767 { 767 {
768 if (contentType == null) 768 if (contentType == null)
769 ({contentType} = RegExpFilter.prototype); 769 ({contentType} = RegExpFilter.prototype);
770 contentType &= ~type; 770 contentType &= ~type;
771 } 771 }
772 else 772 else
773 { 773 {
774 contentType |= type; 774 contentType |= type;
775 775
776 if (type == RegExpFilter.typeMap.CSP && value) 776 if (type == RegExpFilter.typeMap.CSP && value)
Manish Jethani 2018/06/08 05:00:41 Integer comparison.
Manish Jethani 2018/06/08 14:21:14 By the way in the case of csp we quietly ignore th
kzar 2018/06/15 10:44:03 Yea, agreed. By the way Rosie is reimplementing th
777 csp = value; 777 csp = value;
778 } 778 }
779 } 779 }
780 else 780 else
781 { 781 {
782 switch (option.toLowerCase()) 782 switch (option.toLowerCase())
Manish Jethani 2018/06/08 05:00:41 Only lowercase if we get this far. switch is clea
783 { 783 {
784 case "match-case": 784 case "match-case":
785 matchCase = !inverse; 785 matchCase = !inverse;
Manish Jethani 2018/06/08 05:00:41 !inverse
kzar 2018/06/08 09:30:31 (Heh, it does make you wonder if storing !inverse
786 break; 786 break;
787 case "domain": 787 case "domain":
788 if (value) 788 if (!value)
Manish Jethani 2018/06/08 05:00:41 Note: This has a good side effect. Previously foo$
kzar 2018/06/08 09:30:32 Seems reasonable to me, but I wonder if this was i
sergei 2018/06/08 13:28:11 Formally, if the option is present and there are n
Manish Jethani 2018/06/08 14:12:39 For known options that must have a value but none
789 domains = value.toLowerCase(); 789 return new InvalidFilter(origText, "filter_unknown_option");
790 domains = value.toLowerCase();
790 break; 791 break;
791 case "third-party": 792 case "third-party":
792 thirdParty = !inverse; 793 thirdParty = !inverse;
793 break; 794 break;
794 case "collapse": 795 case "collapse":
795 collapse = !inverse; 796 collapse = !inverse;
796 break; 797 break;
797 case "sitekey": 798 case "sitekey":
798 if (value) 799 if (!value)
Manish Jethani 2018/06/08 14:19:42 There's a bit of code repetition here but I'm OK w
kzar 2018/06/15 10:44:03 Yea, I think it's fine.
799 sitekeys = value.toUpperCase(); 800 return new InvalidFilter(origText, "filter_unknown_option");
801 sitekeys = value.toUpperCase();
800 break; 802 break;
801 case "rewrite": 803 case "rewrite":
802 if (value) 804 if (!value)
Manish Jethani 2018/06/08 05:00:41 Note that this also simplifies how we can accept t
kzar 2018/06/08 09:30:31 Acknowledged.
Manish Jethani 2018/06/08 14:19:42 Note that this will get updated for the rewrite op
803 rewrite = value; 805 return new InvalidFilter(origText, "filter_unknown_option");
806 rewrite = value;
804 break; 807 break;
805 default: 808 default:
806 return new InvalidFilter(origText, "filter_unknown_option"); 809 return new InvalidFilter(origText, "filter_unknown_option");
807 } 810 }
808 } 811 }
809 } 812 }
810 } 813 }
811 814
812 // For security reasons, never match $rewrite filters 815 // For security reasons, never match $rewrite filters
813 // against requests that might load any code to be executed. 816 // against requests that might load any code to be executed.
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
1097 */ 1100 */
1098 function ElemHideEmulationFilter(text, domains, selector) 1101 function ElemHideEmulationFilter(text, domains, selector)
1099 { 1102 {
1100 ElemHideBase.call(this, text, domains, selector); 1103 ElemHideBase.call(this, text, domains, selector);
1101 } 1104 }
1102 exports.ElemHideEmulationFilter = ElemHideEmulationFilter; 1105 exports.ElemHideEmulationFilter = ElemHideEmulationFilter;
1103 1106
1104 ElemHideEmulationFilter.prototype = extend(ElemHideBase, { 1107 ElemHideEmulationFilter.prototype = extend(ElemHideBase, {
1105 type: "elemhideemulation" 1108 type: "elemhideemulation"
1106 }); 1109 });
LEFTRIGHT

Powered by Google App Engine
This is Rietveld