| 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-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 * |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 | 65 |
| 66 /** | 66 /** |
| 67 * Returns a detailed translated error message. | 67 * Returns a detailed translated error message. |
| 68 * | 68 * |
| 69 * @return {string} | 69 * @return {string} |
| 70 */ | 70 */ |
| 71 toString() | 71 toString() |
| 72 { | 72 { |
| 73 let message; | 73 let message; |
| 74 if (this.reason) | 74 if (this.reason) |
| 75 { | |
| 76 message = Utils.getString(this.reason); | 75 message = Utils.getString(this.reason); |
| 77 } | |
| 78 else | 76 else |
| 79 { | 77 { |
| 80 message = ext.i18n.getMessage( | 78 message = ext.i18n.getMessage( |
| 81 this.type.replace(/-/g, "_"), | 79 this.type.replace(/-/g, "_"), |
| 82 "selector" in this ? "'" + this.selector + "'" : null | 80 "selector" in this ? "'" + this.selector + "'" : null |
| 83 ); | 81 ); |
| 84 } | 82 } |
| 85 | 83 |
| 86 if (this.lineno) | 84 if (this.lineno) |
| 87 { | 85 { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 107 } | 105 } |
| 108 catch (e) | 106 catch (e) |
| 109 { | 107 { |
| 110 return false; | 108 return false; |
| 111 } | 109 } |
| 112 return true; | 110 return true; |
| 113 } | 111 } |
| 114 | 112 |
| 115 /** | 113 /** |
| 116 * @typedef ParsedFilter | 114 * @typedef ParsedFilter |
| 117 * @property {?Filter} [filter] The parsed filter if it is valid. | 115 * @property {?Filter} [filter] |
| 118 * Or null if the given string is empty. | 116 * The parsed filter if it is valid. Or null if the given string is empty. |
| 119 * @property {FilterParsingError} [error] | 117 * @property {FilterParsingError} [error] |
| 120 * See {@link module:filterValidation~FilterParsingError FilterParsingError} | 118 * See {@link module:filterValidation~FilterParsingError FilterParsingError} |
| 121 */ | 119 */ |
| 122 | 120 |
| 123 let parseFilter = | 121 let parseFilter = |
| 124 /** | 122 /** |
| 125 * Parses and validates a filter given by the user. | 123 * Parses and validates a filter given by the user. |
| 126 * | 124 * |
| 127 * @param {string} text | 125 * @param {string} text |
| 128 * @return {ParsedFilter} | 126 * @return {ParsedFilter} |
| 129 */ | 127 */ |
| 130 exports.parseFilter = text => | 128 exports.parseFilter = text => |
| (...skipping 18 matching lines...) Expand all Loading... |
| 149 return {error: new FilterParsingError("invalid-css-selector", | 147 return {error: new FilterParsingError("invalid-css-selector", |
| 150 {selector: filter.selector})}; | 148 {selector: filter.selector})}; |
| 151 } | 149 } |
| 152 } | 150 } |
| 153 | 151 |
| 154 return {filter}; | 152 return {filter}; |
| 155 }; | 153 }; |
| 156 | 154 |
| 157 /** | 155 /** |
| 158 * @typedef ParsedFilters | 156 * @typedef ParsedFilters |
| 159 * @property {Filter[]} filters The parsed result without invalid filters. | 157 * @property {Filter[]} filters |
| 158 * The parsed result without invalid filters. |
| 160 * @property {FilterParsingError[]} errors | 159 * @property {FilterParsingError[]} errors |
| 161 * See {@link module:filterValidation~FilterParsingError FilterParsingError} | 160 * See {@link module:filterValidation~FilterParsingError FilterParsingError} |
| 162 */ | 161 */ |
| 163 | 162 |
| 164 /** | 163 /** |
| 165 * Parses and validates a newline-separated list of filters given by the user. | 164 * Parses and validates a newline-separated list of filters given by the user. |
| 166 * | 165 * |
| 167 * @param {string} text | 166 * @param {string} text |
| 168 * @return {ParsedFilters} | 167 * @return {ParsedFilters} |
| 169 */ | 168 */ |
| 170 exports.parseFilters = text => | 169 exports.parseFilters = text => |
| 171 { | 170 { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 182 | 181 |
| 183 if (error) | 182 if (error) |
| 184 { | 183 { |
| 185 error.lineno = i + 1; | 184 error.lineno = i + 1; |
| 186 errors.push(error); | 185 errors.push(error); |
| 187 } | 186 } |
| 188 } | 187 } |
| 189 | 188 |
| 190 return {filters, errors}; | 189 return {filters, errors}; |
| 191 }; | 190 }; |
| LEFT | RIGHT |