| OLD | NEW |
| 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 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 break; | 163 break; |
| 164 } | 164 } |
| 165 | 165 |
| 166 switch (c) | 166 switch (c) |
| 167 { | 167 { |
| 168 case "*": | 168 case "*": |
| 169 if (regexp.length > 0 && i < lastIndex && characters[i + 1] != "*") | 169 if (regexp.length > 0 && i < lastIndex && characters[i + 1] != "*") |
| 170 regexp.push(".*"); | 170 regexp.push(".*"); |
| 171 break; | 171 break; |
| 172 case "^": | 172 case "^": |
| 173 if (i < lastIndex) | 173 let alphabet = "a-z"; |
| 174 regexp.push("."); | 174 // If justHostname is true and we've encountered a "^", it means we're |
| 175 // still in the hostname part of the URL. Since hostnames are always |
| 176 // lower case (Punycode), there's no need to include "A-Z" in the |
| 177 // pattern. Further, subsequent code may lower-case the entire regular |
| 178 // expression (if the URL contains only the hostname part), leaving us |
| 179 // with "a-za-z", which would be redundant. |
| 180 if (!justHostname) |
| 181 alphabet = "A-Z" + alphabet; |
| 182 let digits = "0-9"; |
| 183 // Note that the "-" must appear first here in order to retain its |
| 184 // literal meaning within the brackets. |
| 185 let specialCharacters = "-_.%"; |
| 186 let separator = "[^" + specialCharacters + alphabet + digits + "]"; |
| 187 if (i == 0) |
| 188 regexp.push("^https?://(.*" + separator + ")?"); |
| 189 else if (i == lastIndex) |
| 190 regexp.push("(" + separator + ".*)?$"); |
| 191 else |
| 192 regexp.push(separator); |
| 175 break; | 193 break; |
| 176 case "|": | 194 case "|": |
| 177 if (i == 0) | 195 if (i == 0) |
| 178 { | 196 { |
| 179 regexp.push("^"); | 197 regexp.push("^"); |
| 180 break; | 198 break; |
| 181 } | 199 } |
| 182 if (i == lastIndex) | 200 if (i == lastIndex) |
| 183 { | 201 { |
| 184 regexp.push("$"); | 202 regexp.push("$"); |
| (...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 579 { | 597 { |
| 580 convertFilterAddRules(rules, filter, "block", true, | 598 convertFilterAddRules(rules, filter, "block", true, |
| 581 requestFilterExceptionDomains); | 599 requestFilterExceptionDomains); |
| 582 } | 600 } |
| 583 | 601 |
| 584 for (let filter of this.requestExceptions) | 602 for (let filter of this.requestExceptions) |
| 585 convertFilterAddRules(rules, filter, "ignore-previous-rules", true); | 603 convertFilterAddRules(rules, filter, "ignore-previous-rules", true); |
| 586 | 604 |
| 587 return rules; | 605 return rules; |
| 588 }; | 606 }; |
| OLD | NEW |