diff --git a/dom/locales/en-US/chrome/prompts.properties b/dom/locales/en-US/chrome/prompts.properties index 135d06a9256..078807924db 100644 --- a/dom/locales/en-US/chrome/prompts.properties +++ b/dom/locales/en-US/chrome/prompts.properties @@ -34,8 +34,13 @@ # # ***** END LICENSE BLOCK ***** -EnterUserPasswordForRealm=Enter username and password for "%1$S" at %2$S -EnterUserPasswordForProxy=Enter username and password for proxy "%1$S" at %2$S +# Localizer note: %1 is an untrusted string provided by a remote server. It +# could try to take advantage of sentence structure in order to mislead the +# user (see bug 244273). It should be integrated into the these property +# strings as little as possible. +EnterLoginForRealm=A username and password are being requested by %2$S. The site says: "%1$S" +EnterLoginForProxy=The proxy %2$S is requesting a username and password. The site says: "%1$S" + EnterUserPasswordFor=Enter username and password for %1$S EnterPasswordFor=Enter password for %1$S on %2$S diff --git a/embedding/components/windowwatcher/src/nsPrompt.cpp b/embedding/components/windowwatcher/src/nsPrompt.cpp index f95e19ed7c9..a782689cc85 100644 --- a/embedding/components/windowwatcher/src/nsPrompt.cpp +++ b/embedding/components/windowwatcher/src/nsPrompt.cpp @@ -55,6 +55,9 @@ #include "nsIIDNService.h" #include "nsNetUtil.h" #include "nsPromptUtils.h" +#include "nsIPrefService.h" +#include "nsIPrefLocalizedString.h" + nsresult NS_NewPrompter(nsIPrompt **result, nsIDOMWindow *aParent) @@ -418,6 +421,26 @@ MakeDialogText(nsIChannel* aChannel, nsIAuthInformation* aAuthInfo, nsAutoString realm; aAuthInfo->GetRealm(realm); + // Trim obnoxiously long realms. + if (realm.Length() > 150) { + realm.Truncate(150); + + // Append "..." (or localized equivalent). Yay complexity. + nsAutoString ellipsis; + nsCOMPtr prefs(do_GetService(NS_PREFSERVICE_CONTRACTID)); + if (prefs) { + nsCOMPtr prefString; + rv = prefs->GetComplexValue("intl.ellipsis", + NS_GET_IID(nsIPrefLocalizedString), + getter_AddRefs(prefString)); + if (prefString) + prefString->ToString(getter_Copies(ellipsis)); + } + if (ellipsis.IsEmpty()) + ellipsis.AssignLiteral("..."); + + realm.Append(ellipsis); + } // Append the port if it was specified if (port != -1) { @@ -425,8 +448,8 @@ MakeDialogText(nsIChannel* aChannel, nsIAuthInformation* aAuthInfo, displayHost.AppendInt(port); } - NS_NAMED_LITERAL_STRING(proxyText, "EnterUserPasswordForProxy"); - NS_NAMED_LITERAL_STRING(originText, "EnterUserPasswordForRealm"); + NS_NAMED_LITERAL_STRING(proxyText, "EnterLoginForProxy"); + NS_NAMED_LITERAL_STRING(originText, "EnterLoginForRealm"); NS_NAMED_LITERAL_STRING(noRealmText, "EnterUserPasswordFor"); NS_NAMED_LITERAL_STRING(passwordText, "EnterPasswordFor"); diff --git a/toolkit/content/commonDialog.css b/toolkit/content/commonDialog.css index 73e5418c5c9..8732dc7c3ed 100644 --- a/toolkit/content/commonDialog.css +++ b/toolkit/content/commonDialog.css @@ -37,9 +37,18 @@ @namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"); /* set default namespace to XUL */ -#info\.box > description { +#infoContainer { + max-width: 45em; +} + +#info\.body { -moz-user-focus: normal; -moz-user-select: text; cursor: text !important; white-space: -moz-pre-wrap; } + +#loginLabel, #password1Label, #password2Label { + text-align: right; +} + diff --git a/toolkit/content/commonDialog.js b/toolkit/content/commonDialog.js index 4d1eac59121..2f3cfa5304a 100644 --- a/toolkit/content/commonDialog.js +++ b/toolkit/content/commonDialog.js @@ -124,9 +124,9 @@ function commonDialogOnLoad() } // display the main text - var messageParent = document.getElementById("info.box").getElementsByTagName('description')[0]; // XXX the substr(0, 10000) part is a workaround for bug 317334 - messageParent.textContent = gCommonDialogParam.GetString(0).substr(0, 10000); + var croppedMessage = gCommonDialogParam.GetString(0).substr(0, 10000); + setElementText("info.body", croppedMessage, true); setElementText("info.header", gCommonDialogParam.GetString(3), true); @@ -262,9 +262,7 @@ function setElementText(aElementID, aValue, aChildNodeFlag) function setCheckbox(aChkMsg, aChkValue) { if (aChkMsg) { - // XXX Would love to use hidden instead of collapsed, but the checkbox - // fails to size itself properly when I do this. - document.getElementById("checkboxContainer").removeAttribute("collapsed"); + unHideElementById("checkboxContainer"); var checkboxElement = document.getElementById("checkbox"); setLabelForNode(checkboxElement, aChkMsg); diff --git a/toolkit/content/commonDialog.xul b/toolkit/content/commonDialog.xul index a2d12efd472..df05687978a 100644 --- a/toolkit/content/commonDialog.xul +++ b/toolkit/content/commonDialog.xul @@ -38,46 +38,46 @@ - - - - - - -#ifdef XP_MACOSX -# On mac, we're exposing the dialog title inside the dialog - - -#endif - - - - - - - - - - - - + + - - + + + +