| 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-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 |
| 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 filterValidation */ | 18 /** @module filterValidation */ |
| 19 | 19 |
| 20 let {Filter, InvalidFilter, ElemHideBase} = require("filterClasses"); | 20 let {Filter, InvalidFilter, ElemHideBase} = require("filterClasses"); |
| 21 let {Utils} = require("utils"); |
| 21 | 22 |
| 22 /** | 23 /** |
| 23 * An error returned by | 24 * An error returned by |
| 24 * {@link module:filterValidation.parseFilter parseFilter()} or | 25 * {@link module:filterValidation.parseFilter parseFilter()} or |
| 25 * {@link module:filterValidation.parseFilters parseFilters()} | 26 * {@link module:filterValidation.parseFilters parseFilters()} |
| 26 * indicating that a given filter cannot be parsed, | 27 * indicating that a given filter cannot be parsed, |
| 27 * contains an invalid CSS selector or is a filter list header. | 28 * contains an invalid CSS selector or is a filter list header. |
| 28 * | 29 * |
| 29 * @constructor | 30 * @constructor |
| 30 */ | 31 */ |
| (...skipping 26 matching lines...) Expand all Loading... |
| 57 */ | 58 */ |
| 58 lineno: null, | 59 lineno: null, |
| 59 | 60 |
| 60 /** | 61 /** |
| 61 * Returns a detailed translated error message. | 62 * Returns a detailed translated error message. |
| 62 * | 63 * |
| 63 * @return {string} | 64 * @return {string} |
| 64 */ | 65 */ |
| 65 toString: function() | 66 toString: function() |
| 66 { | 67 { |
| 67 let message = this.reason || ext.i18n.getMessage( | 68 let message; |
| 68 this.type.replace(/-/g, "_"), | 69 if (this.reason) |
| 69 "selector" in this ? "'" + this.selector + "'" : null | 70 message = Utils.getString(this.reason); |
| 70 ); | 71 else |
| 72 message = ext.i18n.getMessage( |
| 73 this.type.replace(/-/g, "_"), |
| 74 "selector" in this ? "'" + this.selector + "'" : null |
| 75 ); |
| 71 | 76 |
| 72 if (this.lineno) | 77 if (this.lineno) |
| 73 message = ext.i18n.getMessage("line", this.lineno.toLocaleString()) + ": "
+ message; | 78 message = ext.i18n.getMessage("line", this.lineno.toLocaleString()) + ": "
+ message; |
| 74 | 79 |
| 75 return message; | 80 return message; |
| 76 } | 81 } |
| 77 }; | 82 }; |
| 78 | 83 |
| 79 function isValidCSSSelector(selector) | 84 function isValidCSSSelector(selector) |
| 80 { | 85 { |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 | 164 |
| 160 if (error) | 165 if (error) |
| 161 { | 166 { |
| 162 error.lineno = i + 1; | 167 error.lineno = i + 1; |
| 163 errors.push(error); | 168 errors.push(error); |
| 164 } | 169 } |
| 165 } | 170 } |
| 166 | 171 |
| 167 return {filters: filters, errors: errors}; | 172 return {filters: filters, errors: errors}; |
| 168 }; | 173 }; |
| OLD | NEW |