From aab749691649c18eda87d96ba665a1a67ba89861 Mon Sep 17 00:00:00 2001 From: dwagle Date: Mon, 30 Oct 2017 17:09:45 +0545 Subject: [PATCH 1/4] fixes issue #3161 --- qutebrowser/browser/qutescheme.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/qutebrowser/browser/qutescheme.py b/qutebrowser/browser/qutescheme.py index 2498ea7f6..518012f10 100644 --- a/qutebrowser/browser/qutescheme.py +++ b/qutebrowser/browser/qutescheme.py @@ -141,10 +141,16 @@ def data_for_url(url): # A url like "qute:foo" is split as "scheme:path", not "scheme:host". log.misc.debug("url: {}, path: {}, host {}".format( url.toDisplayString(), path, host)) - if path and not host: + if not path or not host: new_url = QUrl() new_url.setScheme('qute') - new_url.setHost(path) + # When path is absent, e.g. qute://help (with no trailing slash) + if host: + new_url.setHost(host) + # When host is absent, e.g. qute:help + else: + new_url.setHost(path) + new_url.setPath('/') if new_url.host(): # path was a valid host raise Redirect(new_url) From 4c9482be8468a5ec65840a5bd6c319464ecf2843 Mon Sep 17 00:00:00 2001 From: dwagle Date: Mon, 30 Oct 2017 17:49:22 +0545 Subject: [PATCH 2/4] added a Scenario: Opening link with qute://help to tests/end2end/features/qutescheme.feature --- tests/end2end/features/qutescheme.feature | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/end2end/features/qutescheme.feature b/tests/end2end/features/qutescheme.feature index afa791be9..8b1a156a0 100644 --- a/tests/end2end/features/qutescheme.feature +++ b/tests/end2end/features/qutescheme.feature @@ -55,6 +55,14 @@ Feature: Special qute:// pages And I hint with args "links normal" and follow a Then qute://help/quickstart.html should be loaded + Scenario: Opening a link with qute://help + When the documentation is up to date + And I run :tab-only + And I open qute://help + And I wait until qute://help/ is loaded + And I hint with args "links normal" and follow a + Then qute://help/quickstart.html should be loaded + # :history Scenario: :history without arguments From f70740cc3aa25e65e7290ab0a4c1a1fd6e266167 Mon Sep 17 00:00:00 2001 From: dwagle Date: Tue, 31 Oct 2017 11:47:06 +0545 Subject: [PATCH 3/4] set original query parameters if any before redirecting to new_url --- qutebrowser/browser/qutescheme.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/qutebrowser/browser/qutescheme.py b/qutebrowser/browser/qutescheme.py index 518012f10..0c4f611f5 100644 --- a/qutebrowser/browser/qutescheme.py +++ b/qutebrowser/browser/qutescheme.py @@ -138,6 +138,7 @@ def data_for_url(url): """ path = url.path() host = url.host() + query = url.query() # A url like "qute:foo" is split as "scheme:path", not "scheme:host". log.misc.debug("url: {}, path: {}, host {}".format( url.toDisplayString(), path, host)) @@ -152,6 +153,8 @@ def data_for_url(url): new_url.setHost(path) new_url.setPath('/') + if query: + new_url.setQuery(query) if new_url.host(): # path was a valid host raise Redirect(new_url) From 95539961a4b7ad6d1a11c76263c15c0744de16cf Mon Sep 17 00:00:00 2001 From: dwagle Date: Tue, 31 Oct 2017 12:08:43 +0545 Subject: [PATCH 4/4] made some adjustments in tests/end2end/features/qutescheme.feature for the tests to pass. These are to account for changes made in f70740c, 4c9482b and aab7496 --- tests/end2end/features/qutescheme.feature | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/end2end/features/qutescheme.feature b/tests/end2end/features/qutescheme.feature index 8b1a156a0..43558cf60 100644 --- a/tests/end2end/features/qutescheme.feature +++ b/tests/end2end/features/qutescheme.feature @@ -58,7 +58,7 @@ Feature: Special qute:// pages Scenario: Opening a link with qute://help When the documentation is up to date And I run :tab-only - And I open qute://help + And I open qute://help without waiting And I wait until qute://help/ is loaded And I hint with args "links normal" and follow a Then qute://help/quickstart.html should be loaded @@ -147,12 +147,12 @@ Feature: Special qute:// pages Scenario: Running :pyeval When I run :debug-pyeval 1+1 - And I wait until qute://pyeval is loaded + And I wait until qute://pyeval/ is loaded Then the page should contain the plaintext "2" Scenario: Causing exception in :pyeval When I run :debug-pyeval 1/0 - And I wait until qute://pyeval is loaded + And I wait until qute://pyeval/ is loaded Then the page should contain the plaintext "ZeroDivisionError" Scenario: Running :pyeval with --quiet @@ -166,7 +166,7 @@ Feature: Special qute:// pages And I run :message-warning the-warning-message And I run :message-info the-info-message And I run :messages - Then qute://log?level=info should be loaded + Then qute://log/?level=info should be loaded And the error "the-error-message" should be shown And the warning "the-warning-message" should be shown And the page should contain the plaintext "the-error-message" @@ -178,7 +178,7 @@ Feature: Special qute:// pages And I run :message-warning the-warning-message And I run :message-info the-info-message And I run :messages warning - Then qute://log?level=warning should be loaded + Then qute://log/?level=warning should be loaded And the error "the-error-message" should be shown And the warning "the-warning-message" should be shown And the page should contain the plaintext "the-error-message" @@ -190,7 +190,7 @@ Feature: Special qute:// pages And I run :message-warning the-warning-message And I run :message-info the-info-message And I run :messages info - Then qute://log?level=info should be loaded + Then qute://log/?level=info should be loaded And the error "the-error-message" should be shown And the warning "the-warning-message" should be shown And the page should contain the plaintext "the-error-message"