From 61beda4fa220de1e154f72908298019f9c86acd7 Mon Sep 17 00:00:00 2001 From: Anmol Gautam Date: Sun, 29 Apr 2018 19:02:50 +0530 Subject: [PATCH] prevent ssl error dialog by website domain Summary: BUG: 393162 Reviewers: drosca, #falkon Reviewed By: drosca, #falkon Subscribers: falkon Tags: #falkon Differential Revision: https://phabricator.kde.org/D12522 --- src/lib/network/networkmanager.cpp | 11 +++++++++-- src/lib/network/networkmanager.h | 1 + src/lib/network/sslerrordialog.cpp | 5 +++++ src/lib/network/sslerrordialog.h | 2 +- 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/lib/network/networkmanager.cpp b/src/lib/network/networkmanager.cpp index ca7fb93e9..04ac50f19 100644 --- a/src/lib/network/networkmanager.cpp +++ b/src/lib/network/networkmanager.cpp @@ -71,6 +71,10 @@ bool NetworkManager::certificateError(const QWebEngineCertificateError &error, Q { const QString &host = error.url().host(); + if (m_rejectedSslErrors.contains(host) && m_rejectedSslErrors.value(host) == error.error()) { + return false; + } + if (m_ignoredSslErrors.contains(host) && m_ignoredSslErrors.value(host) == error.error()) return true; @@ -88,10 +92,13 @@ bool NetworkManager::certificateError(const QWebEngineCertificateError &error, Q case SslErrorDialog::Yes: // TODO: Permanent exceptions case SslErrorDialog::OnlyForThisSession: - m_ignoredSslErrors[error.url().host()] = error.error(); + m_ignoredSslErrors[host] = error.error(); return true; - case SslErrorDialog::No: + case SslErrorDialog::NoForThisSession: + m_rejectedSslErrors[host] = error.error(); + return false; + default: return false; } diff --git a/src/lib/network/networkmanager.h b/src/lib/network/networkmanager.h index 4dd62234d..da021abe0 100644 --- a/src/lib/network/networkmanager.h +++ b/src/lib/network/networkmanager.h @@ -55,6 +55,7 @@ private: NetworkUrlInterceptor *m_urlInterceptor; ExtensionSchemeManager *m_extensionScheme; QHash m_ignoredSslErrors; + QHash m_rejectedSslErrors; }; #endif // NETWORKMANAGER_H diff --git a/src/lib/network/sslerrordialog.cpp b/src/lib/network/sslerrordialog.cpp index 8d1455e00..6dd5f6af5 100644 --- a/src/lib/network/sslerrordialog.cpp +++ b/src/lib/network/sslerrordialog.cpp @@ -63,6 +63,11 @@ void SslErrorDialog::buttonClicked(QAbstractButton* button) accept(); break; + case QDialogButtonBox::NoRole: + m_result = NoForThisSession; + reject(); + break; + default: m_result = No; reject(); diff --git a/src/lib/network/sslerrordialog.h b/src/lib/network/sslerrordialog.h index d36faaf91..d8c8070a8 100644 --- a/src/lib/network/sslerrordialog.h +++ b/src/lib/network/sslerrordialog.h @@ -34,7 +34,7 @@ class FALKON_EXPORT SslErrorDialog : public QDialog Q_OBJECT public: - enum Result { Yes, No, OnlyForThisSession }; + enum Result { Yes, No, OnlyForThisSession, NoForThisSession }; explicit SslErrorDialog(QWidget* parent = 0); ~SslErrorDialog();