commit 9a78f236a3243d7748e44262ce5a0f1a4be44144
Author: Alex Catarineu <acat(a)torproject.org>
Date: Thu Jul 2 21:38:54 2020 +0200
fixup! Bug 21952: Implement Onion-Location
Fixes #40019.
---
dom/base/Document.cpp | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/dom/base/Document.cpp b/dom/base/Document.cpp
index acc59f5fe70c..0d49a6a18419 100644
--- a/dom/base/Document.cpp
+++ b/dom/base/Document.cpp
@@ -6029,16 +6029,17 @@ void Document::GetHeaderData(nsAtom* aHeaderField, nsAString& aData) const {
static bool IsValidOnionLocation(nsIURI* aDocumentURI,
nsIURI* aOnionLocationURI) {
bool isHttpish;
- nsAutoCString onionHost;
+ nsAutoCString host;
return aDocumentURI && aOnionLocationURI &&
NS_SUCCEEDED(aDocumentURI->SchemeIs("https", &isHttpish)) &&
- isHttpish &&
+ isHttpish && NS_SUCCEEDED(aDocumentURI->GetAsciiHost(host)) &&
+ !StringEndsWith(host, NS_LITERAL_CSTRING(".onion")) &&
((NS_SUCCEEDED(aOnionLocationURI->SchemeIs("http", &isHttpish)) &&
isHttpish) ||
(NS_SUCCEEDED(aOnionLocationURI->SchemeIs("https", &isHttpish)) &&
isHttpish)) &&
- NS_SUCCEEDED(aOnionLocationURI->GetAsciiHost(onionHost)) &&
- StringEndsWith(onionHost, NS_LITERAL_CSTRING(".onion"));
+ NS_SUCCEEDED(aOnionLocationURI->GetAsciiHost(host)) &&
+ StringEndsWith(host, NS_LITERAL_CSTRING(".onion"));
}
void Document::SetHeaderData(nsAtom* aHeaderField, const nsAString& aData) {