Bug 280438 - tab gives away password when no title is defined. patch by Gavin Sharp <gavin.sharp@gmail.com> r=mconnor

This commit is contained in:
mozilla.mano%sent.com 2005-02-06 20:33:26 +00:00
Родитель 6e3c278bea
Коммит 3dd1e5898a
1 изменённых файлов: 31 добавлений и 9 удалений

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

@ -116,6 +116,10 @@
.getService(Components.interfaces.nsIPrefService)
.getBranch(null);
</field>
<field name="mURIFixup" readonly="true">
Components.classes["@mozilla.org/docshell/urifixup;1"]
.getService(Components.interfaces.nsIURIFixup);
</field>
<field name="mTabBox">
document.getAnonymousNodes(this)[1]
</field>
@ -784,16 +788,34 @@
<![CDATA[
var browser = this.getBrowserForTab(aTab);
var crop = "end";
var titleViaGetter = browser.contentDocument.__proto__.__lookupGetter__('title').call(browser.contentDocument);
var title;
if (titleViaGetter)
title = titleViaGetter
else if (browser.currentURI.spec && browser.currentURI.spec != "about:blank") {
title = browser.currentURI.spec;
crop = "center";
var title = browser.contentDocument.__proto__.__lookupGetter__('title').call(browser.contentDocument);
if (!title) {
if (browser.currentURI.spec) {
try {
title = this.mURIFixup.createExposableURI(browser.currentURI).spec;
} catch(ex) {
title = browser.currentURI.spec;
}
}
if (title && title != "about:blank") {
// At this point, we now have a URI.
// Let's try to unescape it using a character set
// in case the URI is not ASCII.
try {
var characterSet = Components.lookupMethod(browser.contentDocument, 'characterSet')
.call(browser.contentDocument);
const textToSubURI = Components.classes["@mozilla.org/intl/texttosuburi;1"]
.getService(Components.interfaces.nsITextToSubURI);
title = textToSubURI.unEscapeNonAsciiURI(characterSet, title);
} catch(ex) { /* Do nothing. */ }
crop = "center";
} else // Still no title? Fall back to our untitled string.
title = this.mStringBundle.getString("tabs.untitled");
}
else
title = this.mStringBundle.getString("tabs.untitled");
aTab.label = title;
aTab.setAttribute("crop", crop);