parent
c23e4b1c5f
commit
a081d4184d
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user