From 085d1e9c10bd5bf5fdd617baa1c3f7f363492ace Mon Sep 17 00:00:00 2001 From: cryzed Date: Mon, 14 Aug 2017 00:30:45 +0200 Subject: [PATCH 01/25] :save-session --only-active-window implies --with-private for private windows --- qutebrowser/misc/sessions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qutebrowser/misc/sessions.py b/qutebrowser/misc/sessions.py index 54ba35014..4bce00ae3 100644 --- a/qutebrowser/misc/sessions.py +++ b/qutebrowser/misc/sessions.py @@ -485,7 +485,7 @@ class SessionManager(QObject): try: if only_active_window: name = self.save(name, only_window=win_id, - with_private=with_private) + with_private=True) else: name = self.save(name, with_private=with_private) except SessionError as e: From c60753731973946c4e8a565970fcd8af24ac44cf Mon Sep 17 00:00:00 2001 From: Ryan Roden-Corrent Date: Mon, 14 Aug 2017 21:37:43 -0400 Subject: [PATCH 02/25] Consistently format urls in history. Encode urls that are inserted into the history, but do not encode urls for completion (other than removing passwords). Also ensure that urls read from the history text file are formatted consistenly with those added while browsing. Fixes #2903. --- qutebrowser/browser/history.py | 16 ++++++++++----- tests/unit/browser/test_history.py | 32 +++++++++++++++++------------- 2 files changed, 29 insertions(+), 19 deletions(-) diff --git a/qutebrowser/browser/history.py b/qutebrowser/browser/history.py index 86e597bcd..60c3f3e36 100644 --- a/qutebrowser/browser/history.py +++ b/qutebrowser/browser/history.py @@ -159,13 +159,12 @@ class WebHistory(sql.SqlTable): return atime = int(atime) if (atime is not None) else int(time.time()) - url_str = url.toString(QUrl.FullyEncoded | QUrl.RemovePassword) - self.insert({'url': url_str, + self.insert({'url': self._format_url(url), 'title': title, 'atime': atime, 'redirect': redirect}) if not redirect: - self.completion.insert({'url': url_str, + self.completion.insert({'url': self._format_completion_url(url), 'title': title, 'last_atime': atime}, replace=True) @@ -249,12 +248,13 @@ class WebHistory(sql.SqlTable): if parsed is None: continue url, title, atime, redirect = parsed - data['url'].append(url) + data['url'].append(self._format_url(url)) data['title'].append(title) data['atime'].append(atime) data['redirect'].append(redirect) if not redirect: - completion_data['url'].append(url) + completion_data['url'].append( + self._format_completion_url(url)) completion_data['title'].append(title) completion_data['last_atime'].append(atime) except ValueError as ex: @@ -263,6 +263,12 @@ class WebHistory(sql.SqlTable): self.insert_batch(data) self.completion.insert_batch(completion_data, replace=True) + def _format_url(self, url): + return url.toString(QUrl.RemovePassword | QUrl.FullyEncoded) + + def _format_completion_url(self, url): + return url.toString(QUrl.RemovePassword) + @cmdutils.register(instance='web-history', debug=True) def debug_dump_history(self, dest): """Dump the history to a file in the old pre-SQL format. diff --git a/tests/unit/browser/test_history.py b/tests/unit/browser/test_history.py index c109f44eb..0c6f65683 100644 --- a/tests/unit/browser/test_history.py +++ b/tests/unit/browser/test_history.py @@ -143,23 +143,27 @@ def test_delete_url(hist): assert completion_diff == {('http://example.com/1', '', 0)} -@pytest.mark.parametrize('url, atime, title, redirect, expected_url', [ - ('http://www.example.com', 12346, 'the title', False, - 'http://www.example.com'), - ('http://www.example.com', 12346, 'the title', True, - 'http://www.example.com'), - ('http://www.example.com/spa ce', 12346, 'the title', False, - 'http://www.example.com/spa%20ce'), - ('https://user:pass@example.com', 12346, 'the title', False, - 'https://user@example.com'), -]) -def test_add_url(qtbot, hist, url, atime, title, redirect, expected_url): +@pytest.mark.parametrize( + 'url, atime, title, redirect, history_url, completion_url', [ + + ('http://www.example.com', 12346, 'the title', False, + 'http://www.example.com', 'http://www.example.com'), + ('http://www.example.com', 12346, 'the title', True, + 'http://www.example.com', None), + ('http://www.example.com/sp ce', 12346, 'the title', False, + 'http://www.example.com/sp%20ce', 'http://www.example.com/sp ce'), + ('https://user:pass@example.com', 12346, 'the title', False, + 'https://user@example.com', 'https://user@example.com'), + ] +) +def test_add_url(qtbot, hist, url, atime, title, redirect, history_url, + completion_url): hist.add_url(QUrl(url), atime=atime, title=title, redirect=redirect) - assert list(hist) == [(expected_url, title, atime, redirect)] - if redirect: + assert list(hist) == [(history_url, title, atime, redirect)] + if completion_url is None: assert not len(hist.completion) else: - assert list(hist.completion) == [(expected_url, title, atime)] + assert list(hist.completion) == [(completion_url, title, atime)] def test_add_url_invalid(qtbot, hist, caplog): From 7073c33dce5896d5158aa551743bac8221ac8ed9 Mon Sep 17 00:00:00 2001 From: Jay Kamat Date: Sun, 13 Aug 2017 17:15:04 -0700 Subject: [PATCH 03/25] Test for saving a session with --only-active-window --- tests/end2end/features/private.feature | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/tests/end2end/features/private.feature b/tests/end2end/features/private.feature index 55ded35d7..bd1059e09 100644 --- a/tests/end2end/features/private.feature +++ b/tests/end2end/features/private.feature @@ -153,3 +153,26 @@ Feature: Using private browsing - history: - url: http://localhost:*/data/numbers/1.txt - url: http://localhost:*/data/numbers/2.txt + + + Scenario: Saving a private session with only-active-window + When I open data/numbers/1.txt + And I open data/numbers/2.txt in a new tab + And I open data/numbers/3.txt in a private window + And I open data/numbers/4.txt in a new tab + And I open data/numbers/5.txt in a new tab + And I run :session-save --only-active-window window_session_name + And I run :window-only + And I run :tab-only + And I run :session-load -c window_session_name + And I wait until data/numbers/5.txt is loaded + Then the session should look like: + windows: + - tabs: + - history: + - url: http://localhost:*/data/numbers/3.txt + - history: + - url: http://localhost:*/data/numbers/4.txt + - history: + - active: true + url: http://localhost:*/data/numbers/5.txt From 8c6133e29d3e6ac3489f2d5d4456e5527830613d Mon Sep 17 00:00:00 2001 From: Ryan Roden-Corrent Date: Thu, 17 Aug 2017 07:57:14 -0400 Subject: [PATCH 04/25] Regenerate history completion table if needed. If the HistoryCompletion table is removed, regenerate it from the History table. This allows users to manually edit History, then remove HistoryCompletion to prompt regeneration. See #2903. --- qutebrowser/browser/history.py | 13 +++++++++++++ tests/unit/browser/test_history.py | 14 ++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/qutebrowser/browser/history.py b/qutebrowser/browser/history.py index 60c3f3e36..e046dc72b 100644 --- a/qutebrowser/browser/history.py +++ b/qutebrowser/browser/history.py @@ -48,6 +48,8 @@ class WebHistory(sql.SqlTable): super().__init__("History", ['url', 'title', 'atime', 'redirect'], parent=parent) self.completion = CompletionHistory(parent=self) + if len(self.completion) == 0: + self._rebuild_completion() self.create_index('HistoryIndex', 'url') self.create_index('HistoryAtimeIndex', 'atime') self._contains_query = self.contains_query('url') @@ -71,6 +73,17 @@ class WebHistory(sql.SqlTable): def __contains__(self, url): return self._contains_query.run(val=url).value() + def _rebuild_completion(self): + data = {'url': [], 'title': [], 'last_atime': []} + # select the latest entry for each url + q = sql.Query('SELECT url, title, max(atime) AS atime FROM History ' + 'WHERE NOT redirect GROUP BY url') + for entry in q.run(): + data['url'].append(self._format_completion_url(QUrl(entry.url))) + data['title'].append(entry.title) + data['last_atime'].append(entry.atime) + self.completion.insert_batch(data) + def get_recent(self): """Get the most recent history entries.""" return self.select(sort_by='atime', sort_order='desc', limit=100) diff --git a/tests/unit/browser/test_history.py b/tests/unit/browser/test_history.py index 0c6f65683..ebb8ff206 100644 --- a/tests/unit/browser/test_history.py +++ b/tests/unit/browser/test_history.py @@ -353,3 +353,17 @@ def test_debug_dump_history_nonexistent(hist, tmpdir): histfile = tmpdir / 'nonexistent' / 'history' with pytest.raises(cmdexc.CommandError): hist.debug_dump_history(str(histfile)) + + +def test_rebuild_completion(hist): + hist.add_url(QUrl('example.com/1'), redirect=False, atime=1) + hist.add_url(QUrl('example.com/1'), redirect=False, atime=2) + hist.add_url(QUrl('example.com/2%203'), redirect=False, atime=3) + hist.add_url(QUrl('example.com/3'), redirect=True, atime=4) + hist.completion.delete_all() + + hist2 = history.WebHistory() + assert list(hist2.completion) == [ + ('example.com/1', '', 2), + ('example.com/2 3', '', 3), + ] From 5f45b9b40e76bcd5378d45ed781b5965faf02686 Mon Sep 17 00:00:00 2001 From: Ryan Roden-Corrent Date: Sun, 20 Aug 2017 20:43:31 -0400 Subject: [PATCH 05/25] Fix pylint and coverage for history. --- qutebrowser/browser/history.py | 2 +- tests/unit/browser/test_history.py | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/qutebrowser/browser/history.py b/qutebrowser/browser/history.py index e046dc72b..0b3cf108e 100644 --- a/qutebrowser/browser/history.py +++ b/qutebrowser/browser/history.py @@ -48,7 +48,7 @@ class WebHistory(sql.SqlTable): super().__init__("History", ['url', 'title', 'atime', 'redirect'], parent=parent) self.completion = CompletionHistory(parent=self) - if len(self.completion) == 0: + if not self.completion: self._rebuild_completion() self.create_index('HistoryIndex', 'url') self.create_index('HistoryAtimeIndex', 'atime') diff --git a/tests/unit/browser/test_history.py b/tests/unit/browser/test_history.py index ebb8ff206..6fa160d31 100644 --- a/tests/unit/browser/test_history.py +++ b/tests/unit/browser/test_history.py @@ -367,3 +367,13 @@ def test_rebuild_completion(hist): ('example.com/1', '', 2), ('example.com/2 3', '', 3), ] + + +def test_no_rebuild_completion(hist): + """Ensure that completion is not regenerated unless completely empty.""" + hist.add_url(QUrl('example.com/1'), redirect=False, atime=1) + hist.add_url(QUrl('example.com/2'), redirect=False, atime=2) + hist.completion.delete('url', 'example.com/2') + + hist2 = history.WebHistory() + assert list(hist2.completion) == [('example.com/1', '', 1)] From d35b47c9d8c139986834f2c6603c8d81fd7e00de Mon Sep 17 00:00:00 2001 From: Ryan Roden-Corrent Date: Mon, 21 Aug 2017 08:38:14 -0400 Subject: [PATCH 06/25] Regenerate history completion on version change. Incrementing _USER_VERSION in the source will cause the HistoryCompletion table to regenerate when users update. This is currently necessary to support some recent formatting fixes, but could be incremented again in the future for other changes. --- qutebrowser/browser/history.py | 8 ++++++++ tests/unit/browser/test_history.py | 17 +++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/qutebrowser/browser/history.py b/qutebrowser/browser/history.py index 0b3cf108e..9948992ea 100644 --- a/qutebrowser/browser/history.py +++ b/qutebrowser/browser/history.py @@ -30,6 +30,10 @@ from qutebrowser.utils import (utils, objreg, log, usertypes, message, from qutebrowser.misc import objects, sql +# increment to indicate that HistoryCompletion must be regenerated +_USER_VERSION = 1 + + class CompletionHistory(sql.SqlTable): """History which only has the newest entry for each URL.""" @@ -48,7 +52,10 @@ class WebHistory(sql.SqlTable): super().__init__("History", ['url', 'title', 'atime', 'redirect'], parent=parent) self.completion = CompletionHistory(parent=self) + if sql.Query('pragma user_version').run().value() < _USER_VERSION: + self.completion.delete_all() if not self.completion: + # either the table is out-of-date or the user wiped it manually self._rebuild_completion() self.create_index('HistoryIndex', 'url') self.create_index('HistoryAtimeIndex', 'atime') @@ -83,6 +90,7 @@ class WebHistory(sql.SqlTable): data['title'].append(entry.title) data['last_atime'].append(entry.atime) self.completion.insert_batch(data) + sql.Query('pragma user_version = {}'.format(_USER_VERSION)).run() def get_recent(self): """Get the most recent history entries.""" diff --git a/tests/unit/browser/test_history.py b/tests/unit/browser/test_history.py index 6fa160d31..b49a52a2a 100644 --- a/tests/unit/browser/test_history.py +++ b/tests/unit/browser/test_history.py @@ -377,3 +377,20 @@ def test_no_rebuild_completion(hist): hist2 = history.WebHistory() assert list(hist2.completion) == [('example.com/1', '', 1)] + + +def test_user_version(hist, monkeypatch): + """Ensure that completion is regenerated if user_version is incremented.""" + hist.add_url(QUrl('example.com/1'), redirect=False, atime=1) + hist.add_url(QUrl('example.com/2'), redirect=False, atime=2) + hist.completion.delete('url', 'example.com/2') + + hist2 = history.WebHistory() + assert list(hist2.completion) == [('example.com/1', '', 1)] + + monkeypatch.setattr(history, '_USER_VERSION', history._USER_VERSION + 1) + hist3 = history.WebHistory() + assert list(hist3.completion) == [ + ('example.com/1', '', 1), + ('example.com/2', '', 2), + ] From 0313982ac8b8a019c7582af02c763884389781d2 Mon Sep 17 00:00:00 2001 From: pyup-bot Date: Mon, 21 Aug 2017 16:24:23 +0200 Subject: [PATCH 07/25] Update requests from 2.18.3 to 2.18.4 --- misc/requirements/requirements-codecov.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/misc/requirements/requirements-codecov.txt b/misc/requirements/requirements-codecov.txt index 98979c4d8..c971e2306 100644 --- a/misc/requirements/requirements-codecov.txt +++ b/misc/requirements/requirements-codecov.txt @@ -5,5 +5,5 @@ chardet==3.0.4 codecov==2.0.9 coverage==4.4.1 idna==2.6 -requests==2.18.3 +requests==2.18.4 urllib3==1.22 From 8151a73d6436a399793c3b66a6b38fc4a0c90bab Mon Sep 17 00:00:00 2001 From: pyup-bot Date: Mon, 21 Aug 2017 16:24:25 +0200 Subject: [PATCH 08/25] Update requests from 2.18.3 to 2.18.4 --- misc/requirements/requirements-pylint-master.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/misc/requirements/requirements-pylint-master.txt b/misc/requirements/requirements-pylint-master.txt index ec4693abf..cf2c98f5a 100644 --- a/misc/requirements/requirements-pylint-master.txt +++ b/misc/requirements/requirements-pylint-master.txt @@ -10,7 +10,7 @@ lazy-object-proxy==1.3.1 mccabe==0.6.1 -e git+https://github.com/PyCQA/pylint.git#egg=pylint ./scripts/dev/pylint_checkers -requests==2.18.3 +requests==2.18.4 six==1.10.0 uritemplate==3.0.0 uritemplate.py==3.0.2 From dc61e8ecdfa418e1f94ecea2805ab9240c05bd46 Mon Sep 17 00:00:00 2001 From: pyup-bot Date: Mon, 21 Aug 2017 16:24:27 +0200 Subject: [PATCH 09/25] Update requests from 2.18.3 to 2.18.4 --- misc/requirements/requirements-pylint.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/misc/requirements/requirements-pylint.txt b/misc/requirements/requirements-pylint.txt index dde7a5ad1..1146932c3 100644 --- a/misc/requirements/requirements-pylint.txt +++ b/misc/requirements/requirements-pylint.txt @@ -10,7 +10,7 @@ lazy-object-proxy==1.3.1 mccabe==0.6.1 pylint==1.7.2 ./scripts/dev/pylint_checkers -requests==2.18.3 +requests==2.18.4 six==1.10.0 uritemplate==3.0.0 uritemplate.py==3.0.2 From 86a9487fb29e9aa40f58711b6037fa8bfcdb7120 Mon Sep 17 00:00:00 2001 From: pyup-bot Date: Mon, 21 Aug 2017 16:24:29 +0200 Subject: [PATCH 10/25] Update glob2 from 0.5 to 0.6 --- misc/requirements/requirements-tests.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/misc/requirements/requirements-tests.txt b/misc/requirements/requirements-tests.txt index 12a291c42..58e56705a 100644 --- a/misc/requirements/requirements-tests.txt +++ b/misc/requirements/requirements-tests.txt @@ -9,7 +9,7 @@ decorator==4.1.2 EasyProcess==0.2.3 fields==5.0.0 Flask==0.12.2 -glob2==0.5 +glob2==0.6 httpbin==0.5.0 hunter==1.4.1 hypothesis==3.18.0 From 67e3de06c7d7e5ede215fd1c8415093f837a54b6 Mon Sep 17 00:00:00 2001 From: pyup-bot Date: Mon, 21 Aug 2017 16:24:32 +0200 Subject: [PATCH 11/25] Update hypothesis from 3.18.0 to 3.19.1 --- misc/requirements/requirements-tests.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/misc/requirements/requirements-tests.txt b/misc/requirements/requirements-tests.txt index 58e56705a..986a5c287 100644 --- a/misc/requirements/requirements-tests.txt +++ b/misc/requirements/requirements-tests.txt @@ -12,7 +12,7 @@ Flask==0.12.2 glob2==0.6 httpbin==0.5.0 hunter==1.4.1 -hypothesis==3.18.0 +hypothesis==3.19.1 itsdangerous==0.24 # Jinja2==2.9.6 Mako==1.0.7 From 6c8301665728e6d18968f24602021fab67fddfb4 Mon Sep 17 00:00:00 2001 From: pyup-bot Date: Mon, 21 Aug 2017 16:24:34 +0200 Subject: [PATCH 12/25] Update pytest-rerunfailures from 2.2 to 3.0 --- misc/requirements/requirements-tests.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/misc/requirements/requirements-tests.txt b/misc/requirements/requirements-tests.txt index 986a5c287..8825d25ad 100644 --- a/misc/requirements/requirements-tests.txt +++ b/misc/requirements/requirements-tests.txt @@ -30,7 +30,7 @@ pytest-instafail==0.3.0 pytest-mock==1.6.2 pytest-qt==2.1.2 pytest-repeat==0.4.1 -pytest-rerunfailures==2.2 +pytest-rerunfailures==3.0 pytest-travis-fold==1.2.0 pytest-xvfb==1.0.0 PyVirtualDisplay==0.2.1 From 7f2e8d8147738a4f865334d0988600742564c092 Mon Sep 17 00:00:00 2001 From: pyup-bot Date: Mon, 21 Aug 2017 16:24:36 +0200 Subject: [PATCH 13/25] Update vulture from 0.24 to 0.25 --- misc/requirements/requirements-tests.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/misc/requirements/requirements-tests.txt b/misc/requirements/requirements-tests.txt index 8825d25ad..e59a553b9 100644 --- a/misc/requirements/requirements-tests.txt +++ b/misc/requirements/requirements-tests.txt @@ -35,5 +35,5 @@ pytest-travis-fold==1.2.0 pytest-xvfb==1.0.0 PyVirtualDisplay==0.2.1 six==1.10.0 -vulture==0.24 +vulture==0.25 Werkzeug==0.12.2 From 8a0b7b94414b297fef1366c3e2b816e69f660e8f Mon Sep 17 00:00:00 2001 From: pyup-bot Date: Mon, 21 Aug 2017 16:24:38 +0200 Subject: [PATCH 14/25] Update vulture from 0.24 to 0.25 --- misc/requirements/requirements-vulture.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/misc/requirements/requirements-vulture.txt b/misc/requirements/requirements-vulture.txt index 5c26fc57c..fe2228c5f 100644 --- a/misc/requirements/requirements-vulture.txt +++ b/misc/requirements/requirements-vulture.txt @@ -1,3 +1,3 @@ # This file is automatically generated by scripts/dev/recompile_requirements.py -vulture==0.24 +vulture==0.25 From f1fc078dc1a9c69d891c4cc7fab091a5e801536d Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Tue, 22 Aug 2017 08:08:28 +0200 Subject: [PATCH 15/25] Remove vulture exclude Looks like it was removed in https://github.com/jendrikseipp/vulture/commit/d35e73dedaf26c4f4b693760e168a87ef7b72579, and passing [] seems to be equal to the default nowadays anyways. --- scripts/dev/run_vulture.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/dev/run_vulture.py b/scripts/dev/run_vulture.py index 2a0ecec44..ae5ca76fa 100755 --- a/scripts/dev/run_vulture.py +++ b/scripts/dev/run_vulture.py @@ -143,7 +143,7 @@ def run(files): whitelist_file.close() - vult = vulture.Vulture(exclude=[], verbose=False) + vult = vulture.Vulture(verbose=False) vult.scavenge(files + [whitelist_file.name]) os.remove(whitelist_file.name) From df909ca75b3bdebef530f1e211f4e3624029345c Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Wed, 23 Aug 2017 08:33:50 +0200 Subject: [PATCH 16/25] Fix sorting for vulture --- scripts/dev/run_vulture.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/dev/run_vulture.py b/scripts/dev/run_vulture.py index ae5ca76fa..41925be25 100755 --- a/scripts/dev/run_vulture.py +++ b/scripts/dev/run_vulture.py @@ -127,7 +127,8 @@ def report(items): properties which get used for the items. """ output = [] - for item in sorted(items, key=lambda e: (e.filename.lower(), e.lineno)): + for item in sorted(items, + key=lambda e: (e.filename.lower(), e.first_lineno)): relpath = os.path.relpath(item.filename) path = relpath if not relpath.startswith('..') else item.filename output.append("{}:{}: Unused {} '{}'".format(path, item.lineno, From 074cc1b723d8b6bc6bed422815296c34d5172f61 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Wed, 23 Aug 2017 09:37:51 +0200 Subject: [PATCH 17/25] Another one --- scripts/dev/run_vulture.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/dev/run_vulture.py b/scripts/dev/run_vulture.py index 41925be25..35cdadbb0 100755 --- a/scripts/dev/run_vulture.py +++ b/scripts/dev/run_vulture.py @@ -131,7 +131,7 @@ def report(items): key=lambda e: (e.filename.lower(), e.first_lineno)): relpath = os.path.relpath(item.filename) path = relpath if not relpath.startswith('..') else item.filename - output.append("{}:{}: Unused {} '{}'".format(path, item.lineno, + output.append("{}:{}: Unused {} '{}'".format(path, item.first_lineno, item.typ, item.name)) return output From b89caf04580ffccefcc1f1482f3f9c7f8e7d86f2 Mon Sep 17 00:00:00 2001 From: Ryan Roden-Corrent Date: Tue, 22 Aug 2017 07:19:04 -0400 Subject: [PATCH 18/25] Use REPLACE when rebuilding completion table. When upgrading from an old table that used different url formatting, two entries might map to the same key, so we'll need to replace the previous entry to avoid a primary key conflict. --- qutebrowser/browser/history.py | 4 ++-- tests/unit/browser/test_history.py | 18 ++++++++++++------ 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/qutebrowser/browser/history.py b/qutebrowser/browser/history.py index 9948992ea..2d5c263bc 100644 --- a/qutebrowser/browser/history.py +++ b/qutebrowser/browser/history.py @@ -84,12 +84,12 @@ class WebHistory(sql.SqlTable): data = {'url': [], 'title': [], 'last_atime': []} # select the latest entry for each url q = sql.Query('SELECT url, title, max(atime) AS atime FROM History ' - 'WHERE NOT redirect GROUP BY url') + 'WHERE NOT redirect GROUP BY url ORDER BY atime asc') for entry in q.run(): data['url'].append(self._format_completion_url(QUrl(entry.url))) data['title'].append(entry.title) data['last_atime'].append(entry.atime) - self.completion.insert_batch(data) + self.completion.insert_batch(data, replace=True) sql.Query('pragma user_version = {}'.format(_USER_VERSION)).run() def get_recent(self): diff --git a/tests/unit/browser/test_history.py b/tests/unit/browser/test_history.py index b49a52a2a..2462a1141 100644 --- a/tests/unit/browser/test_history.py +++ b/tests/unit/browser/test_history.py @@ -356,16 +356,22 @@ def test_debug_dump_history_nonexistent(hist, tmpdir): def test_rebuild_completion(hist): - hist.add_url(QUrl('example.com/1'), redirect=False, atime=1) - hist.add_url(QUrl('example.com/1'), redirect=False, atime=2) - hist.add_url(QUrl('example.com/2%203'), redirect=False, atime=3) - hist.add_url(QUrl('example.com/3'), redirect=True, atime=4) + hist.insert({'url': 'example.com/1', 'title': 'example1', + 'redirect': False, 'atime': 1}) + hist.insert({'url': 'example.com/1', 'title': 'example1', + 'redirect': False, 'atime': 2}) + hist.insert({'url': 'example.com/2%203', 'title': 'example2', + 'redirect': False, 'atime': 3}) + hist.insert({'url': 'example.com/3', 'title': 'example3', + 'redirect': True, 'atime': 4}) + hist.insert({'url': 'example.com/2 3', 'title': 'example2', + 'redirect': False, 'atime': 5}) hist.completion.delete_all() hist2 = history.WebHistory() assert list(hist2.completion) == [ - ('example.com/1', '', 2), - ('example.com/2 3', '', 3), + ('example.com/1', 'example1', 2), + ('example.com/2 3', 'example2', 5), ] From 8e9284835656cdfb6de58564bc58f1f8e692c752 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Wed, 23 Aug 2017 08:20:24 +0200 Subject: [PATCH 19/25] Switch pyup to Mondays --- .pyup.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pyup.yml b/.pyup.yml index 18ec25a64..3fbe456dc 100644 --- a/.pyup.yml +++ b/.pyup.yml @@ -1 +1 @@ -schedule: "every week" +schedule: "every week on monday" From 536c28a952eb7e210c98e66041420a473354c4e9 Mon Sep 17 00:00:00 2001 From: Bryan Gilbert Date: Thu, 24 Aug 2017 15:57:19 -0400 Subject: [PATCH 20/25] implemented format_json userscript --- misc/userscripts/format_json | 47 ++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100755 misc/userscripts/format_json diff --git a/misc/userscripts/format_json b/misc/userscripts/format_json new file mode 100755 index 000000000..f756850f1 --- /dev/null +++ b/misc/userscripts/format_json @@ -0,0 +1,47 @@ +#!/bin/sh +# +# Behavior: +# Userscript for qutebrowser which will take the raw JSON text of the current +# page, format it using `jq`, will add syntax highlighting using `pygments`, +# and open the syntax highlighted pretty printed html in a new tab. If the file +# is larger than 10MB then this script will only indent the json and will forego +# syntax highlighting using pygments. +# +# In order to use this script, just start it using `spawn --userscript` from +# qutebrowser. I recommend using an alias, e.g. put this in the +# [alias]-section of qutebrowser.conf: +# +# json = spawn --userscript /path/to/json_format +# +# Note that the color style defaults to monokai, but a different pygments style +# can be passed as the first parameter to the script. A full list of the pygments +# styles can be found at: https://help.farbox.com/pygments.html +# +# Bryan Gilbert, 2017 + +# default style to monokai if none is provided +STYLE=${1:-monokai} +# format json using jq +FORMATTED_JSON="$(cat "$QUTE_TEXT" | jq '.')" + +# if jq command failed or formatted json is empty, assume failure and terminate +if [ $? -ne 0 ] || [ -z "$FORMATTED_JSON" ]; then + echo "Invalid json, aborting..." + exit 1 +fi + +# calculate the filesize of the json document +FILE_SIZE=$(ls -s --block-size=1048576 "$QUTE_TEXT" | cut -d' ' -f1) + +# use pygments to pretty-up the json (syntax highlight) if file is less than 10MB +if [ "$FILE_SIZE" -lt "10" ]; then + FORMATTED_JSON="$(echo "$FORMATTED_JSON" | pygmentize -l json -f html -O full,style=$STYLE)" +fi + +# create a temp file and write the formatted json to that file +TEMP_FILE="$(mktemp --suffix '.html')" +echo "$FORMATTED_JSON" > $TEMP_FILE + + +# send the command to qutebrowser to open the new file containing the formatted json +echo "open -t file://$TEMP_FILE" >> "$QUTE_FIFO" From 69ea2cf327f82365b382d41a682b55f95b97568b Mon Sep 17 00:00:00 2001 From: Kepi Date: Fri, 1 Sep 2017 01:30:50 +0200 Subject: [PATCH 21/25] password_fill: Stop filling username to invisible input fields There is no reason to fill usernames into invisible input fields. We are probably not leaking anything but it can break some apps (like TTRSS). --- misc/userscripts/password_fill | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/misc/userscripts/password_fill b/misc/userscripts/password_fill index 327a55690..00dd55e63 100755 --- a/misc/userscripts/password_fill +++ b/misc/userscripts/password_fill @@ -327,6 +327,17 @@ open_entry "$file" js() { cat < 0 && elem.offsetHeight > 0; + }; function hasPasswordField(form) { var inputs = form.getElementsByTagName("input"); for (var j = 0; j < inputs.length; j++) { @@ -341,7 +352,7 @@ cat < Date: Mon, 4 Sep 2017 15:03:04 +0200 Subject: [PATCH 22/25] Add a note about Gentoo and bindist to INSTALL Closes #2944 --- INSTALL.asciidoc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/INSTALL.asciidoc b/INSTALL.asciidoc index d53c33fa3..6977717c8 100644 --- a/INSTALL.asciidoc +++ b/INSTALL.asciidoc @@ -175,6 +175,12 @@ If video or sound don't seem to work, try installing the gstreamer plugins: # emerge -av gst-plugins-{base,good,bad,ugly,libav} ---- +To be able to play videos with proprietary codecs with QtWebEngine, you will +need to turn off the `bindist` flag for `dev-qt/qtwebengine`. + +See the https://wiki.gentoo.org/wiki/Qutebrowser#USE_flags[Gentoo Wiki] for +more information. + On Void Linux ------------- From 19385208788d938630938bbdcbb780becbeed4b9 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Mon, 4 Sep 2017 15:48:20 +0200 Subject: [PATCH 23/25] eslint: Turn off function-paren-newline --- qutebrowser/javascript/.eslintrc.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/qutebrowser/javascript/.eslintrc.yaml b/qutebrowser/javascript/.eslintrc.yaml index 7e787bae8..fc56f9dd8 100644 --- a/qutebrowser/javascript/.eslintrc.yaml +++ b/qutebrowser/javascript/.eslintrc.yaml @@ -43,3 +43,4 @@ rules: array-bracket-newline: "off" array-element-newline: "off" no-multi-spaces: ["error", {"ignoreEOLComments": true}] + function-paren-newline: "off" From 7f30fe377c7345b367a578270dcb51ba87a7ad43 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Thu, 7 Sep 2017 13:01:21 +0200 Subject: [PATCH 24/25] Update CONTRIBUTING for new completion --- CONTRIBUTING.asciidoc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTING.asciidoc b/CONTRIBUTING.asciidoc index 7d42cad28..9567b26a3 100644 --- a/CONTRIBUTING.asciidoc +++ b/CONTRIBUTING.asciidoc @@ -479,7 +479,8 @@ The following arguments are supported for `@cmdutils.argument`: - `win_id=True`: Mark the argument as special window ID argument - `count=True`: Mark the argument as special count argument - `hide=True`: Hide the argument from the documentation -- `completion`: A `usertypes.Completion` member to use as completion. +- `completion`: A completion function (see `qutebrowser.completions.models.*`) + to use when completing arguments for the given command. - `choices`: The allowed string choices for the argument. The name of an argument will always be the parameter name, with any trailing From adb552ee6ef99056fd8efa4375f21f1d7a2370f0 Mon Sep 17 00:00:00 2001 From: instinctive Date: Thu, 7 Sep 2017 14:29:45 -0700 Subject: [PATCH 25/25] Use python3-qt5-webengine for Fedora This was the incantation that worked for me on Fedora 26. --- INSTALL.asciidoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/INSTALL.asciidoc b/INSTALL.asciidoc index 6977717c8..e8ce36c48 100644 --- a/INSTALL.asciidoc +++ b/INSTALL.asciidoc @@ -85,7 +85,7 @@ qutebrowser is available in the official repositories for Fedora 22 and newer. # dnf install qutebrowser ---- -It's also recommended to install `qt5-qtwebengine` and start with `--backend +It's also recommended to install `python3-qt5-webengine` and start with `--backend webengine` to use the new backend. On Archlinux