diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc index e90327567..4e96af7bc 100644 --- a/CHANGELOG.asciidoc +++ b/CHANGELOG.asciidoc @@ -30,6 +30,7 @@ Fixed - Version checks when starting qutebrowser now also take the Qt version PyQt was compiled against into account - Hinting a input now doesn't select existing text anymore with QtWebKit - The cursor now moves to the end when input elements are selected with QtWebEngine +- Download suffixes like (1) are now correctly stripped with QtWebEngine v0.10.0 ------- diff --git a/qutebrowser/browser/webengine/webenginedownloads.py b/qutebrowser/browser/webengine/webenginedownloads.py index 59a81df69..070bcf8c0 100644 --- a/qutebrowser/browser/webengine/webenginedownloads.py +++ b/qutebrowser/browser/webengine/webenginedownloads.py @@ -144,7 +144,7 @@ def _get_suggested_filename(path): See https://bugreports.qt.io/browse/QTBUG-56978 """ filename = os.path.basename(path) - filename = re.sub(r'\([0-9]+\)$', '', filename) + filename = re.sub(r'\([0-9]+\)(?=\.|$)', '', filename) if not qtutils.version_check('5.8.1'): # https://bugreports.qt.io/browse/QTBUG-58155 filename = urllib.parse.unquote(filename) diff --git a/tests/end2end/test_invocations.py b/tests/end2end/test_invocations.py index 4b18b57e2..072ff192a 100644 --- a/tests/end2end/test_invocations.py +++ b/tests/end2end/test_invocations.py @@ -219,3 +219,32 @@ def test_webengine_inspector(request, quteproc_new): s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect(('127.0.0.1', port)) s.close() + + +@pytest.mark.linux +def test_webengine_download_suffix(request, quteproc_new, tmpdir): + """Make sure QtWebEngine does not add a suffix to downloads.""" + if not request.config.webengine: + pytest.skip() + + download_dir = tmpdir / 'downloads' + download_dir.ensure(dir=True) + + (tmpdir / 'user-dirs.dirs').write( + 'XDG_DOWNLOAD_DIR={}'.format(download_dir)) + env = {'XDG_CONFIG_HOME': str(tmpdir)} + args = (['--temp-basedir'] + _base_args(request.config)) + quteproc_new.start(args, env=env) + + quteproc_new.set_setting('storage', 'prompt-download-directory', 'false') + quteproc_new.set_setting('storage', 'download-directory', str(download_dir)) + quteproc_new.open_path('data/downloads/download.bin', wait=False) + quteproc_new.wait_for(category='downloads', message='Download * finished') + quteproc_new.open_path('data/downloads/download.bin', wait=False) + quteproc_new.wait_for(message='Entering mode KeyMode.yesno *') + quteproc_new.send_cmd(':prompt-accept yes') + quteproc_new.wait_for(category='downloads', message='Download * finished') + + files = download_dir.listdir() + assert len(files) == 1 + assert files[0].basename == 'download.bin'