This is an automated email from the git hooks/post-receive script.
pierov pushed a change to branch tor-browser-102.4.0esr-12.0-1 in repository tor-browser.
from 7187cb8561e9 fixup! Bug 40562: Added Tor-related preferences to 000-tor-browser.js new 8ee2a04b63f0 fixup! Bug 27476: Implement about:torconnect captive portal within Tor Browser new 2c885618ed0e fixup! Bug 21952: Implement Onion-Location new dae0e8fa0796 fixup! Bug 40458: Implement .tor.onion aliases
The 3 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "add" were already present in the repository and have only been added to this reference.
Summary of changes: dom/base/Document.cpp | 104 +++++++++++++++++++++++++------------- netwerk/dns/OnionAliasService.cpp | 13 +++-- 2 files changed, 76 insertions(+), 41 deletions(-)
This is an automated email from the git hooks/post-receive script.
pierov pushed a commit to branch tor-browser-102.4.0esr-12.0-1 in repository tor-browser.
commit 8ee2a04b63f0d6277ca3445074b5d243a7f2d631 Author: Pier Angelo Vendrame pierov@torproject.org AuthorDate: Tue Oct 25 10:05:17 2022 +0200
fixup! Bug 27476: Implement about:torconnect captive portal within Tor Browser
Linted Document.cpp --- dom/base/Document.cpp | 47 ++++++++++++++++++++++++----------------------- 1 file changed, 24 insertions(+), 23 deletions(-)
diff --git a/dom/base/Document.cpp b/dom/base/Document.cpp index f429506b0a8d..6ddf6f9e4283 100644 --- a/dom/base/Document.cpp +++ b/dom/base/Document.cpp @@ -17827,49 +17827,50 @@ ColorScheme Document::DefaultColorScheme() const { }
ColorScheme Document::PreferredColorScheme(IgnoreRFP aIgnoreRFP) const { - // tor-browser#27476 - // should this document ignore resist finger-printing settings with regards to - // setting the color scheme - // currently only enabled for about:torconnect but we could expand to other non- - // SystemPrincipal pages if we wish - const auto documentUsesPreferredColorScheme = [](auto const* constDocument) -> bool { - if (auto* document = const_cast<Document*>(constDocument); document != nullptr) { + // Should this document ignore resist finger-printing settings with regards to + // setting the color scheme? + // Currently only enabled for about:torconnect but we could expand to other + // non-SystemPrincipal pages if we wish. + const auto documentUsesPreferredColorScheme = + [](auto const* constDocument) -> bool { + if (auto* document = const_cast<Document*>(constDocument); + document != nullptr) { auto uri = document->GetDocBaseURI();
- // try and extract out our prepath and filepath portions of the uri to C-strings + // Try and extract out our prepath and filepath portions of the uri to + // C-strings. nsAutoCString prePathStr, filePathStr; - if(NS_FAILED(uri->GetPrePath(prePathStr)) || - NS_FAILED(uri->GetFilePath(filePathStr))) { + if (NS_FAILED(uri->GetPrePath(prePathStr)) || + NS_FAILED(uri->GetFilePath(filePathStr))) { return false; }
- // stick them in string view for easy comparisons + // Stick them in string view for easy comparisons std::string_view prePath(prePathStr.get(), prePathStr.Length()), - filePath(filePathStr.get(), filePathStr.Length()); + filePath(filePathStr.get(), filePathStr.Length());
- // these about URIs will have the user's preferred color scheme exposed to them - // we can place other URIs here in the future if we wish - // see nsIURI.idl for URI part definitions + // These about URIs will have the user's preferred color scheme exposed to + // them we can place other URIs here in the future if we wish. + // See nsIURI.idl for URI part definitions constexpr struct { std::string_view prePath; std::string_view filePath; } allowedURIs[] = { - { "about:", "torconnect" }, + {"about:", "torconnect"}, };
- // check each uri in the allow list against this document's uri - // verify the prepath and the file path match - for(auto const& uri : allowedURIs) { - if (prePath == uri.prePath && - filePath == uri.filePath) { - // positive match means we can apply dark-mode to the page + // Check each uri in the allow list against this document's URI. + // Verify the prepath and the file path match + for (auto const& uri : allowedURIs) { + if (prePath == uri.prePath && filePath == uri.filePath) { + // Positive match means we can apply dark-mode to the page return true; } } }
- // do not allow if no match or other error + // Do not allow if no match or other error return false; };
This is an automated email from the git hooks/post-receive script.
pierov pushed a commit to branch tor-browser-102.4.0esr-12.0-1 in repository tor-browser.
commit 2c885618ed0e1e7779f89160f75cb920b2c79264 Author: Pier Angelo Vendrame pierov@torproject.org AuthorDate: Tue Oct 25 10:54:25 2022 +0200
fixup! Bug 21952: Implement Onion-Location
Bug 40491: Don't auto-pick a v2 address when it's in Onion-Location header --- dom/base/Document.cpp | 57 +++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 46 insertions(+), 11 deletions(-)
diff --git a/dom/base/Document.cpp b/dom/base/Document.cpp index 6ddf6f9e4283..9001556d0232 100644 --- a/dom/base/Document.cpp +++ b/dom/base/Document.cpp @@ -6831,18 +6831,53 @@ void Document::GetHeaderData(nsAtom* aHeaderField, nsAString& aData) const {
static bool IsValidOnionLocation(nsIURI* aDocumentURI, nsIURI* aOnionLocationURI) { - bool isHttpish; + if (!aDocumentURI || !aOnionLocationURI) { + return false; + } + + // Current URI nsAutoCString host; - return aDocumentURI && aOnionLocationURI && - NS_SUCCEEDED(aDocumentURI->SchemeIs("https", &isHttpish)) && - isHttpish && NS_SUCCEEDED(aDocumentURI->GetAsciiHost(host)) && - !StringEndsWith(host, ".onion"_ns) && - ((NS_SUCCEEDED(aOnionLocationURI->SchemeIs("http", &isHttpish)) && - isHttpish) || - (NS_SUCCEEDED(aOnionLocationURI->SchemeIs("https", &isHttpish)) && - isHttpish)) && - NS_SUCCEEDED(aOnionLocationURI->GetAsciiHost(host)) && - StringEndsWith(host, ".onion"_ns); + if (!aDocumentURI->SchemeIs("https")) { + return false; + } + NS_ENSURE_SUCCESS(aDocumentURI->GetAsciiHost(host), false); + if (StringEndsWith(host, ".onion"_ns)) { + // Already in the .onion site + return false; + } + + // Target URI + if (!aOnionLocationURI->SchemeIs("http") && + !aOnionLocationURI->SchemeIs("https")) { + return false; + } + nsCOMPtr<nsIEffectiveTLDService> eTLDService = + do_GetService(NS_EFFECTIVETLDSERVICE_CONTRACTID); + if (!eTLDService) { + NS_ENSURE_SUCCESS(aOnionLocationURI->GetAsciiHost(host), false); + // This should not happen, but in the unlikely case, still check if it is a + // .onion and in case allow it. + return StringEndsWith(host, ".onion"_ns); + } + NS_ENSURE_SUCCESS(eTLDService->GetBaseDomain(aOnionLocationURI, 0, host), + false); + if (!StringEndsWith(host, ".onion"_ns)) { + return false; + } + + // Ignore v2 + if (host.Length() == 22) { + const char* cur = host.BeginWriting(); + // We have already checked that it ends by ".onion" + const char* end = host.EndWriting() - 6; + bool base32 = true; + for (; cur < end && base32; ++cur) { + base32 = isalpha(*cur) || ('2' <= *cur && *cur <= '7'); + } + return !base32; + } + + return true; }
void Document::SetHeaderData(nsAtom* aHeaderField, const nsAString& aData) {
This is an automated email from the git hooks/post-receive script.
pierov pushed a commit to branch tor-browser-102.4.0esr-12.0-1 in repository tor-browser.
commit dae0e8fa0796265e0e321aca60843e46027fd6d4 Author: Pier Angelo Vendrame pierov@torproject.org AuthorDate: Tue Oct 25 18:58:33 2022 +0200
fixup! Bug 40458: Implement .tor.onion aliases --- netwerk/dns/OnionAliasService.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-)
diff --git a/netwerk/dns/OnionAliasService.cpp b/netwerk/dns/OnionAliasService.cpp index 3d8a7643b045..50d9841e87b6 100644 --- a/netwerk/dns/OnionAliasService.cpp +++ b/netwerk/dns/OnionAliasService.cpp @@ -13,8 +13,7 @@ * verification. * @return Tells whether the input string is an Onion v3 address */ -static bool ValidateOnionV3(nsACString &aHostname) -{ +static bool ValidateOnionV3(nsACString& aHostname) { constexpr nsACString::size_type v3Length = 56 + 6; if (aHostname.Length() != v3Length) { return false; @@ -24,7 +23,7 @@ static bool ValidateOnionV3(nsACString &aHostname) return false; }
- char* cur = aHostname.BeginWriting(); + const char* cur = aHostname.BeginWriting(); // We have already checked that it ends by ".onion" const char* end = aHostname.EndWriting() - 6; for (; cur < end; ++cur) { @@ -55,11 +54,11 @@ already_AddRefed<IOnionAliasService> OnionAliasService::GetSingleton() {
NS_IMETHODIMP OnionAliasService::AddOnionAlias(const nsACString& aShortHostname, - const nsACString& aLongHostname) { + const nsACString& aLongHostname) { nsAutoCString shortHostname; ToLowerCase(aShortHostname, shortHostname); mozilla::UniquePtr<nsAutoCString> longHostname = - mozilla::MakeUnique<nsAutoCString>(aLongHostname); + mozilla::MakeUnique<nsAutoCString>(aLongHostname); if (!longHostname) { return NS_ERROR_OUT_OF_MEMORY; } @@ -73,8 +72,8 @@ OnionAliasService::AddOnionAlias(const nsACString& aShortHostname, }
NS_IMETHODIMP -OnionAliasService::GetOnionAlias(const nsACString& aShortHostname, nsACString& aLongHostname) -{ +OnionAliasService::GetOnionAlias(const nsACString& aShortHostname, + nsACString& aLongHostname) { aLongHostname = aShortHostname; if (mozilla::StaticPrefs::browser_urlbar_onionRewrites_enabled() && StringEndsWith(aShortHostname, ".tor.onion"_ns)) {
tor-commits@lists.torproject.org