[tbb-commits] [tor-browser] 01/03: fixup! Bug 27476: Implement about:torconnect captive portal within Tor Browser

gitolite role git at cupani.torproject.org
Tue Oct 25 17:23:32 UTC 2022


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 at 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;
   };
 

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the tbb-commits mailing list