зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1473247 - Part 1: Fixing the issue that the IP addresses won't be set for first party domains. r=arthuredelstein,baku
Right now, the firstPartyDomain won't be set when using IP addresses as first party domains. It is because of that the TLD service won't accept IP addresses as valid hosts. The patch fixes this problem by detecting that if the host is a IP address. If it is, we will still set the firstPartyDoamin with the IP address. Differential Revision: https://phabricator.services.mozilla.com/D1977 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
7fb3548c85
Коммит
c0118a2d73
|
@ -11,6 +11,7 @@
|
|||
#include "nsIEffectiveTLDService.h"
|
||||
#include "nsIURI.h"
|
||||
#include "nsIURIWithPrincipal.h"
|
||||
#include "nsURLHelper.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
|
@ -58,6 +59,28 @@ OriginAttributes::SetFirstPartyDomain(const bool aIsTopLevelDocument,
|
|||
return;
|
||||
}
|
||||
|
||||
if (rv == NS_ERROR_HOST_IS_IP_ADDRESS) {
|
||||
// If the host is an IPv4/IPv6 address, we still accept it as a
|
||||
// valid firstPartyDomain.
|
||||
nsAutoCString ipAddr;
|
||||
rv = aURI->GetHost(ipAddr);
|
||||
NS_ENSURE_SUCCESS_VOID(rv);
|
||||
|
||||
if (net_IsValidIPv6Addr(ipAddr.BeginReading(), ipAddr.Length())) {
|
||||
// According to RFC2732, the host of an IPv6 address should be an
|
||||
// IPv6reference. The GetHost() of nsIURI will only return the IPv6
|
||||
// address. So, we need to convert it back to IPv6reference here.
|
||||
mFirstPartyDomain.Truncate();
|
||||
mFirstPartyDomain.AssignLiteral("[");
|
||||
mFirstPartyDomain.Append(NS_ConvertUTF8toUTF16(ipAddr));
|
||||
mFirstPartyDomain.AppendLiteral("]");
|
||||
} else {
|
||||
mFirstPartyDomain = NS_ConvertUTF8toUTF16(ipAddr);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
nsAutoCString scheme;
|
||||
rv = aURI->GetScheme(scheme);
|
||||
NS_ENSURE_SUCCESS_VOID(rv);
|
||||
|
|
Загрузка…
Ссылка в новой задаче