Web Browser: made the URL entry background configurable and harmonized certificate handling for the web page and its web icon (favicon).

Sun, 03 May 2020 16:18:14 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sun, 03 May 2020 16:18:14 +0200
changeset 7570
a7a5750aded4
parent 7567
bb196e51827d
child 7571
c34333fa5aba

Web Browser: made the URL entry background configurable and harmonized certificate handling for the web page and its web icon (favicon).

eric6/DebugClients/Python/DebugClientBase.py file | annotate | diff | comparison | revisions
eric6/Preferences/ConfigurationPages/SecurityPage.py file | annotate | diff | comparison | revisions
eric6/Preferences/ConfigurationPages/SecurityPage.ui file | annotate | diff | comparison | revisions
eric6/Preferences/__init__.py file | annotate | diff | comparison | revisions
eric6/WebBrowser/Network/NetworkManager.py file | annotate | diff | comparison | revisions
eric6/WebBrowser/UrlBar/UrlBar.py file | annotate | diff | comparison | revisions
--- a/eric6/DebugClients/Python/DebugClientBase.py	Sun May 03 10:26:40 2020 +0200
+++ b/eric6/DebugClients/Python/DebugClientBase.py	Sun May 03 16:18:14 2020 +0200
@@ -68,7 +68,7 @@
     
     This function works with the split debugger.
     
-    @param prompt prompt to be shown 
+    @param prompt prompt to be shown
     @type str
     @return result of the input() call
     @rtype str
--- a/eric6/Preferences/ConfigurationPages/SecurityPage.py	Sun May 03 10:26:40 2020 +0200
+++ b/eric6/Preferences/ConfigurationPages/SecurityPage.py	Sun May 03 16:18:14 2020 +0200
@@ -45,6 +45,9 @@
         
         self.__newPassword = ""
         self.__oldUseMasterPassword = Preferences.getUser("UseMasterPassword")
+        
+        self.alwaysRejectCheckBox.setChecked(
+            Preferences.getWebBrowser("AlwaysRejectFaultyCertificates"))
     
     def setMode(self, displayMode):
         """
@@ -63,6 +66,10 @@
         )
         
         self.__displayMode = displayMode
+        
+        self.certificateErrorsGroup.setVisible(
+            displayMode == ConfigurationWidget.WebBrowserMode
+        )
     
     def save(self):
         """
@@ -80,6 +87,10 @@
             self.masterPasswordCheckBox.isChecked()
         ):
             self.__configDlg.masterPasswordChanged.emit("", self.__newPassword)
+        
+        Preferences.setWebBrowser(
+            "AlwaysRejectFaultyCertificates",
+            self.alwaysRejectCheckBox.isChecked())
     
     @pyqtSlot(bool)
     def on_masterPasswordCheckBox_clicked(self, checked):
--- a/eric6/Preferences/ConfigurationPages/SecurityPage.ui	Sun May 03 10:26:40 2020 +0200
+++ b/eric6/Preferences/ConfigurationPages/SecurityPage.ui	Sun May 03 16:18:14 2020 +0200
@@ -7,7 +7,7 @@
     <x>0</x>
     <y>0</y>
     <width>400</width>
-    <height>300</height>
+    <height>434</height>
    </rect>
   </property>
   <layout class="QVBoxLayout" name="verticalLayout_3">
@@ -91,6 +91,25 @@
     </widget>
    </item>
    <item>
+    <widget class="QGroupBox" name="certificateErrorsGroup">
+     <property name="title">
+      <string>Certificate Errors</string>
+     </property>
+     <layout class="QVBoxLayout" name="verticalLayout_2">
+      <item>
+       <widget class="QCheckBox" name="alwaysRejectCheckBox">
+        <property name="toolTip">
+         <string>Select to always reject web pages with certificate issues</string>
+        </property>
+        <property name="text">
+         <string>Always reject URLs with certificate errors</string>
+        </property>
+       </widget>
+      </item>
+     </layout>
+    </widget>
+   </item>
+   <item>
     <spacer name="verticalSpacer">
      <property name="orientation">
       <enum>Qt::Vertical</enum>
--- a/eric6/Preferences/__init__.py	Sun May 03 10:26:40 2020 +0200
+++ b/eric6/Preferences/__init__.py	Sun May 03 16:18:14 2020 +0200
@@ -952,6 +952,7 @@
         "DiskCacheEnabled": True,
         "DiskCacheSize": 50,        # 50 MB
         "SslExceptionsDB": "{}",    # empty JSON dictionary
+        "AlwaysRejectFaultyCertificates": False,
         "DoNotTrack": False,
         "RefererSendReferer": 2,        # send always
         "RefererDefaultPolicy": 3,      # don't send a referer when downgrading
@@ -2836,7 +2837,7 @@
                  "WebRTCPublicInterfacesOnly", "DnsPrefetchEnabled",
                  "FlashCookiesDeleteOnStartExit", "FlashCookieAutoRefresh",
                  "FlashCookieNotify", "VirusTotalEnabled", "VirusTotalSecure",
-                 "PdfViewerEnabled",
+                 "PdfViewerEnabled", "AlwaysRejectFaultyCertificates",
                  ]:
         return toBool(prefClass.settings.value(
             "WebBrowser/" + key, prefClass.webBrowserDefaults[key]))
--- a/eric6/WebBrowser/Network/NetworkManager.py	Sun May 03 10:26:40 2020 +0200
+++ b/eric6/WebBrowser/Network/NetworkManager.py	Sun May 03 16:18:14 2020 +0200
@@ -64,7 +64,7 @@
         
         if SSL_AVAILABLE:
             self.__sslErrorHandler = E5SslErrorHandler(self)
-            self.sslErrors.connect(self.__sslErrorHandler.sslErrorsReplySlot)
+            self.sslErrors.connect(self.__sslErrorHandlingSlot)
         
         self.__temporarilyIgnoredSslErrors = {}
         self.__permanentlyIgnoredSslErrors = {}
@@ -177,6 +177,9 @@
         @return flag indicating to ignore this error
         @rtype bool
         """
+        if Preferences.getWebBrowser("AlwaysRejectFaultyCertificates"):
+            return False
+        
         self.__load()
         
         host = error.url().host()
@@ -200,11 +203,11 @@
             E5MessageBox.Warning,
             title,
             self.tr("""<b>{0}</b>"""
-                    """<p>The page you are trying to access has errors"""
-                    """ in the SSL certificate.</p>"""
-                    """<ul><li>{1}</li></ul>"""
+                    """<p>The host <b>{1}</b> you are trying to access has"""
+                    """ errors in the SSL certificate.</p>"""
+                    """<ul><li>{2}</li></ul>"""
                     """<p>Would you like to make an exception?</p>""")
-            .format(title, error.errorDescription()),
+            .format(title, host, error.errorDescription()),
             modal=True, parent=view)
         permButton = msgBox.addButton(self.tr("&Permanent accept"),
                                       E5MessageBox.AcceptRole)
@@ -226,10 +229,35 @@
         else:
             return False
     
+    def __sslErrorHandlingSlot(self, reply, errors):
+        """
+        Private slot to handle SSL errors for a network reply.
+        
+        @param reply reference to the reply object
+        @type QNetworkReply
+        @param errors list of SSL errors
+        @type list of QSslError
+        """
+        if Preferences.getWebBrowser("AlwaysRejectFaultyCertificates"):
+            return
+        
+        self.__load()
+        
+        host = reply.url().host()
+        if (
+            host in self.__permanentlyIgnoredSslErrors or
+            host in self.__temporarilyIgnoredSslErrors
+        ):
+            reply.ignoreSslErrors()
+        else:
+            self.__sslErrorHandler.sslErrorsReply(reply, errors)
+    
     def isInsecureHost(self, host):
         """
         Public method to check a host against the list of insecure hosts.
         
+        @param host name of the host to be checked
+        @type str
         @return flag indicating an insecure host
         @rtype bool
         """
--- a/eric6/WebBrowser/UrlBar/UrlBar.py	Sun May 03 10:26:40 2020 +0200
+++ b/eric6/WebBrowser/UrlBar/UrlBar.py	Sun May 03 16:18:14 2020 +0200
@@ -235,7 +235,7 @@
             if not self.__browser.getSafeBrowsingStatus():
                 # malicious web site
                 backgroundColor = Preferences.getWebBrowser(
-                        "MaliciousUrlColor")
+                    "MaliciousUrlColor")
             elif self.__browser.url().scheme() == "https":
                 if WebBrowserWindow.networkManager().isInsecureHost(
                     self.__browser.url().host()

eric ide

mercurial