diff options
author | wolfbeast <mcwerewolf@gmail.com> | 2018-02-07 12:03:46 +0100 |
---|---|---|
committer | wolfbeast <mcwerewolf@gmail.com> | 2018-02-07 12:03:46 +0100 |
commit | f8d1830b530cd553d788b3579d41725d35c4da7f (patch) | |
tree | c995f1eed357cbeb7ed9bbe9d2319ca802b77a26 /netwerk | |
parent | 0f3e990615adfd42ae9cfbe13a6259cb6a0368c4 (diff) | |
parent | e9f79ad46582ca150ef193252851015a031d1556 (diff) | |
download | UXP-f8d1830b530cd553d788b3579d41725d35c4da7f.tar UXP-f8d1830b530cd553d788b3579d41725d35c4da7f.tar.gz UXP-f8d1830b530cd553d788b3579d41725d35c4da7f.tar.lz UXP-f8d1830b530cd553d788b3579d41725d35c4da7f.tar.xz UXP-f8d1830b530cd553d788b3579d41725d35c4da7f.zip |
Merge branch 'ported-upstream'
Diffstat (limited to 'netwerk')
-rw-r--r-- | netwerk/protocol/http/nsHttpChannelAuthProvider.cpp | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/netwerk/protocol/http/nsHttpChannelAuthProvider.cpp b/netwerk/protocol/http/nsHttpChannelAuthProvider.cpp index 9a2275287..d04f47ddc 100644 --- a/netwerk/protocol/http/nsHttpChannelAuthProvider.cpp +++ b/netwerk/protocol/http/nsHttpChannelAuthProvider.cpp @@ -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) { @@ -1512,6 +1515,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; |