From 5b1d35bef99a135bd6199cc8283fcde89d4fc1fb Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Mon, 15 May 2017 09:04:16 +0200 Subject: [PATCH] Don't add data: URLs to history --- CHANGELOG.asciidoc | 1 + qutebrowser/browser/history.py | 2 ++ tests/end2end/data/data_link.html | 10 ++++++++++ tests/end2end/data/downloads/issue1214.html | 10 ---------- tests/end2end/features/downloads.feature | 2 +- tests/end2end/features/history.feature | 13 +++++++++++++ tests/end2end/fixtures/quteprocess.py | 3 ++- 7 files changed, 29 insertions(+), 12 deletions(-) create mode 100644 tests/end2end/data/data_link.html delete mode 100644 tests/end2end/data/downloads/issue1214.html diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc index c352eb994..8d0bf22f3 100644 --- a/CHANGELOG.asciidoc +++ b/CHANGELOG.asciidoc @@ -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 ------- diff --git a/qutebrowser/browser/history.py b/qutebrowser/browser/history.py index d05d4b01c..7cee19de3 100644 --- a/qutebrowser/browser/history.py +++ b/qutebrowser/browser/history.py @@ -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 diff --git a/tests/end2end/data/data_link.html b/tests/end2end/data/data_link.html new file mode 100644 index 000000000..227a9f2f9 --- /dev/null +++ b/tests/end2end/data/data_link.html @@ -0,0 +1,10 @@ + + + + + data: link + + + download + + diff --git a/tests/end2end/data/downloads/issue1214.html b/tests/end2end/data/downloads/issue1214.html deleted file mode 100644 index db56cdc61..000000000 --- a/tests/end2end/data/downloads/issue1214.html +++ /dev/null @@ -1,10 +0,0 @@ - - - - - Wrong filename when using data: links - - - download - - diff --git a/tests/end2end/features/downloads.feature b/tests/end2end/features/downloads.feature index b1dd5155b..5959014df 100644 --- a/tests/end2end/features/downloads.feature +++ b/tests/end2end/features/downloads.feature @@ -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 text=* title='Save file to:'>, *" in the log And I run :leave-mode diff --git a/tests/end2end/features/history.feature b/tests/end2end/features/history.feature index 613b660af..8231d3fe0 100644 --- a/tests/end2end/features/history.feature +++ b/tests/end2end/features/history.feature @@ -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 diff --git a/tests/end2end/fixtures/quteprocess.py b/tests/end2end/fixtures/quteprocess.py index 040110e77..97842c6c7 100644 --- a/tests/end2end/fixtures/quteprocess.py +++ b/tests/end2end/fixtures/quteprocess.py @@ -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: