Fix crash when downloading URL without path infos.

Fixes #1243.
This commit is contained in:
Florian Bruhin 2016-01-26 22:37:46 +01:00
parent ea1627c1e6
commit 85adf7593d
4 changed files with 25 additions and 0 deletions

View File

@ -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
------

View File

@ -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:

View File

@ -0,0 +1,10 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Crash when trying to get filename from custom URL</title>
</head>
<body>
<a href="qute://">download</a>
</body>
</html>

View File

@ -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 <qutebrowser.utils.usertypes.Question default='qutebrowser-download' mode=<PromptMode.text: 2> 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"