[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [tor-browser/tor-browser-60.1.0esr-8.0-1] Bug 1473247 - Part 1: Fixing the issue that the IP addresses won't be set for first party domains. r=arthuredelstein, baku
commit a8a7f63745d822670462bde4c8db8cbb2ccc397c
Author: Tim Huang <tihuang@xxxxxxxxxxx>
Date: Fri Jul 13 19:53:15 2018 +0000
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
---
caps/OriginAttributes.cpp | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/caps/OriginAttributes.cpp b/caps/OriginAttributes.cpp
index 3d9c3f9bda78..ea3d7e507f3f 100644
--- a/caps/OriginAttributes.cpp
+++ b/caps/OriginAttributes.cpp
@@ -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);
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits