aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/browsertab.cpp45
1 files changed, 19 insertions, 26 deletions
diff --git a/src/browsertab.cpp b/src/browsertab.cpp
index 0fe0af6..041f886 100644
--- a/src/browsertab.cpp
+++ b/src/browsertab.cpp
@@ -810,20 +810,25 @@ bool BrowserTab::startRequest(const QUrl &url, ProtocolHandler::RequestOptions o
assert((this->current_handler != nullptr) and "If this error happens, someone forgot to add a new protocol handler class in the constructor. Shame on the programmer!");
- if(this->current_identity.isValid()) {
- if(not this->current_handler->enableClientCertificate(this->current_identity)) {
- auto answer = QMessageBox::question(
- this,
- "Kristall",
- tr("You requested a %1-URL with a client certificate, but these are not supported for this scheme. Continue?").arg(url.scheme())
- );
- if(answer != QMessageBox::Yes)
- return false;
+ auto const try_enable_certificate = [&]() -> bool {
+ if(this->current_identity.isValid()) {
+ if(not this->current_handler->enableClientCertificate(this->current_identity)) {
+ auto answer = QMessageBox::question(
+ this,
+ "Kristall",
+ tr("You requested a %1-URL with a client certificate, but these are not supported for this scheme. Continue?").arg(url.scheme())
+ );
+ if(answer != QMessageBox::Yes)
+ return false;
+ this->disableClientCertificate();
+ }
+ } else {
this->disableClientCertificate();
}
- } else {
- this->disableClientCertificate();
- }
+ return true;
+ };
+ if(not try_enable_certificate())
+ return false;
if(this->current_identity.isValid() and (url.host() != this->current_location.host())) {
auto answer = QMessageBox::question(
@@ -876,20 +881,8 @@ bool BrowserTab::startRequest(const QUrl &url, ProtocolHandler::RequestOptions o
}
}
- if(this->current_identity.isValid()) {
- if(not this->current_handler->enableClientCertificate(this->current_identity)) {
- auto answer = QMessageBox::question(
- this,
- "Kristall",
- tr("You requested a %1-URL with a client certificate, but these are not supported for this scheme. Continue?").arg(url.scheme())
- );
- if(answer != QMessageBox::Yes)
- return false;
- this->disableClientCertificate();
- }
- } else {
- this->disableClientCertificate();
- }
+ if(not try_enable_certificate())
+ return false;
this->is_internal_location = (url.scheme() == "about");
this->current_location = url;