diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc index 622e255f9..a706d92dd 100644 --- a/CHANGELOG.asciidoc +++ b/CHANGELOG.asciidoc @@ -38,6 +38,8 @@ Fixed authentication dialogs) - Fixed crash when a notification/geolocation prompt is answered after closing the tab it belongs to. +- Fixed crash when downloading a file without any path information (e.g a + magnet link). v0.5.1 ------ diff --git a/qutebrowser/browser/downloads.py b/qutebrowser/browser/downloads.py index 448ab120e..8c977fb34 100644 --- a/qutebrowser/browser/downloads.py +++ b/qutebrowser/browser/downloads.py @@ -774,7 +774,10 @@ class DownloadManager(QAbstractListModel): # https://bugreports.qt.io/browse/QTBUG-42757 request.setAttribute(QNetworkRequest.CacheLoadControlAttribute, QNetworkRequest.AlwaysNetwork) + suggested_fn = urlutils.filename_from_url(request.url()) + if suggested_fn is None: + suggested_fn = 'qutebrowser-download' # We won't need a question if a filename or fileobj is already given if fileobj is None and filename is None: diff --git a/tests/integration/data/downloads/issue1243.html b/tests/integration/data/downloads/issue1243.html new file mode 100644 index 000000000..d8acd22d3 --- /dev/null +++ b/tests/integration/data/downloads/issue1243.html @@ -0,0 +1,10 @@ + + + + + Crash when trying to get filename from custom URL + + + download + + diff --git a/tests/integration/features/downloads.feature b/tests/integration/features/downloads.feature index 8ed43f8e0..5881767f6 100644 --- a/tests/integration/features/downloads.feature +++ b/tests/integration/features/downloads.feature @@ -24,6 +24,16 @@ Feature: Downloading things from a website. And I wait for the error "Download error: * - server replied: NOT FOUND" Then no crash should happen + Scenario: Downloading a link without path information (issue 1243) + When I set completion -> download-path-suggestion to filename + And I set storage -> prompt-download-directory to true + And I open data/downloads/issue1243.html + And I run :hint links download + And I run :follow-hint a + And I wait for "Asking question text='Save file to:'>, *" in the log + And I run :leave-mode + Then no crash should happen + Scenario: Retrying a failed download When I run :download http://localhost:(port)/does-not-exist And I wait for the error "Download error: * - server replied: NOT FOUND"