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

Side by Side Diff: lib/abp2blocklist.js

Issue 29426579: Noissue - Reimplement public suffix matching more efficiently (Closed) Base URL: https://hg.adblockplus.org/abp2blocklist
Patch Set: Created May 1, 2017, 6:48 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 | « README.md ('k') | lib/domain.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
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details. 12 * GNU General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU General Public License 14 * You should have received a copy of the GNU General Public License
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
16 */ 16 */
17 17
18 /** @module abp2blocklist */ 18 /** @module abp2blocklist */
19 19
20 "use strict"; 20 "use strict";
21 21
22 let filterClasses = require("filterClasses"); 22 let filterClasses = require("filterClasses");
23 let tldjs = require("tldjs");
24 let punycode = require("punycode"); 23 let punycode = require("punycode");
25 24
25 let {getBaseDomain} = require("./domain");
26
26 const selectorLimit = 5000; 27 const selectorLimit = 5000;
27 const typeMap = filterClasses.RegExpFilter.typeMap; 28 const typeMap = filterClasses.RegExpFilter.typeMap;
28 const whitelistableRequestTypes = (typeMap.IMAGE 29 const whitelistableRequestTypes = (typeMap.IMAGE
29 | typeMap.STYLESHEET 30 | typeMap.STYLESHEET
30 | typeMap.SCRIPT 31 | typeMap.SCRIPT
31 | typeMap.FONT 32 | typeMap.FONT
32 | typeMap.MEDIA 33 | typeMap.MEDIA
33 | typeMap.POPUP 34 | typeMap.POPUP
34 | typeMap.OBJECT 35 | typeMap.OBJECT
35 | typeMap.OBJECT_SUBREQUEST 36 | typeMap.OBJECT_SUBREQUEST
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 } 217 }
217 218
218 function addDomainPrefix(domains) 219 function addDomainPrefix(domains)
219 { 220 {
220 let result = []; 221 let result = [];
221 222
222 for (let domain of domains) 223 for (let domain of domains)
223 { 224 {
224 result.push(domain); 225 result.push(domain);
225 226
226 if (tldjs.getDomain(domain) == domain) 227 if (getBaseDomain(domain) == domain)
227 result.push("www." + domain); 228 result.push("www." + domain);
228 } 229 }
229 230
230 return result; 231 return result;
231 } 232 }
232 233
233 function convertFilterAddRules(rules, filter, action, withResourceTypes) 234 function convertFilterAddRules(rules, filter, action, withResourceTypes)
234 { 235 {
235 let parsed = parseFilterRegexpSource(filter.regexpSource); 236 let parsed = parseFilterRegexpSource(filter.regexpSource);
236 237
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
467 468
468 for (let filter of this.elemhideExceptions) 469 for (let filter of this.elemhideExceptions)
469 convertFilterAddRules(rules, filter, "ignore-previous-rules", false); 470 convertFilterAddRules(rules, filter, "ignore-previous-rules", false);
470 for (let filter of this.requestFilters) 471 for (let filter of this.requestFilters)
471 convertFilterAddRules(rules, filter, "block", true); 472 convertFilterAddRules(rules, filter, "block", true);
472 for (let filter of this.requestExceptions) 473 for (let filter of this.requestExceptions)
473 convertFilterAddRules(rules, filter, "ignore-previous-rules", true); 474 convertFilterAddRules(rules, filter, "ignore-previous-rules", true);
474 475
475 return rules.filter(rule => !hasNonASCI(rule)); 476 return rules.filter(rule => !hasNonASCI(rule));
476 }; 477 };
OLDNEW
« no previous file with comments | « README.md ('k') | lib/domain.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld