зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1360842
, r=valentin
MozReview-Commit-ID: B7uG3ShaGuH --HG-- extra : rebase_source : 92813be22a7554fec17981bf14903a526145fed2 extra : amend_source : 30643e1d5a4b942d4069e3dd28b5f736cb7fdc18
This commit is contained in:
Родитель
f38ce9a2fe
Коммит
2c13f23a54
|
@ -53,6 +53,9 @@ namespace net {
|
|||
#define HTTP_AUTH_NEGOTIATE_INSECURE 6
|
||||
#define HTTP_AUTH_NEGOTIATE_SECURE 7
|
||||
|
||||
#define MAX_DISPLAYED_USER_LENGTH 64
|
||||
#define MAX_DISPLAYED_HOST_LENGTH 64
|
||||
|
||||
static void
|
||||
GetOriginAttributesSuffix(nsIChannel* aChan, nsACString &aSuffix)
|
||||
{
|
||||
|
@ -1543,6 +1546,33 @@ nsHttpChannelAuthProvider::ConfirmAuth(const nsString &bundleKey,
|
|||
return true;
|
||||
|
||||
NS_ConvertUTF8toUTF16 ucsHost(host), ucsUser(user);
|
||||
|
||||
size_t userLength = ucsUser.Length();
|
||||
if (userLength > MAX_DISPLAYED_USER_LENGTH) {
|
||||
size_t desiredLength = MAX_DISPLAYED_USER_LENGTH;
|
||||
// Don't cut off right before a low surrogate. Just include it.
|
||||
if (NS_IS_LOW_SURROGATE(ucsUser[desiredLength])) {
|
||||
desiredLength++;
|
||||
}
|
||||
ucsUser.Replace(desiredLength, userLength - desiredLength,
|
||||
nsContentUtils::GetLocalizedEllipsis());
|
||||
}
|
||||
|
||||
size_t hostLen = ucsHost.Length();
|
||||
if (hostLen > MAX_DISPLAYED_HOST_LENGTH) {
|
||||
size_t cutPoint = hostLen - MAX_DISPLAYED_HOST_LENGTH;
|
||||
// Likewise, don't cut off right before a low surrogate here.
|
||||
// Keep the low surrogate
|
||||
if (NS_IS_LOW_SURROGATE(ucsHost[cutPoint])) {
|
||||
cutPoint--;
|
||||
}
|
||||
// It's possible cutPoint was 1 and is now 0. Only insert the ellipsis
|
||||
// if we're actually removing anything.
|
||||
if (cutPoint > 0) {
|
||||
ucsHost.Replace(0, cutPoint, nsContentUtils::GetLocalizedEllipsis());
|
||||
}
|
||||
}
|
||||
|
||||
const char16_t *strs[2] = { ucsHost.get(), ucsUser.get() };
|
||||
|
||||
nsXPIDLString msg;
|
||||
|
|
Загрузка…
Ссылка в новой задаче