Decode percent sequences in QtWebEngine downloads

Fixes #2122.
This commit is contained in:
Florian Bruhin 2016-12-09 07:08:51 +01:00
parent 03eea7f62a
commit d0372f1730
4 changed files with 8 additions and 0 deletions

View File

@ -21,6 +21,7 @@
import re import re
import os.path import os.path
import urllib
import functools import functools
from PyQt5.QtCore import pyqtSlot, Qt from PyQt5.QtCore import pyqtSlot, Qt
@ -135,6 +136,7 @@ def _get_suggested_filename(path):
""" """
filename = os.path.basename(path) filename = os.path.basename(path)
filename = re.sub(r'\([0-9]+\)$', '', filename) filename = re.sub(r'\([0-9]+\)$', '', filename)
filename = urllib.parse.unquote(filename)
return filename return filename

Binary file not shown.

View File

@ -113,6 +113,11 @@ Feature: Downloading things from a website.
And I wait for "Download drip finished" in the log And I wait for "Download drip finished" in the log
Then the downloaded file drip should contain 128 bytes Then the downloaded file drip should contain 128 bytes
Scenario: Downloading a file with spaces
When I open data/downloads/download with spaces.bin without waiting
And I wait until the download is finished
Then the downloaded file download with spaces.bin should exist
## :download-retry ## :download-retry
Scenario: Retrying a failed download Scenario: Retrying a failed download

View File

@ -29,6 +29,7 @@ from qutebrowser.browser.webengine import webenginedownloads
('foo(1)', 'foo'), ('foo(1)', 'foo'),
('foo(a)', 'foo(a)'), ('foo(a)', 'foo(a)'),
('foo1', 'foo1'), ('foo1', 'foo1'),
('foo%20bar', 'foo bar'),
]) ])
def test_get_suggested_filename(path, expected): def test_get_suggested_filename(path, expected):
assert webenginedownloads._get_suggested_filename(path) == expected assert webenginedownloads._get_suggested_filename(path) == expected