Skip to content

Commit 6f534c5

Browse files
committedDec 13, 2016
[BUGFIX] Fixed a crash on bad network protocol
1 parent a8b9723 commit 6f534c5

File tree

5 files changed

+21
-21
lines changed

5 files changed

+21
-21
lines changed
 

‎ci/travis/linux/script.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,5 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
2525
export OTB_APPLICATION_PATH=${HOME}/OTB-5.6.0-Linux64/lib/otb/applications
2626
export LD_PRELOAD=/lib/x86_64-linux-gnu/libSegFault.so
2727

28-
xvfb-run ctest -V -E "qgis_filedownloader|qgis_openstreetmaptest|qgis_wcsprovidertest|PyQgsWFSProviderGUI|qgis_ziplayertest|$(cat ${DIR}/blacklist.txt | paste -sd '|' -)" -S ./qgis-test-travis.ctest --output-on-failure
28+
xvfb-run ctest -V -E "qgis_openstreetmaptest|qgis_wcsprovidertest|PyQgsWFSProviderGUI|qgis_ziplayertest|$(cat ${DIR}/blacklist.txt | paste -sd '|' -)" -S ./qgis-test-travis.ctest --output-on-failure
2929
# xvfb-run ctest -V -E "qgis_openstreetmaptest|qgis_wcsprovidertest" -S ./qgis-test-travis.ctest --output-on-failure

‎src/app/qgsidentifyresultsdialog.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ QgsIdentifyResultsWebView::QgsIdentifyResultsWebView( QWidget *parent ) : QgsWeb
7777
{
7878
setSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::Minimum );
7979
page()->setNetworkAccessManager( QgsNetworkAccessManager::instance() );
80-
// page()->setLinkDelegationPolicy( QWebPage::DelegateAllLinks );
8180
#ifdef WITH_QTWEBKIT
8281
page()->setForwardUnsupportedContent( true );
8382
#endif

‎src/gui/qgsfiledownloader.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ void QgsFileDownloader::startDownload()
6060
mReply = nam->get( request );
6161

6262
connect( mReply, &QNetworkReply::readyRead, this, &QgsFileDownloader::onReadyRead );
63-
connect( mReply, static_cast < void ( QNetworkReply::* )( QNetworkReply::NetworkError ) > ( &QNetworkReply::error ), this, &QgsFileDownloader::onNetworkError );
6463
connect( mReply, &QNetworkReply::finished, this, &QgsFileDownloader::onFinished );
6564
connect( mReply, &QNetworkReply::downloadProgress, this, &QgsFileDownloader::onDownloadProgress );
6665
connect( nam, &QgsNetworkAccessManager::requestTimedOut, this, &QgsFileDownloader::onRequestTimedOut );
@@ -108,7 +107,7 @@ void QgsFileDownloader::error( QStringList errorMessages )
108107
{
109108
for ( auto end = errorMessages.size(), i = 0; i != end; ++i )
110109
{
111-
mErrors.append( errorMessages[i] );
110+
mErrors << errorMessages[i];
112111
}
113112
// Show error
114113
if ( mGuiNotificationsEnabled )
@@ -161,7 +160,7 @@ void QgsFileDownloader::onFinished()
161160
if ( mReply->error() )
162161
{
163162
mFile.remove();
164-
error( tr( "Download failed: %1." ).arg( mReply->errorString() ) );
163+
error( tr( "Download failed: %1" ).arg( mReply->errorString() ) );
165164
}
166165
else if ( !redirectionTarget.isNull() )
167166
{
@@ -174,8 +173,10 @@ void QgsFileDownloader::onFinished()
174173
startDownload();
175174
return;
176175
}
177-
// All done
178-
emit downloadCompleted();
176+
else
177+
{
178+
emit downloadCompleted();
179+
}
179180
}
180181
emit downloadExited();
181182
this->deleteLater();

‎tests/src/gui/testqgsfiledownloader.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ class TestQgsFileDownloader: public QObject
7878

7979
void testValidDownload();
8080
void testInValidDownload();
81-
void testCanceledDownload();
8281
void testInvalidFile();
82+
void testCanceledDownload();
8383
void testInvalidUrl();
8484
void testBlankUrl();
8585
#ifndef QT_NO_SSL
@@ -172,7 +172,7 @@ void TestQgsFileDownloader::testInValidDownload()
172172
QVERIFY( mError );
173173
QVERIFY( !mCanceled );
174174
QVERIFY( mTempFile->size() == 0 );
175-
QCOMPARE( mErrorMessage, QString( "Network error 3: Host www.doesnotexistofthatimsure.qgis not found" ) );
175+
QCOMPARE( mErrorMessage, QString( "Download failed: Host www.doesnotexistofthatimsure.qgis not found" ) );
176176
}
177177

178178
void TestQgsFileDownloader::testCanceledDownload()
@@ -184,7 +184,7 @@ void TestQgsFileDownloader::testCanceledDownload()
184184
QVERIFY( !mError );
185185
QVERIFY( mProgress );
186186
QVERIFY( mCanceled );
187-
QVERIFY( mTempFile->size() == 0 );
187+
QVERIFY( !mTempFile->exists() );
188188
}
189189

190190
void TestQgsFileDownloader::testInvalidFile()
@@ -205,7 +205,7 @@ void TestQgsFileDownloader::testInvalidUrl()
205205
QVERIFY( !mCompleted );
206206
QVERIFY( mError );
207207
QVERIFY( !mCanceled );
208-
QCOMPARE( mErrorMessage, QString( "Network error 301: Protocol \"xyz\" is unknown" ) );
208+
QCOMPARE( mErrorMessage, QString( "Download failed: Protocol \"xyz\" is unknown" ) );
209209
}
210210

211211
void TestQgsFileDownloader::testBlankUrl()
@@ -216,7 +216,7 @@ void TestQgsFileDownloader::testBlankUrl()
216216
QVERIFY( !mCompleted );
217217
QVERIFY( mError );
218218
QVERIFY( !mCanceled );
219-
QCOMPARE( mErrorMessage, QString( "Network error 301: Protocol \"\" is unknown" ) );
219+
QCOMPARE( mErrorMessage, QString( "Download failed: Protocol \"\" is unknown" ) );
220220
}
221221

222222
#ifndef QT_NO_SSL
@@ -226,11 +226,11 @@ void TestQgsFileDownloader::testSslError_data()
226226
QTest::addColumn<QString>( "result" );
227227

228228
QTest::newRow( "expired" ) << "https://expired.badssl.com/"
229-
<< "Network error 6: SSL handshake failed;SSL Errors: ;The certificate has expired";
229+
<< "SSL Errors: ;The certificate has expired";
230230
QTest::newRow( "self-signed" ) << "https://self-signed.badssl.com/"
231-
<< "Network error 6: SSL handshake failed;SSL Errors: ;The certificate is self-signed, and untrusted";
231+
<< "SSL Errors: ;The certificate is self-signed, and untrusted";
232232
QTest::newRow( "untrusted-root" ) << "https://untrusted-root.badssl.com/"
233-
<< "Network error 6: SSL handshake failed;No certificates could be verified;SSL Errors: ;The issuer certificate of a locally looked up certificate could not be found";
233+
<< "No certificates could be verified;SSL Errors: ;The issuer certificate of a locally looked up certificate could not be found";
234234
}
235235

236236
void TestQgsFileDownloader::testSslError()

‎tests/src/python/test_qgsfiledownloader.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def test_inValidDownload(self):
7878
self.assertTrue(self.progress_was_called)
7979
self.assertFalse(self.canceled_was_called)
8080
self.assertTrue(self.error_was_called)
81-
self.assertEqual(self.error_args[1], [u'Network error 3: Host www.doesnotexistofthatimsure.qgis not found'])
81+
self.assertEqual(self.error_args[1], [u'Download failed: Host www.doesnotexistofthatimsure.qgis not found'])
8282
self.assertFalse(os.path.isfile(destination))
8383

8484
def test_dowloadCanceled(self):
@@ -99,7 +99,7 @@ def test_InvalidUrl(self):
9999
self.assertFalse(self.canceled_was_called)
100100
self.assertTrue(self.error_was_called)
101101
self.assertFalse(os.path.isfile(destination))
102-
self.assertEqual(self.error_args[1], [u"Network error 301: Protocol \"xyz\" is unknown"])
102+
self.assertEqual(self.error_args[1], [u"Download failed: Protocol \"xyz\" is unknown"])
103103

104104
def test_InvalidFile(self):
105105
self._make_download('https://github.com/qgis/QGIS/archive/master.zip', "")
@@ -117,7 +117,7 @@ def test_BlankUrl(self):
117117
self.assertFalse(self.canceled_was_called)
118118
self.assertTrue(self.error_was_called)
119119
self.assertFalse(os.path.isfile(destination))
120-
self.assertEqual(self.error_args[1], [u"Network error 301: Protocol \"\" is unknown"])
120+
self.assertEqual(self.error_args[1], [u"Download failed: Protocol \"\" is unknown"])
121121

122122
def ssl_compare(self, name, url, error):
123123
destination = tempfile.mktemp()
@@ -133,9 +133,9 @@ def ssl_compare(self, name, url, error):
133133
self.assertTrue(result.startswith(error), msg + "expected:\n%s\nactual:\n%s\n" % (result, error))
134134

135135
def test_sslExpired(self):
136-
self.ssl_compare("expired", "https://expired.badssl.com/", "Network error 6: SSL handshake failed;SSL Errors: ;The certificate has expired")
137-
self.ssl_compare("self-signed", "https://self-signed.badssl.com/", "Network error 6: SSL handshake failed;SSL Errors: ;The certificate is self-signed, and untrusted")
138-
self.ssl_compare("untrusted-root", "https://untrusted-root.badssl.com/", "Network error 6: SSL handshake failed;No certificates could be verified;")
136+
self.ssl_compare("expired", "https://expired.badssl.com/", "SSL Errors: ;The certificate has expired")
137+
self.ssl_compare("self-signed", "https://self-signed.badssl.com/", "SSL Errors: ;The certificate is self-signed, and untrusted")
138+
self.ssl_compare("untrusted-root", "https://untrusted-root.badssl.com/", "No certificates could be verified;SSL Errors: ;The issuer certificate of a locally looked up certificate could not be found")
139139

140140
def _set_slot(self, *args, **kwargs):
141141
#print('_set_slot(%s) called' % args[0])

0 commit comments

Comments
 (0)
Please sign in to comment.