From 2a56a19677822904c76c6c43b33da0f588cb6c43 Mon Sep 17 00:00:00 2001 From: Bill Somerville Date: Wed, 17 Oct 2018 22:31:10 +0100 Subject: [PATCH] Avoid redirect loops with no OpenSSL support Only force http scheme on initial fetch attempt if no suitable OpenSSL support is installed, also give a more meaningful error message when a redirect to an https scheme URL when no suitable OpenSSL support is installed. --- LotWUsers.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/LotWUsers.cpp b/LotWUsers.cpp index d24b93940..3876cd7bf 100644 --- a/LotWUsers.cpp +++ b/LotWUsers.cpp @@ -48,6 +48,10 @@ public: if (!QFileInfo::exists (csv_file_name) || forced_fetch) { current_url_.setUrl (url); + if (current_url_.isValid () && !QSslSocket::supportsSsl ()) + { + current_url_.setScheme ("http"); + } redirect_count_ = 0; download (current_url_); } @@ -66,10 +70,6 @@ public: network_manager_->setNetworkAccessible (QNetworkAccessManager::Accessible); } - if (url.isValid () && !QSslSocket::supportsSsl ()) - { - url.setScheme ("http"); - } QNetworkRequest request {url}; request.setRawHeader ("User-Agent", "WSJT LotW User Downloader"); request.setOriginatingObject (this); @@ -99,7 +99,14 @@ public: QUrl redirect_url {reply_->attribute (QNetworkRequest::RedirectionTargetAttribute).toUrl ()}; if (reply_->error () == QNetworkReply::NoError && !redirect_url.isEmpty ()) { - if (++redirect_count_ < 10) // maintain sanity + if ("https" == redirect_url.scheme () && !QSslSocket::supportsSsl ()) + { + Q_EMIT self_->LotW_users_error (tr ("Network Error - SSL/TLS support not installed, cannot fetch:\n\'%1\'") + .arg (redirect_url.toDisplayString ())); + url_valid_ = false; // reset + Q_EMIT self_->load_finished (); + } + else if (++redirect_count_ < 10) // maintain sanity { // follow redirect download (reply_->url ().resolved (redirect_url));