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

Side by Side Diff: lib/abp2blocklist.js

Issue 29467595: Issue 5325 - Add support for separator characters (Closed) Base URL: https://hg.adblockplus.org/abp2blocklist
Patch Set: Add special handling for separator at beginning Created June 19, 2017, 10:36 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/abp2blocklist.js » ('j') | test/abp2blocklist.js » ('J')
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-2017 eyeo GmbH 3 * Copyright (C) 2006-2017 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 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 break; 141 break;
142 } 142 }
143 143
144 switch (c) 144 switch (c)
145 { 145 {
146 case "*": 146 case "*":
147 if (regexp.length > 0 && i < lastIndex && text[i + 1] != "*") 147 if (regexp.length > 0 && i < lastIndex && text[i + 1] != "*")
148 regexp.push(".*"); 148 regexp.push(".*");
149 break; 149 break;
150 case "^": 150 case "^":
151 if (i < lastIndex) 151 let separator = "[^-_.%" + (justHostname ? "" : "A-Z") + "a-z0-9]";
kzar 2017/07/07 12:46:18 I don't understand the logic with justHostname her
kzar 2017/07/07 12:46:18 Like I mentioned in the issue shouldn't the period
Manish Jethani 2017/07/08 06:29:10 For filters like "example.co^" and "example.co^*^h
Manish Jethani 2017/07/08 06:29:10 I replied there as well. No, the period must not b
kzar 2017/07/10 12:39:56 Ah OK, thanks. Would you mind adding a comment to
kzar 2017/07/10 12:39:56 Acknowledged.
Manish Jethani 2017/07/11 17:10:33 Done. I've also made the code a bit more verbose
kzar 2017/07/12 09:16:31 Thanks, while a little verbose like you mention I
152 regexp.push("."); 152 if (i == 0)
Manish Jethani 2017/06/19 10:39:54 Support separators at the beginning of the filter
kzar 2017/07/07 12:46:18 Acknowledged.
153 regexp.push("^https?://(.*" + separator + ")?");
154 else if (i == lastIndex)
155 regexp.push("(" + separator + ".*)?$");
156 else
157 regexp.push(separator);
153 break; 158 break;
154 case "|": 159 case "|":
155 if (i == 0) 160 if (i == 0)
156 { 161 {
157 regexp.push("^"); 162 regexp.push("^");
158 break; 163 break;
159 } 164 }
160 if (i == lastIndex) 165 if (i == lastIndex)
161 { 166 {
162 regexp.push("$"); 167 regexp.push("$");
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after
539 { 544 {
540 convertFilterAddRules(rules, filter, "block", true, 545 convertFilterAddRules(rules, filter, "block", true,
541 requestFilterExceptionDomains); 546 requestFilterExceptionDomains);
542 } 547 }
543 548
544 for (let filter of this.requestExceptions) 549 for (let filter of this.requestExceptions)
545 convertFilterAddRules(rules, filter, "ignore-previous-rules", true); 550 convertFilterAddRules(rules, filter, "ignore-previous-rules", true);
546 551
547 return rules.filter(rule => !hasNonASCI(rule)); 552 return rules.filter(rule => !hasNonASCI(rule));
548 }; 553 };
OLDNEW
« no previous file with comments | « no previous file | test/abp2blocklist.js » ('j') | test/abp2blocklist.js » ('J')

Powered by Google App Engine
This is Rietveld