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: Wrap long lines Created July 9, 2017, 10:48 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') | 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-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]";
152 regexp.push("."); 152 if (i == 0)
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') | no next file with comments »

Powered by Google App Engine
This is Rietveld