diff --git a/toolkit/content/widgets/tabbrowser.xml b/toolkit/content/widgets/tabbrowser.xml index 4cdeaa67783..410a9646fa3 100644 --- a/toolkit/content/widgets/tabbrowser.xml +++ b/toolkit/content/widgets/tabbrowser.xml @@ -583,12 +583,13 @@ // If location bar is hidden and the URL type supports a host, // add the scheme and host to the title to prevent spoofing. // XXX https://bugzilla.mozilla.org/show_bug.cgi?id=22183#c239 + // (only for schemes that support a host) try { if (docElement.getAttribute("chromehidden").indexOf("location") != -1) { - var host = this.mURIFixup.createExposableURI( - this.mCurrentBrowser.currentURI).prePath; - if (host) - newTitle = host + sep + newTitle; + var uri = this.mURIFixup.createExposableURI( + this.mCurrentBrowser.currentURI); + if (uri.host) + newTitle = uri.prePath + sep + newTitle; } } catch (e) {} diff --git a/xpfe/appshell/src/nsContentTreeOwner.cpp b/xpfe/appshell/src/nsContentTreeOwner.cpp index aa93e86171a..fd9b6f9a2ae 100644 --- a/xpfe/appshell/src/nsContentTreeOwner.cpp +++ b/xpfe/appshell/src/nsContentTreeOwner.cpp @@ -639,9 +639,12 @@ NS_IMETHODIMP nsContentTreeOwner::SetTitle(const PRUnichar* aTitle) nsCOMPtr tmpuri; nsresult rv = fixup->CreateExposableURI(uri,getter_AddRefs(tmpuri)); if (NS_SUCCEEDED(rv) && tmpuri) { + // (don't bother if there's no host) + nsCAutoString host; nsCAutoString prepath; + tmpuri->GetHost(host); tmpuri->GetPrePath(prepath); - if (!prepath.IsEmpty()) { + if (!host.IsEmpty()) { // // We have a scheme/host, update the title // diff --git a/xpfe/global/resources/content/bindings/tabbrowser.xml b/xpfe/global/resources/content/bindings/tabbrowser.xml index 606dafe87e8..6ba05191040 100644 --- a/xpfe/global/resources/content/bindings/tabbrowser.xml +++ b/xpfe/global/resources/content/bindings/tabbrowser.xml @@ -511,12 +511,13 @@ // If location bar is hidden and the URL type supports a host, // add the scheme and host to the title to prevent spoofing. // XXX https://bugzilla.mozilla.org/show_bug.cgi?id=22183#c239 + // (only for schemes that support a host) try { if (docElement.getAttribute("chromehidden").indexOf("location") != -1) { - var host = this.mURIFixup.createExposableURI( - this.mCurrentBrowser.currentURI).prePath; - if (host) - newTitle = host + sep + newTitle; + var uri = this.mURIFixup.createExposableURI( + this.mCurrentBrowser.currentURI); + if (uri.host) + newTitle = uri.prePath + sep + newTitle; } } catch (e) {}