From 5b7090e40236f428ee55592b38c03f1cc3e5bf60 Mon Sep 17 00:00:00 2001 From: Tomasz Kramkowski Date: Sat, 18 Feb 2017 19:04:25 +0000 Subject: [PATCH 1/3] browser/navigate: _find_nextprev allow for space sep rel attribs The _find_nextprev function of browser/navigate.py only checks to see if the rell attribute equals 'prev', 'previous', or 'next'. This patch changes this to check for a set intersection between {'prev', 'previous'} or {'next'} and the set of the space separated list of the rel attribute. --- qutebrowser/browser/navigate.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/qutebrowser/browser/navigate.py b/qutebrowser/browser/navigate.py index 5abfbe0b4..aacec9d3c 100644 --- a/qutebrowser/browser/navigate.py +++ b/qutebrowser/browser/navigate.py @@ -70,11 +70,11 @@ def path_up(url, count): def _find_prevnext(prev, elems): """Find a prev/next element in the given list of elements.""" # First check for - rel_values = ('prev', 'previous') if prev else ('next') + rel_values = {'prev', 'previous'} if prev else {'next'} for e in elems: if e.tag_name() not in ['link', 'a'] or 'rel' not in e: continue - if e['rel'] in rel_values: + if set(e['rel'].split(' ')) & rel_values: log.hints.debug("Found {!r} with rel={}".format(e, e['rel'])) return e From 1fcba72958d61077c8dab804114546a9b02ff29e Mon Sep 17 00:00:00 2001 From: Tomasz Kramkowski Date: Sun, 19 Feb 2017 12:32:19 +0000 Subject: [PATCH 2/3] tests navigate: Add tests for rel attributes with nofollow Add two extra tests for checking navigation on pages with rel "next" and "prev" links which are also rel "nofollow" to test for the correct functionality of navigating pages with rel "next" and "prev" links with multiple rel attributes. --- tests/end2end/data/navigate/rel_nofollow.html | 12 ++++++++++++ tests/end2end/features/navigate.feature | 10 ++++++++++ 2 files changed, 22 insertions(+) create mode 100644 tests/end2end/data/navigate/rel_nofollow.html diff --git a/tests/end2end/data/navigate/rel_nofollow.html b/tests/end2end/data/navigate/rel_nofollow.html new file mode 100644 index 000000000..d6f7fd3e8 --- /dev/null +++ b/tests/end2end/data/navigate/rel_nofollow.html @@ -0,0 +1,12 @@ + + + + + Navigate + + +

Index page

+ bla + blub + + diff --git a/tests/end2end/features/navigate.feature b/tests/end2end/features/navigate.feature index 4b6b7f82e..5153400a4 100644 --- a/tests/end2end/features/navigate.feature +++ b/tests/end2end/features/navigate.feature @@ -53,6 +53,16 @@ Feature: Using :navigate And I run :navigate next Then data/navigate/next.html should be loaded + Scenario: Navigating to previous page with rel nofollow + When I open data/navigate/rel_nofollow.html + And I run :navigate prev + Then data/navigate/prev.html should be loaded + + Scenario: Navigating to next page with rel nofollow + When I open data/navigate/rel_nofollow.html + And I run :navigate next + Then data/navigate/next.html should be loaded + # increment/decrement Scenario: Incrementing number in URL From 53ec3e8a439f7ffbd8dda4d2378cefbc50d10bb2 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Sun, 19 Feb 2017 20:23:54 +0100 Subject: [PATCH 3/3] Update docs --- CHANGELOG.asciidoc | 3 ++- README.asciidoc | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc index da50a87af..5075cf505 100644 --- a/CHANGELOG.asciidoc +++ b/CHANGELOG.asciidoc @@ -66,7 +66,8 @@ Fixed - Fixed showing of keybindings in the :help completion - Worked around a segfault when opening a URL after a QtWebEngine renderer process crash - Using :undo or :tab-clone with a view-source:// or chrome:// tab is now prevented, as it segfaults -- `:navigate prev/next` now detects `rel` attributes on `` elements +- `:navigate prev/next` now detects `rel` attributes on `` elements, and + handles multiple `rel` attributes correctly. - Fixed a crash when hinting with target `userscript` and spawning a non-existing script v0.9.1 diff --git a/README.asciidoc b/README.asciidoc index dc3b427df..a834171d3 100644 --- a/README.asciidoc +++ b/README.asciidoc @@ -187,6 +187,7 @@ Contributors, sorted by the number of commits in descending order: * knaggita * Oliver Caldwell * Julian Weigt +* Tomasz Kramkowski * Sebastian Frysztak * Nikolay Amiantov * Jonas Schürmann @@ -196,7 +197,6 @@ Contributors, sorted by the number of commits in descending order: * Julie Engel * skinnay * Zach-Button -* Tomasz Kramkowski * Samuel Walladge * Peter Rice * Ismail S