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

Side by Side Diff: lib/abp2blocklist.js

Issue 29468579: Issue 5332 - Do not filter out rules containing non-ASCII characters (Closed) Base URL: https://hg.adblockplus.org/abp2blocklist
Patch Set: Created June 19, 2017, 4:09 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 | « 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 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 filter.contentType & typeMap.SUBDOCUMENT) 318 filter.contentType & typeMap.SUBDOCUMENT)
319 { 319 {
320 trigger["unless-top-url"] = [trigger["url-filter"]]; 320 trigger["unless-top-url"] = [trigger["url-filter"]];
321 if (trigger["url-filter-is-case-sensitive"]) 321 if (trigger["url-filter-is-case-sensitive"])
322 trigger["top-url-filter-is-case-sensitive"] = true; 322 trigger["top-url-filter-is-case-sensitive"] = true;
323 } 323 }
324 324
325 rules.push({trigger: trigger, action: {type: action}}); 325 rules.push({trigger: trigger, action: {type: action}});
326 } 326 }
327 327
328 function hasNonASCI(obj)
329 {
330 if (typeof obj == "string")
331 {
332 if (/[^\x00-\x7F]/.test(obj))
333 return true;
334 }
335
336 if (typeof obj == "object")
337 {
338 if (obj instanceof Array)
339 for (let item of obj)
340 if (hasNonASCI(item))
341 return true;
342
343 let names = Object.getOwnPropertyNames(obj);
344 for (let name of names)
345 if (hasNonASCI(obj[name]))
346 return true;
347 }
348
349 return false;
350 }
351
352 function convertIDSelectorsToAttributeSelectors(selector) 328 function convertIDSelectorsToAttributeSelectors(selector)
353 { 329 {
354 // First we figure out where all the IDs are 330 // First we figure out where all the IDs are
355 let sep = ""; 331 let sep = "";
356 let start = null; 332 let start = null;
357 let positions = []; 333 let positions = [];
358 for (let i = 0; i < selector.length; i++) 334 for (let i = 0; i < selector.length; i++)
359 { 335 {
360 let chr = selector[i]; 336 let chr = selector[i];
361 337
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
537 513
538 for (let filter of this.requestFilters) 514 for (let filter of this.requestFilters)
539 { 515 {
540 convertFilterAddRules(rules, filter, "block", true, 516 convertFilterAddRules(rules, filter, "block", true,
541 requestFilterExceptionDomains); 517 requestFilterExceptionDomains);
542 } 518 }
543 519
544 for (let filter of this.requestExceptions) 520 for (let filter of this.requestExceptions)
545 convertFilterAddRules(rules, filter, "ignore-previous-rules", true); 521 convertFilterAddRules(rules, filter, "ignore-previous-rules", true);
546 522
547 return rules.filter(rule => !hasNonASCI(rule)); 523 return rules;
548 }; 524 };
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