Don't add data: URLs to history

This commit is contained in:
Florian Bruhin 2017-05-15 09:04:16 +02:00
parent 920dde4a68
commit 5b1d35bef9
7 changed files with 29 additions and 12 deletions

View File

@ -78,6 +78,7 @@ Fixed
- Various styling issues with the tabbar and a crash with qt5ct
- The validation for colors in stylesheets is now less strict,
allowing for all valid Qt values.
- data: URLs now aren't added to the history anymore.
v0.10.1
-------

View File

@ -257,6 +257,8 @@ class WebHistory(QObject):
@pyqtSlot(QUrl, QUrl, str)
def add_from_tab(self, url, requested_url, title):
"""Add a new history entry as slot, called from a BrowserTab."""
if url.scheme() == 'data' or requested_url.scheme() == 'data':
return
if url.isEmpty():
# things set via setHtml
return

View File

@ -0,0 +1,10 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>data: link</title>
</head>
<body>
<a href="data:;base64,cXV0ZWJyb3dzZXI=" id="link">download</a>
</body>
</html>

View File

@ -1,10 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Wrong filename when using data: links</title>
</head>
<body>
<a href="data:;base64,cXV0ZWJyb3dzZXI=">download</a>
</body>
</html>

View File

@ -71,7 +71,7 @@ Feature: Downloading things from a website.
Scenario: Downloading a data: link (issue 1214)
When I set completion -> download-path-suggestion to filename
And I set storage -> prompt-download-directory to true
And I open data/downloads/issue1214.html
And I open data/data_link.html
And I hint with args "links download" and follow a
And I wait for "Asking question <qutebrowser.utils.usertypes.Question default='binary blob' mode=<PromptMode.download: 5> text=* title='Save file to:'>, *" in the log
And I run :leave-mode

View File

@ -57,6 +57,19 @@ Feature: Page history
And I run :click-element id open-invalid
Then "Changing title for idx 1 to 'about:blank'" should be logged
Scenario: History with data URL
When I open data/data_link.html
And I run :click-element id link
And I wait until data:;base64,cXV0ZWJyb3dzZXI= is loaded
Then the history file should contain:
http://localhost:(port)/data/data_link.html data: link
Scenario: History with view-source URL
When I open data/title.html
And I run :view-source
Then the history file should contain:
http://localhost:(port)/data/title.html Test title
Scenario: Clearing history
When I open data/title.html
And I run :history-clear --force

View File

@ -314,7 +314,8 @@ class QuteProc(testprocess.Process):
URLs like about:... and qute:... are handled specially and returned
verbatim.
"""
special_schemes = ['about:', 'qute:', 'chrome:', 'view-source:']
special_schemes = ['about:', 'qute:', 'chrome:', 'view-source:',
'data:']
if any(path.startswith(scheme) for scheme in special_schemes):
return path
else: