Left: | ||
Right: |
LEFT | RIGHT |
---|---|
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-2016 Eyeo GmbH | 3 * Copyright (C) 2006-2016 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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
58 let included = []; | 58 let included = []; |
59 let excluded = []; | 59 let excluded = []; |
60 let rules = []; | 60 let rules = []; |
61 | 61 |
62 parseDomains(filter.domains, included, excluded); | 62 parseDomains(filter.domains, included, excluded); |
63 | 63 |
64 if (excluded.length == 0 && !(filter.selector in elemhideSelectorExceptions)) | 64 if (excluded.length == 0 && !(filter.selector in elemhideSelectorExceptions)) |
65 return {matchDomains: included.map(matchDomain), selector: filter.selector}; | 65 return {matchDomains: included.map(matchDomain), selector: filter.selector}; |
66 } | 66 } |
67 | 67 |
68 // Convert the "regexpSource" part of a filter's text to a regular expression, | 68 /** |
Sebastian Noack
2016/02/25 02:28:35
Sorry for commenting after LGTM. Just one more nit
kzar
2016/02/25 15:22:28
Done.
| |
69 // also deciding if the expression can safely be converted to and matched as | 69 * Convert the given filter "regexpSource" string into a regular expression. |
70 // lowercase. | 70 * (Also deciding if the regular expression can be safely converted to and |
71 * matched as lower case or not.) | |
72 * | |
73 * @param {string} text regexpSource property of a filter | |
74 * @returns {object} An object containing a regular expression string and a bool | |
75 * indicating if the filter can be safely matched as lower | |
76 * case: {regexp: "...", caseSenstive: true/false} | |
77 */ | |
71 function toRegExp(text) | 78 function toRegExp(text) |
72 { | 79 { |
73 let result = []; | 80 let result = []; |
74 let lastIndex = text.length - 1; | 81 let lastIndex = text.length - 1; |
75 let hostnameStarted = false; | 82 let hostnameStarted = false; |
76 let hostnameFinished = false; | 83 let hostnameFinished = false; |
77 let caseSensitive = false; | 84 let caseSensitive = false; |
78 | 85 |
79 for (let i = 0; i < text.length; i++) | 86 for (let i = 0; i < text.length; i++) |
80 { | 87 { |
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
420 | 427 |
421 for (let filter of this.elemhideExceptions) | 428 for (let filter of this.elemhideExceptions) |
422 addRule(convertFilter(filter, "ignore-previous-rules", false)); | 429 addRule(convertFilter(filter, "ignore-previous-rules", false)); |
423 for (let filter of this.requestFilters) | 430 for (let filter of this.requestFilters) |
424 addRule(convertFilter(filter, "block", true)); | 431 addRule(convertFilter(filter, "block", true)); |
425 for (let filter of this.requestExceptions) | 432 for (let filter of this.requestExceptions) |
426 addRule(convertFilter(filter, "ignore-previous-rules", true)); | 433 addRule(convertFilter(filter, "ignore-previous-rules", true)); |
427 | 434 |
428 return rules; | 435 return rules; |
429 }; | 436 }; |
LEFT | RIGHT |