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

Side by Side Diff: lib/notification.js

Issue 29329776: Issue 3254 - Fix exception when navigating to about:addons and similar pages (Closed)
Patch Set: Created Nov. 5, 2015, 7:26 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 | no next file » | no next file with comments »
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-2015 Eyeo GmbH 3 * Copyright (C) 2006-2015 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 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 if (shown instanceof Array && shown.indexOf(notification.id) != -1) 212 if (shown instanceof Array && shown.indexOf(notification.id) != -1)
213 continue; 213 continue;
214 if (Prefs.notifications_ignoredcategories.indexOf("*") != -1) 214 if (Prefs.notifications_ignoredcategories.indexOf("*") != -1)
215 continue; 215 continue;
216 } 216 }
217 217
218 if (typeof url === "string" || notification.urlFilters instanceof Array) 218 if (typeof url === "string" || notification.urlFilters instanceof Array)
219 { 219 {
220 if (Prefs.enabled && typeof url === "string" && notification.urlFilters instanceof Array) 220 if (Prefs.enabled && typeof url === "string" && notification.urlFilters instanceof Array)
221 { 221 {
222 let host = (typeof URL == "function" ? new URL(url).hostname : Utils.m akeURI(url).host); 222 let host;
223 if (typeof URL == "function")
224 host = new URL(url).hostname;
225 else
226 {
227 try
228 {
229 host = Services.io.newURI(url, null, null).host;
230 }
231 catch (e)
232 {
233 // Ignore, an exception is excepted for about: and similar schemes
Thomas Greiner 2015/11/10 17:54:19 Detail: I suppose you meant to write "expected" he
Wladimir Palant 2015/11/11 07:49:27 Yes, I fixed that before pushing.
234 host = "";
235 }
236 }
223 let exception = defaultMatcher.matchesAny(url, RegExpFilter.typeMap.DO CUMENT, host, false, null); 237 let exception = defaultMatcher.matchesAny(url, RegExpFilter.typeMap.DO CUMENT, host, false, null);
224 if (exception instanceof WhitelistFilter) 238 if (exception instanceof WhitelistFilter)
225 continue; 239 continue;
226 240
227 let matcher = new Matcher(); 241 let matcher = new Matcher();
228 for (let urlFilter of notification.urlFilters) 242 for (let urlFilter of notification.urlFilters)
229 matcher.add(Filter.fromText(urlFilter)); 243 matcher.add(Filter.fromText(urlFilter));
230 if (!matcher.matchesAny(url, RegExpFilter.typeMap.DOCUMENT, host, fals e, null)) 244 if (!matcher.matchesAny(url, RegExpFilter.typeMap.DOCUMENT, host, fals e, null))
231 continue; 245 continue;
232 } 246 }
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 Prefs.notifications_showui = true; 403 Prefs.notifications_showui = true;
390 } 404 }
391 else if (index != -1 && forceValue !== true) 405 else if (index != -1 && forceValue !== true)
392 categories.splice(index, 1); 406 categories.splice(index, 1);
393 407
394 // HACK: JSON values aren't saved unless they are assigned a different objec t. 408 // HACK: JSON values aren't saved unless they are assigned a different objec t.
395 Prefs.notifications_ignoredcategories = JSON.parse(JSON.stringify(categories )); 409 Prefs.notifications_ignoredcategories = JSON.parse(JSON.stringify(categories ));
396 } 410 }
397 }; 411 };
398 Notification.init(); 412 Notification.init();
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld