Bug 1157503 - NewTabUtils.extractSite should try-catch nsIURI.asciiHost. r=ttaubert,Mardak

This commit is contained in:
Drew Willcoxon 2015-04-23 15:52:16 -07:00
Родитель 1028ac00f3
Коммит aefa8b95be
1 изменённых файлов: 5 добавлений и 3 удалений

Просмотреть файл

@ -1311,15 +1311,17 @@ this.NewTabUtils = {
* @return The "site" string or null
*/
extractSite: function Links_extractSite(url) {
let uri;
let host;
try {
uri = Services.io.newURI(url, null, null);
// Note that nsIURI.asciiHost throws NS_ERROR_FAILURE for some types of
// URIs, including jar and moz-icon URIs.
host = Services.io.newURI(url, null, null).asciiHost;
} catch (ex) {
return null;
}
// Strip off common subdomains of the same site (e.g., www, load balancer)
return uri.asciiHost.replace(/^(m|mobile|www\d*)\./, "");
return host.replace(/^(m|mobile|www\d*)\./, "");
},
init: function NewTabUtils_init() {