diff --git a/tests/end2end/features/downloads.feature b/tests/end2end/features/downloads.feature index 768521183..b1dd5155b 100644 --- a/tests/end2end/features/downloads.feature +++ b/tests/end2end/features/downloads.feature @@ -121,14 +121,22 @@ Feature: Downloading things from a website. And I wait until the download is finished Then the downloaded file download with spaces.bin should exist - @qtwebkit_skip - Scenario: Downloading a file with evil content-disposition header + @qtwebkit_skip @qt<5.9 + Scenario: Downloading a file with evil content-disposition header (Qt 5.8 or older) # Content-Disposition: download; filename=..%2Ffoo When I open response-headers?Content-Disposition=download;%20filename%3D..%252Ffoo without waiting And I wait until the download is finished Then the downloaded file ../foo should not exist And the downloaded file foo should exist + @qtwebkit_skip @qt>=5.9 + Scenario: Downloading a file with evil content-disposition header (Qt 5.9 or newer) + # Content-Disposition: download; filename=..%2Ffoo + When I open response-headers?Content-Disposition=download;%20filename%3D..%252Ffoo without waiting + And I wait until the download is finished + Then the downloaded file ../foo should not exist + And the downloaded file ..%2Ffoo should exist + @windows Scenario: Downloading a file to a reserved path When I set storage -> prompt-download-directory to true diff --git a/tests/unit/browser/webengine/test_webenginedownloads.py b/tests/unit/browser/webengine/test_webenginedownloads.py index ee5b8e22a..735852cd3 100644 --- a/tests/unit/browser/webengine/test_webenginedownloads.py +++ b/tests/unit/browser/webengine/test_webenginedownloads.py @@ -24,6 +24,12 @@ import pytest pytest.importorskip('PyQt5.QtWebEngineWidgets') from qutebrowser.browser.webengine import webenginedownloads +from qutebrowser.utils import qtutils + +qt58 = pytest.mark.skipif( + qtutils.version_check('5.9'), reason="Needs Qt 5.8 or earlier") +qt59 = pytest.mark.skipif( + not qtutils.version_check('5.9'), reason="Needs Qt 5.9 or newer") @pytest.mark.parametrize('path, expected', [ @@ -31,8 +37,10 @@ from qutebrowser.browser.webengine import webenginedownloads ('foo(1)', 'foo'), ('foo(a)', 'foo(a)'), ('foo1', 'foo1'), - ('foo%20bar', 'foo bar'), - ('foo%2Fbar', 'bar'), + qt58(('foo%20bar', 'foo bar')), + qt58(('foo%2Fbar', 'bar')), + qt59(('foo%20bar', 'foo%20bar')), + qt59(('foo%2Fbar', 'foo%2Fbar')), ]) def test_get_suggested_filename(path, expected): assert webenginedownloads._get_suggested_filename(path) == expected