diff options
author | Jay Kamat <jaygkamat@gmail.com> | 2019-03-17 23:36:46 -0700 |
---|---|---|
committer | Jay Kamat <jaygkamat@gmail.com> | 2019-03-17 23:36:46 -0700 |
commit | 4829a83fdec30f4cc9997023d420f3725c064f63 (patch) | |
tree | 49cbac26adb30b4a0d742fdead01cf1cfd83513c /qutebrowser | |
parent | c4d254b59f223186c619a9d4c2e47b42d9fa54e2 (diff) | |
parent | 158b3be6ce48532b65457b17b7066850d16f6612 (diff) | |
download | qutebrowser-4829a83fdec30f4cc9997023d420f3725c064f63.tar.gz qutebrowser-4829a83fdec30f4cc9997023d420f3725c064f63.zip |
Merge branch 'master' of https://github.com/qutebrowser/qutebrowser into jay/keys-unneeeded-code
Diffstat (limited to 'qutebrowser')
176 files changed, 608 insertions, 372 deletions
diff --git a/qutebrowser/__init__.py b/qutebrowser/__init__.py index 8be3df172..713575646 100644 --- a/qutebrowser/__init__.py +++ b/qutebrowser/__init__.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2014-2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2014-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # @@ -22,11 +22,11 @@ import os.path __author__ = "Florian Bruhin" -__copyright__ = "Copyright 2014-2018 Florian Bruhin (The Compiler)" +__copyright__ = "Copyright 2014-2019 Florian Bruhin (The Compiler)" __license__ = "GPL" __maintainer__ = __author__ __email__ = "mail@qutebrowser.org" -__version_info__ = (1, 5, 2) +__version_info__ = (1, 6, 0) __version__ = '.'.join(str(e) for e in __version_info__) __description__ = "A keyboard-driven, vim-like browser based on PyQt5." diff --git a/qutebrowser/__main__.py b/qutebrowser/__main__.py index 533cf6e67..9bbe390e5 100644 --- a/qutebrowser/__main__.py +++ b/qutebrowser/__main__.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2014-2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2014-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # diff --git a/qutebrowser/api/__init__.py b/qutebrowser/api/__init__.py index 648887005..c579e52bc 100644 --- a/qutebrowser/api/__init__.py +++ b/qutebrowser/api/__init__.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2018-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # diff --git a/qutebrowser/api/apitypes.py b/qutebrowser/api/apitypes.py index 8fbc1a9a7..dc0e8fa11 100644 --- a/qutebrowser/api/apitypes.py +++ b/qutebrowser/api/apitypes.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2018-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # diff --git a/qutebrowser/api/cmdutils.py b/qutebrowser/api/cmdutils.py index cd43079ad..0efc187a5 100644 --- a/qutebrowser/api/cmdutils.py +++ b/qutebrowser/api/cmdutils.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2014-2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2014-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # diff --git a/qutebrowser/api/config.py b/qutebrowser/api/config.py index 0c633e54d..da6c40179 100644 --- a/qutebrowser/api/config.py +++ b/qutebrowser/api/config.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2018-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # diff --git a/qutebrowser/api/downloads.py b/qutebrowser/api/downloads.py index a2a37d931..70389bc51 100644 --- a/qutebrowser/api/downloads.py +++ b/qutebrowser/api/downloads.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2018-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # diff --git a/qutebrowser/api/hook.py b/qutebrowser/api/hook.py index 84e103cbd..0a9be4595 100644 --- a/qutebrowser/api/hook.py +++ b/qutebrowser/api/hook.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2018-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # diff --git a/qutebrowser/api/interceptor.py b/qutebrowser/api/interceptor.py index 78819dc46..f19d30897 100644 --- a/qutebrowser/api/interceptor.py +++ b/qutebrowser/api/interceptor.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2018-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # @@ -27,6 +27,9 @@ from qutebrowser.extensions.interceptors import Request #: Type annotation for an interceptor function. InterceptorType = interceptors.InterceptorType +#: Possible resource types for requests sent to interceptor. +ResourceType = interceptors.ResourceType + def register(interceptor: InterceptorType) -> None: """Register a request interceptor. diff --git a/qutebrowser/api/message.py b/qutebrowser/api/message.py index fdb06354f..a225e12c0 100644 --- a/qutebrowser/api/message.py +++ b/qutebrowser/api/message.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2018-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # diff --git a/qutebrowser/app.py b/qutebrowser/app.py index 2b6896b76..5c347fa86 100644 --- a/qutebrowser/app.py +++ b/qutebrowser/app.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2014-2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2014-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # @@ -83,7 +83,7 @@ from qutebrowser.misc import utilcmds # pylint: enable=unused-import -qApp = None +q_app = None def run(args): @@ -101,25 +101,25 @@ def run(args): log.init.debug("Initializing config...") configinit.early_init(args) - global qApp - qApp = Application(args) - qApp.setOrganizationName("qutebrowser") - qApp.setApplicationName("qutebrowser") - qApp.setDesktopFileName("qutebrowser") - qApp.setApplicationVersion(qutebrowser.__version__) - qApp.lastWindowClosed.connect(quitter.on_last_window_closed) + global q_app + q_app = Application(args) + q_app.setOrganizationName("qutebrowser") + q_app.setApplicationName("qutebrowser") + q_app.setDesktopFileName("qutebrowser") + q_app.setApplicationVersion(qutebrowser.__version__) + q_app.lastWindowClosed.connect(quitter.on_last_window_closed) if args.version: print(version.version()) sys.exit(usertypes.Exit.ok) crash_handler = crashsignal.CrashHandler( - app=qApp, quitter=quitter, args=args, parent=qApp) + app=q_app, quitter=quitter, args=args, parent=q_app) crash_handler.activate() objreg.register('crash-handler', crash_handler) - signal_handler = crashsignal.SignalHandler(app=qApp, quitter=quitter, - parent=qApp) + signal_handler = crashsignal.SignalHandler(app=q_app, quitter=quitter, + parent=q_app) signal_handler.activate() objreg.register('signal-handler', signal_handler) @@ -151,7 +151,7 @@ def qt_mainloop(): WARNING: misc/crashdialog.py checks the stacktrace for this function name, so if this is changed, it should be changed there as well! """ - return qApp.exec_() + return q_app.exec_() def init(args, crash_handler): @@ -162,7 +162,7 @@ def init(args, crash_handler): crash_handler: The CrashHandler instance. """ log.init.debug("Starting init...") - qApp.setQuitOnLastWindowClosed(False) + q_app.setQuitOnLastWindowClosed(False) _init_icon() loader.init() @@ -175,12 +175,12 @@ def init(args, crash_handler): sys.exit(usertypes.Exit.err_init) log.init.debug("Initializing eventfilter...") - event_filter = EventFilter(qApp) - qApp.installEventFilter(event_filter) + event_filter = EventFilter(q_app) + q_app.installEventFilter(event_filter) objreg.register('event-filter', event_filter) log.init.debug("Connecting signals...") - qApp.focusChanged.connect(on_focus_changed) + q_app.focusChanged.connect(on_focus_changed) _process_args(args) @@ -207,7 +207,7 @@ def _init_icon(): if icon.isNull(): log.init.warning("Failed to load icon") else: - qApp.setWindowIcon(icon) + q_app.setWindowIcon(icon) def _process_args(args): @@ -220,7 +220,7 @@ def _process_args(args): window = mainwindow.MainWindow(private=None) if not args.nowindow: window.show() - qApp.setActiveWindow(window) + q_app.setActiveWindow(window) process_pos_args(args.command) _open_startpage() @@ -425,7 +425,7 @@ def _init_modules(args, crash_handler): crash_handler: The CrashHandler instance. """ log.init.debug("Initializing save manager...") - save_manager = savemanager.SaveManager(qApp) + save_manager = savemanager.SaveManager(q_app) objreg.register('save-manager', save_manager) configinit.late_init(save_manager) @@ -450,7 +450,7 @@ def _init_modules(args, crash_handler): sql.init(os.path.join(standarddir.data(), 'history.sqlite')) log.init.debug("Initializing web history...") - history.init(qApp) + history.init(q_app) except sql.SqlEnvironmentError as e: error.handle_fatal_exc(e, args, 'Error initializing SQL', pre_text='Error initializing SQL') @@ -464,31 +464,31 @@ def _init_modules(args, crash_handler): crash_handler.handle_segfault() log.init.debug("Initializing sessions...") - sessions.init(qApp) + sessions.init(q_app) log.init.debug("Initializing websettings...") websettings.init(args) log.init.debug("Initializing quickmarks...") - quickmark_manager = urlmarks.QuickmarkManager(qApp) + quickmark_manager = urlmarks.QuickmarkManager(q_app) objreg.register('quickmark-manager', quickmark_manager) log.init.debug("Initializing bookmarks...") - bookmark_manager = urlmarks.BookmarkManager(qApp) + bookmark_manager = urlmarks.BookmarkManager(q_app) objreg.register('bookmark-manager', bookmark_manager) log.init.debug("Initializing cookies...") - cookie_jar = cookies.CookieJar(qApp) - ram_cookie_jar = cookies.RAMCookieJar(qApp) + cookie_jar = cookies.CookieJar(q_app) + ram_cookie_jar = cookies.RAMCookieJar(q_app) objreg.register('cookie-jar', cookie_jar) objreg.register('ram-cookie-jar', ram_cookie_jar) log.init.debug("Initializing cache...") - diskcache = cache.DiskCache(standarddir.cache(), parent=qApp) + diskcache = cache.DiskCache(standarddir.cache(), parent=q_app) objreg.register('cache', diskcache) log.init.debug("Initializing downloads...") - download_manager = qtnetworkdownloads.DownloadManager(parent=qApp) + download_manager = qtnetworkdownloads.DownloadManager(parent=q_app) objreg.register('qtnetwork-download-manager', download_manager) log.init.debug("Initializing Greasemonkey...") @@ -735,7 +735,7 @@ class Quitter: def _shutdown(self, status, restart): # noqa """Second stage of shutdown.""" log.destroy.debug("Stage 2 of shutting down...") - if qApp is None: + if q_app is None: # No QApplication exists yet, so quit hard. sys.exit(status) # Remove eventfilter @@ -743,7 +743,7 @@ class Quitter: log.destroy.debug("Removing eventfilter...") event_filter = objreg.get('event-filter', None) if event_filter is not None: - qApp.removeEventFilter(event_filter) + q_app.removeEventFilter(event_filter) except AttributeError: pass # Close all windows @@ -792,7 +792,7 @@ class Quitter: session_manager.delete_autosave() # We use a singleshot timer to exit here to minimize the likelihood of # segfaults. - QTimer.singleShot(0, functools.partial(qApp.exit, status)) + QTimer.singleShot(0, functools.partial(q_app.exit, status)) class Application(QApplication): @@ -893,7 +893,7 @@ class EventFilter(QObject): Return: True if the event should be filtered, False if it's passed through. """ - if qApp.activeWindow() not in objreg.window_registry.values(): + if q_app.activeWindow() not in objreg.window_registry.values(): # Some other window (print dialog, etc.) is focused so we pass the # event through. return False diff --git a/qutebrowser/browser/__init__.py b/qutebrowser/browser/__init__.py index b565801d3..9b8251a75 100644 --- a/qutebrowser/browser/__init__.py +++ b/qutebrowser/browser/__init__.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2016-2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2016-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # diff --git a/qutebrowser/browser/browsertab.py b/qutebrowser/browser/browsertab.py index 55ab89a20..c9770af5f 100644 --- a/qutebrowser/browser/browsertab.py +++ b/qutebrowser/browser/browsertab.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2016-2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2016-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # diff --git a/qutebrowser/browser/commands.py b/qutebrowser/browser/commands.py index 6ae47f9d9..d04c9ec91 100644 --- a/qutebrowser/browser/commands.py +++ b/qutebrowser/browser/commands.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2014-2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2014-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # @@ -479,7 +479,7 @@ class CommandDispatcher: # Catch common cases before e.g. cloning tab if not forward and not history.can_go_back(): raise cmdutils.CommandError("At beginning of history.") - elif forward and not history.can_go_forward(): + if forward and not history.can_go_forward(): raise cmdutils.CommandError("At end of history.") if tab or bg or window: diff --git a/qutebrowser/browser/downloads.py b/qutebrowser/browser/downloads.py index b18e426d7..671730b1f 100644 --- a/qutebrowser/browser/downloads.py +++ b/qutebrowser/browser/downloads.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2014-2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2014-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # @@ -1105,8 +1105,7 @@ class DownloadModel(QAbstractListModel): to_retry = [d for d in self if d.done and not d.successful] if not to_retry: raise cmdutils.CommandError("No failed downloads!") - else: - download = to_retry[0] + download = to_retry[0] download.try_retry() def can_clear(self): diff --git a/qutebrowser/browser/downloadview.py b/qutebrowser/browser/downloadview.py index 1ea2b6744..fc45fe26c 100644 --- a/qutebrowser/browser/downloadview.py +++ b/qutebrowser/browser/downloadview.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2014-2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2014-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # diff --git a/qutebrowser/browser/greasemonkey.py b/qutebrowser/browser/greasemonkey.py index 9314f81c6..3a5b60544 100644 --- a/qutebrowser/browser/greasemonkey.py +++ b/qutebrowser/browser/greasemonkey.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2017-2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2017-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # @@ -31,7 +31,8 @@ import attr from PyQt5.QtCore import pyqtSignal, QObject, QUrl from qutebrowser.utils import (log, standarddir, jinja, objreg, utils, - javascript, urlmatch, version, usertypes) + javascript, urlmatch, version, usertypes, + qtutils) from qutebrowser.api import cmdutils from qutebrowser.browser import downloads from qutebrowser.misc import objects @@ -116,6 +117,40 @@ class GreasemonkeyScript: script.includes = ['*'] return script + def needs_document_end_workaround(self): + """Check whether to force @run-at document-end. + + This needs to be done on QtWebEngine with Qt 5.12 for known-broken + scripts. + + On Qt 5.12, accessing the DOM isn't possible with "@run-at + document-start". It was documented to be impossible before, but seems + to work fine. + + However, some scripts do DOM access with "@run-at document-start". Fix + those by forcing them to use document-end instead. + """ + if objects.backend != usertypes.Backend.QtWebEngine: + return False + elif not qtutils.version_check('5.12', compiled=False): + return False + + broken_scripts = [ + ('http://userstyles.org', None), + ('https://github.com/ParticleCore', 'Iridium'), + ] + return any(self._matches_id(namespace=namespace, name=name) + for namespace, name in broken_scripts) + + def _matches_id(self, *, namespace, name): + """Check if this script matches the given namespace/name. + + Both namespace and name can be None in order to match any script. + """ + matches_namespace = namespace is None or self.namespace == namespace + matches_name = name is None or self.name == name + return matches_namespace and matches_name + def code(self): """Return the processed JavaScript code of this script. diff --git a/qutebrowser/browser/hints.py b/qutebrowser/browser/hints.py index 43257d0a8..14f61de35 100644 --- a/qutebrowser/browser/hints.py +++ b/qutebrowser/browser/hints.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2014-2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2014-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # @@ -956,10 +956,9 @@ class HintManager(QObject): if keystring is None: if self._context.to_follow is None: raise cmdutils.CommandError("No hint to follow") - elif select: + if select: raise cmdutils.CommandError("Can't use --select without hint.") - else: - keystring = self._context.to_follow + keystring = self._context.to_follow elif keystring not in self._context.labels: raise cmdutils.CommandError("No hint {}!".format(keystring)) diff --git a/qutebrowser/browser/history.py b/qutebrowser/browser/history.py index 757a72e41..2480f7a7a 100644 --- a/qutebrowser/browser/history.py +++ b/qutebrowser/browser/history.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2015-2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2015-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # diff --git a/qutebrowser/browser/inspector.py b/qutebrowser/browser/inspector.py index 3334cea4e..9b9e37504 100644 --- a/qutebrowser/browser/inspector.py +++ b/qutebrowser/browser/inspector.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2015-2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2015-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # diff --git a/qutebrowser/browser/mouse.py b/qutebrowser/browser/mouse.py index a73f28203..c2e39663b 100644 --- a/qutebrowser/browser/mouse.py +++ b/qutebrowser/browser/mouse.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2016-2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2016-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # diff --git a/qutebrowser/browser/navigate.py b/qutebrowser/browser/navigate.py index 240878ed6..a7bf50bb6 100644 --- a/qutebrowser/browser/navigate.py +++ b/qutebrowser/browser/navigate.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2016-2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2016-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # diff --git a/qutebrowser/browser/network/pac.py b/qutebrowser/browser/network/pac.py index bd060820b..cb3819bce 100644 --- a/qutebrowser/browser/network/pac.py +++ b/qutebrowser/browser/network/pac.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2016-2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2016-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # @@ -142,7 +142,8 @@ class PACResolver: config = [c.strip() for c in proxy_str.split(' ') if c] if not config: raise ParseProxyError("Empty proxy entry") - elif config[0] == "DIRECT": + + if config[0] == "DIRECT": if len(config) != 1: raise ParseProxyError("Invalid number of parameters for " + "DIRECT") @@ -208,6 +209,8 @@ class PACResolver: Return: A list of QNetworkProxy objects in order of preference. """ + qtutils.ensure_valid(query.url()) + if from_file: string_flags = QUrl.PrettyDecoded else: diff --git a/qutebrowser/browser/network/proxy.py b/qutebrowser/browser/network/proxy.py index d3e25c23c..a14448512 100644 --- a/qutebrowser/browser/network/proxy.py +++ b/qutebrowser/browser/network/proxy.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2014-2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2014-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # @@ -20,10 +20,12 @@ """Handling of proxies.""" +from PyQt5.QtCore import QUrl from PyQt5.QtNetwork import QNetworkProxy, QNetworkProxyFactory from qutebrowser.config import config, configtypes -from qutebrowser.utils import objreg +from qutebrowser.utils import objreg, message, usertypes, urlutils +from qutebrowser.misc import objects from qutebrowser.browser.network import pac @@ -33,6 +35,18 @@ def init(): objreg.register('proxy-factory', proxy_factory) QNetworkProxyFactory.setApplicationProxyFactory(proxy_factory) + config.instance.changed.connect(_warn_for_pac) + _warn_for_pac() + + +@config.change_filter('content.proxy', function=True) +def _warn_for_pac(): + """Show a warning if PAC is used with QtWebEngine.""" + proxy = config.val.content.proxy + if (isinstance(proxy, pac.PACFetcher) and + objects.backend == usertypes.Backend.QtWebEngine): + message.error("PAC support isn't implemented for QtWebEngine yet!") + def shutdown(): QNetworkProxyFactory.setApplicationProxyFactory(None) @@ -70,7 +84,11 @@ class ProxyFactory(QNetworkProxyFactory): # ref. http://doc.qt.io/qt-5/qnetworkproxyfactory.html#systemProxyForQuery proxies = QNetworkProxyFactory.systemProxyForQuery(query) elif isinstance(proxy, pac.PACFetcher): - proxies = proxy.resolve(query) + if objects.backend == usertypes.Backend.QtWebEngine: + # Looks like query.url() is always invalid on QtWebEngine... + proxies = [urlutils.proxy_from_url(QUrl('direct://'))] + else: + proxies = proxy.resolve(query) else: proxies = [proxy] for p in proxies: diff --git a/qutebrowser/browser/pdfjs.py b/qutebrowser/browser/pdfjs.py index 897f0407e..0fccaf4e2 100644 --- a/qutebrowser/browser/pdfjs.py +++ b/qutebrowser/browser/pdfjs.py @@ -1,7 +1,7 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: +# Copyright 2016-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # Copyright 2015 Daniel Schadt -# Copyright 2016-2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # diff --git a/qutebrowser/browser/qtnetworkdownloads.py b/qutebrowser/browser/qtnetworkdownloads.py index bdd2b280a..5fb9ca95f 100644 --- a/qutebrowser/browser/qtnetworkdownloads.py +++ b/qutebrowser/browser/qtnetworkdownloads.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2014-2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2014-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # diff --git a/qutebrowser/browser/qutescheme.py b/qutebrowser/browser/qutescheme.py index 14c43ad1e..606a05fc1 100644 --- a/qutebrowser/browser/qutescheme.py +++ b/qutebrowser/browser/qutescheme.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2016-2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2016-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # @@ -340,19 +340,11 @@ def qute_gpl(_url): def _asciidoc_fallback_path(html_path): """Fall back to plaintext asciidoc if the HTML is unavailable.""" - asciidoc_path = html_path.replace('.html', '.asciidoc') - asciidoc_paths = [asciidoc_path] - if asciidoc_path.startswith('html/doc/'): - asciidoc_paths += [asciidoc_path.replace('html/doc/', '../doc/help/'), - asciidoc_path.replace('html/doc/', '../doc/')] - - for path in asciidoc_paths: - try: - return utils.read_file(path) - except OSError: - pass - - return None + path = html_path.replace('.html', '.asciidoc') + try: + return utils.read_file(path) + except OSError: + return None @add_handler('help') diff --git a/qutebrowser/browser/shared.py b/qutebrowser/browser/shared.py index 0bf3301f9..194dc5b36 100644 --- a/qutebrowser/browser/shared.py +++ b/qutebrowser/browser/shared.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2016-2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2016-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # @@ -42,7 +42,6 @@ def custom_headers(url): if dnt_config is not None: dnt = b'1' if dnt_config else b'0' headers[b'DNT'] = dnt - headers[b'X-Do-Not-Track'] = dnt conf_headers = config.instance.get('content.headers.custom', url=url) for header, value in conf_headers.items(): diff --git a/qutebrowser/browser/signalfilter.py b/qutebrowser/browser/signalfilter.py index 7cc46abdb..356cd27a6 100644 --- a/qutebrowser/browser/signalfilter.py +++ b/qutebrowser/browser/signalfilter.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2014-2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2014-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # diff --git a/qutebrowser/browser/urlmarks.py b/qutebrowser/browser/urlmarks.py index 4d25dde45..2ff71c2df 100644 --- a/qutebrowser/browser/urlmarks.py +++ b/qutebrowser/browser/urlmarks.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2014-2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2014-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # Copyright 2015-2018 Antoni Boucher <bouanto@zoho.com> # # This file is part of qutebrowser. diff --git a/qutebrowser/browser/webelem.py b/qutebrowser/browser/webelem.py index ac46fdcb9..3629ea0ef 100644 --- a/qutebrowser/browser/webelem.py +++ b/qutebrowser/browser/webelem.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2014-2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2014-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # diff --git a/qutebrowser/browser/webengine/__init__.py b/qutebrowser/browser/webengine/__init__.py index 2649645d3..36a9a8b61 100644 --- a/qutebrowser/browser/webengine/__init__.py +++ b/qutebrowser/browser/webengine/__init__.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2014-2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2014-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # diff --git a/qutebrowser/browser/webengine/certificateerror.py b/qutebrowser/browser/webengine/certificateerror.py index 768f54ec6..c3d6c74ab 100644 --- a/qutebrowser/browser/webengine/certificateerror.py +++ b/qutebrowser/browser/webengine/certificateerror.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2016-2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2016-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # diff --git a/qutebrowser/browser/webengine/cookies.py b/qutebrowser/browser/webengine/cookies.py index e5abc20ea..7e5583152 100644 --- a/qutebrowser/browser/webengine/cookies.py +++ b/qutebrowser/browser/webengine/cookies.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2018-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # diff --git a/qutebrowser/browser/webengine/interceptor.py b/qutebrowser/browser/webengine/interceptor.py index a5b7721b8..8d8fb04dd 100644 --- a/qutebrowser/browser/webengine/interceptor.py +++ b/qutebrowser/browser/webengine/interceptor.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2016-2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2016-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # @@ -33,6 +33,50 @@ class RequestInterceptor(QWebEngineUrlRequestInterceptor): """Handle ad blocking and custom headers.""" + # This dict should be from QWebEngine Resource Types to qutebrowser + # extension ResourceTypes. If a ResourceType is added to Qt, this table + # should be updated too. + RESOURCE_TYPES = { + QWebEngineUrlRequestInfo.ResourceTypeMainFrame: + interceptors.ResourceType.main_frame, + QWebEngineUrlRequestInfo.ResourceTypeSubFrame: + interceptors.ResourceType.sub_frame, + QWebEngineUrlRequestInfo.ResourceTypeStylesheet: + interceptors.ResourceType.stylesheet, + QWebEngineUrlRequestInfo.ResourceTypeScript: + interceptors.ResourceType.script, + QWebEngineUrlRequestInfo.ResourceTypeImage: + interceptors.ResourceType.image, + QWebEngineUrlRequestInfo.ResourceTypeFontResource: + interceptors.ResourceType.font_resource, + QWebEngineUrlRequestInfo.ResourceTypeSubResource: + interceptors.ResourceType.sub_resource, + QWebEngineUrlRequestInfo.ResourceTypeObject: + interceptors.ResourceType.object, + QWebEngineUrlRequestInfo.ResourceTypeMedia: + interceptors.ResourceType.media, + QWebEngineUrlRequestInfo.ResourceTypeWorker: + interceptors.ResourceType.worker, + QWebEngineUrlRequestInfo.ResourceTypeSharedWorker: + interceptors.ResourceType.shared_worker, + QWebEngineUrlRequestInfo.ResourceTypePrefetch: + interceptors.ResourceType.prefetch, + QWebEngineUrlRequestInfo.ResourceTypeFavicon: + interceptors.ResourceType.favicon, + QWebEngineUrlRequestInfo.ResourceTypeXhr: + interceptors.ResourceType.xhr, + QWebEngineUrlRequestInfo.ResourceTypePing: + interceptors.ResourceType.ping, + QWebEngineUrlRequestInfo.ResourceTypeServiceWorker: + interceptors.ResourceType.service_worker, + QWebEngineUrlRequestInfo.ResourceTypeCspReport: + interceptors.ResourceType.csp_report, + QWebEngineUrlRequestInfo.ResourceTypePluginResource: + interceptors.ResourceType.plugin_resource, + QWebEngineUrlRequestInfo.ResourceTypeUnknown: + interceptors.ResourceType.unknown, + } + def __init__(self, args, parent=None): super().__init__(parent) self._args = args @@ -71,6 +115,17 @@ class RequestInterceptor(QWebEngineUrlRequestInterceptor): url = info.requestUrl() first_party = info.firstPartyUrl() + # Per QWebEngineUrlRequestInfo::ResourceType documentation, if we fail + # our lookup, we should fall back to ResourceTypeUnknown + try: + resource_type = RequestInterceptor.RESOURCE_TYPES[ + info.resourceType()] + except KeyError: + log.webview.warning( + "Resource type {} not found in RequestInterceptor dict." + .format(debug.qenum_key(QWebEngineUrlRequestInfo, + info.resourceType()))) + resource_type = interceptors.ResourceType.unknown if ((url.scheme(), url.host(), url.path()) == ('qute', 'settings', '/set')): @@ -85,7 +140,8 @@ class RequestInterceptor(QWebEngineUrlRequestInterceptor): # FIXME:qtwebengine only block ads for NavigationTypeOther? request = interceptors.Request(first_party_url=first_party, - request_url=url) + request_url=url, + resource_type=resource_type) interceptors.run(request) if request.is_blocked: info.block(True) diff --git a/qutebrowser/browser/webengine/spell.py b/qutebrowser/browser/webengine/spell.py index 55d8aea5b..6653acdd6 100644 --- a/qutebrowser/browser/webengine/spell.py +++ b/qutebrowser/browser/webengine/spell.py @@ -1,5 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: +# Copyright 2017-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # Copyright 2017-2018 Michal Siedlaczek <michal.siedlaczek@gmail.com> # This file is part of qutebrowser. diff --git a/qutebrowser/browser/webengine/tabhistory.py b/qutebrowser/browser/webengine/tabhistory.py index 81f0a3afd..592b64b6a 100644 --- a/qutebrowser/browser/webengine/tabhistory.py +++ b/qutebrowser/browser/webengine/tabhistory.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2015-2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2015-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # diff --git a/qutebrowser/browser/webengine/webenginedownloads.py b/qutebrowser/browser/webengine/webenginedownloads.py index 6dde42070..a9e4046a1 100644 --- a/qutebrowser/browser/webengine/webenginedownloads.py +++ b/qutebrowser/browser/webengine/webenginedownloads.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2014-2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2014-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # @@ -180,7 +180,21 @@ def _get_suggested_filename(path): See https://bugreports.qt.io/browse/QTBUG-56978 """ filename = os.path.basename(path) - filename = re.sub(r'\([0-9]+\)(?=\.|$)', '', filename) + + suffix_re = re.compile(r""" + \ ? # Optional space between filename and suffix + ( + # Numerical suffix + \([0-9]+\) + | + # ISO-8601 suffix + # https://cs.chromium.org/chromium/src/base/time/time_to_iso8601.cc + \ -\ \d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d{3}Z + ) + (?=\.|$) # Begin of extension, or filename without extension + """, re.VERBOSE) + + filename = suffix_re.sub('', filename) if not qtutils.version_check('5.9', compiled=False): # https://bugreports.qt.io/browse/QTBUG-58155 filename = urllib.parse.unquote(filename) diff --git a/qutebrowser/browser/webengine/webengineelem.py b/qutebrowser/browser/webengine/webengineelem.py index 13292b45b..12aa28f33 100644 --- a/qutebrowser/browser/webengine/webengineelem.py +++ b/qutebrowser/browser/webengine/webengineelem.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2016-2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2016-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # diff --git a/qutebrowser/browser/webengine/webengineinspector.py b/qutebrowser/browser/webengine/webengineinspector.py index 0b1ace3f3..4bf72502c 100644 --- a/qutebrowser/browser/webengine/webengineinspector.py +++ b/qutebrowser/browser/webengine/webengineinspector.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2015-2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2015-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # diff --git a/qutebrowser/browser/webengine/webenginequtescheme.py b/qutebrowser/browser/webengine/webenginequtescheme.py index 816589514..132005878 100644 --- a/qutebrowser/browser/webengine/webenginequtescheme.py +++ b/qutebrowser/browser/webengine/webenginequtescheme.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2016-2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2016-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # @@ -62,18 +62,33 @@ class QuteSchemeHandler(QWebEngineUrlSchemeHandler): """ try: initiator = job.initiator() + request_url = job.requestUrl() except AttributeError: # Added in Qt 5.11 return True - if initiator == QUrl('null') and not qtutils.version_check('5.12'): + # https://codereview.qt-project.org/#/c/234849/ + is_opaque = initiator == QUrl('null') + target = request_url.scheme(), request_url.host() + + if is_opaque and not qtutils.version_check('5.12'): # WORKAROUND for https://bugreports.qt.io/browse/QTBUG-70421 + # When we don't register the qute:// scheme, all requests are + # flagged as opaque. + return True + + if (target == ('qute', 'testdata') and + is_opaque and + qtutils.version_check('5.12')): + # Allow requests to qute://testdata, as this is needed in Qt 5.12 + # for all tests to work properly. No qute://testdata handler is + # installed outside of tests. return True if initiator.isValid() and initiator.scheme() != 'qute': log.misc.warning("Blocking malicious request from {} to {}".format( initiator.toDisplayString(), - job.requestUrl().toDisplayString())) + request_url.toDisplayString())) job.fail(QWebEngineUrlRequestJob.RequestDenied) return False diff --git a/qutebrowser/browser/webengine/webenginesettings.py b/qutebrowser/browser/webengine/webenginesettings.py index 10c4d4e6b..315a0325f 100644 --- a/qutebrowser/browser/webengine/webenginesettings.py +++ b/qutebrowser/browser/webengine/webenginesettings.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2016-2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2016-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # @@ -25,6 +25,7 @@ Module attributes: """ import os +import operator from PyQt5.QtGui import QFont from PyQt5.QtWebEngineWidgets import (QWebEngineSettings, QWebEngineProfile, @@ -163,9 +164,14 @@ class WebEngineSettings(websettings.AbstractSettings): # Qt 5.8 'content.print_element_backgrounds': ('PrintElementBackgrounds', None), + # Qt 5.11 'content.autoplay': - ('PlaybackRequiresUserGesture', lambda val: not val), + ('PlaybackRequiresUserGesture', operator.not_), + + # Qt 5.12 + 'content.dns_prefetch': + ('DnsPrefetchEnabled', None), } for name, (attribute, converter) in new_attributes.items(): try: diff --git a/qutebrowser/browser/webengine/webenginetab.py b/qutebrowser/browser/webengine/webenginetab.py index 22380cb1f..9ecdb1955 100644 --- a/qutebrowser/browser/webengine/webenginetab.py +++ b/qutebrowser/browser/webengine/webenginetab.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2016-2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2016-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # @@ -715,8 +715,6 @@ class _WebEnginePermissions(QObject): """Handling of various permission-related signals.""" - _abort_questions = pyqtSignal() - def __init__(self, tab, parent=None): super().__init__(parent) self._tab = tab @@ -736,9 +734,6 @@ class _WebEnginePermissions(QObject): page.registerProtocolHandlerRequested.connect( self._on_register_protocol_handler_requested) - self._tab.shutting_down.connect(self._abort_questions) - self._tab.load_started.connect(self._abort_questions) - @pyqtSlot('QWebEngineFullScreenRequest') def _on_fullscreen_requested(self, request): request.accept() @@ -816,7 +811,7 @@ class _WebEnginePermissions(QObject): question = shared.feature_permission( url=url, option=options[feature], msg=messages[feature], yes_action=yes_action, no_action=no_action, - abort_on=[self._abort_questions]) + abort_on=[self._tab.abort_questions]) if question is not None: page.featurePermissionRequestCanceled.connect( @@ -844,7 +839,7 @@ class _WebEnginePermissions(QObject): option='content.persistent_storage', msg='use {} of persistent storage'.format(size), yes_action=request.accept, no_action=request.reject, - abort_on=[self._abort_questions], + abort_on=[self._tab.abort_questions], blocking=True) def _on_register_protocol_handler_requested(self, request): @@ -853,7 +848,7 @@ class _WebEnginePermissions(QObject): option='content.register_protocol_handler', msg='open all {} links'.format(request.scheme()), yes_action=request.accept, no_action=request.reject, - abort_on=[self._abort_questions], + abort_on=[self._tab.abort_questions], blocking=True) @@ -927,10 +922,14 @@ class _WebEngineScripts(QObject): utils.read_file('javascript/webelem.js'), utils.read_file('javascript/caret.js'), ) - self._inject_early_js('js', - utils.read_file('javascript/print.js'), - subframes=True, - world=QWebEngineScript.MainWorld) + if not qtutils.version_check('5.12'): + # WORKAROUND for Qt versions < 5.12 not exposing window.print(). + # Qt 5.12 has a printRequested() signal so we don't need this hack + # anymore. + self._inject_early_js('js', + utils.read_file('javascript/print.js'), + subframes=True, + world=QWebEngineScript.MainWorld) # FIXME:qtwebengine what about subframes=True? self._inject_early_js('js', js_code, subframes=True) self._init_stylesheet() @@ -1039,9 +1038,15 @@ class _WebEngineScripts(QObject): new_script.setSourceCode(script.code()) new_script.setName("GM-{}".format(script.name)) new_script.setRunsOnSubFrames(script.runs_on_sub_frames) + # Override the @run-at value parsed by QWebEngineScript if desired. if injection_point: new_script.setInjectionPoint(injection_point) + elif script.needs_document_end_workaround(): + log.greasemonkey.debug("Forcing @run-at document-end for {}" + .format(script.name)) + new_script.setInjectionPoint(QWebEngineScript.DocumentReady) + log.greasemonkey.debug('adding script: {}' .format(new_script.name())) page_scripts.insert(new_script) @@ -1076,10 +1081,13 @@ class WebEngineTab(browsertab.AbstractTab): Signals: _load_finished_fake: Used in place of unreliable loadFinished + abort_questions: Emitted when a new load started or we're shutting + down. """ # WORKAROUND for https://bugreports.qt.io/browse/QTBUG-65223 _load_finished_fake = pyqtSignal(bool) + abort_questions = pyqtSignal() def __init__(self, *, win_id, mode_manager, private, parent=None): super().__init__(win_id=win_id, private=private, parent=parent) @@ -1252,15 +1260,13 @@ class WebEngineTab(browsertab.AbstractTab): answer = message.ask( title="Proxy authentication required", text=msg, mode=usertypes.PromptMode.user_pwd, - abort_on=[self.shutting_down, self.load_started], url=urlstr) + abort_on=[self.abort_questions], url=urlstr) if answer is not None: authenticator.setUser(answer.user) authenticator.setPassword(answer.password) else: try: - # pylint: disable=no-member, useless-suppression sip.assign(authenticator, QAuthenticator()) - # pylint: enable=no-member, useless-suppression except AttributeError: self._show_error_page(url, "Proxy authentication required") @@ -1276,15 +1282,12 @@ class WebEngineTab(browsertab.AbstractTab): if not netrc_success: log.network.debug("Asking for credentials") - abort_on = [self.shutting_down, self.load_started] - answer = shared.authentication_required(url, authenticator, - abort_on) + answer = shared.authentication_required( + url, authenticator, abort_on=[self.abort_questions]) if not netrc_success and answer is None: log.network.debug("Aborting auth") try: - # pylint: disable=no-member, useless-suppression sip.assign(authenticator, QAuthenticator()) - # pylint: enable=no-member, useless-suppression except AttributeError: # WORKAROUND for # https://www.riverbankcomputing.com/pipermail/pyqt/2016-December/038400.html @@ -1389,7 +1392,7 @@ class WebEngineTab(browsertab.AbstractTab): if error.is_overridable(): error.ignore = shared.ignore_certificate_errors( - url, [error], abort_on=[self.shutting_down, self.load_started]) + url, [error], abort_on=[self.abort_questions]) else: log.webview.error("Non-overridable certificate error: " "{}".format(error)) @@ -1418,15 +1421,20 @@ class WebEngineTab(browsertab.AbstractTab): if not qtutils.version_check('5.11.1', compiled=False): self.settings.update_for_url(url) + @pyqtSlot() + def _on_print_requested(self): + """Slot for window.print() in JS.""" + try: + self.printing.show_dialog() + except browsertab.WebTabError as e: + message.error(str(e)) + @pyqtSlot(usertypes.NavigationRequest) def _on_navigation_request(self, navigation): super()._on_navigation_request(navigation) if navigation.url == QUrl('qute://print'): - try: - self.printing.show_dialog() - except browsertab.WebTabError as e: - message.error(str(e)) + self._on_print_requested() navigation.accepted = False if not navigation.accepted or not navigation.is_main_frame: @@ -1458,6 +1466,37 @@ class WebEngineTab(browsertab.AbstractTab): if reload_needed: self._reload_url = navigation.url + def _on_select_client_certificate(self, selection): + """Handle client certificates. + + Currently, we simply pick the first available certificate and show an + additional note if there are multiple matches. + """ + certificate = selection.certificates()[0] + text = ('<b>Subject:</b> {subj}<br/>' + '<b>Issuer:</b> {issuer}<br/>' + '<b>Serial:</b> {serial}'.format( + subj=html_utils.escape(certificate.subjectDisplayName()), + issuer=html_utils.escape(certificate.issuerDisplayName()), + serial=bytes(certificate.serialNumber()).decode('ascii'))) + if len(selection.certificates()) > 1: + text += ('<br/><br/><b>Note:</b> Multiple matching certificates ' + 'were found, but certificate selection is not ' + 'implemented yet!') + urlstr = selection.host().host() + + present = message.ask( + title='Present client certificate to {}?'.format(urlstr), + text=text, + mode=usertypes.PromptMode.yesno, + abort_on=[self.abort_questions], + url=urlstr) + + if present: + selection.select(certificate) + else: + selection.selectNone() + def _connect_signals(self): view = self._widget page = view.page() @@ -1473,6 +1512,11 @@ class WebEngineTab(browsertab.AbstractTab): page.contentsSizeChanged.connect(self.contents_size_changed) page.navigation_request.connect(self._on_navigation_request) + if qtutils.version_check('5.12'): + page.printRequested.connect(self._on_print_requested) + page.selectClientCertificate.connect( + self._on_select_client_certificate) + view.titleChanged.connect(self.title_changed) view.urlChanged.connect(self._on_url_changed) view.renderProcessTerminated.connect( @@ -1493,6 +1537,8 @@ class WebEngineTab(browsertab.AbstractTab): page.loadFinished.connect(self._on_load_finished) self.before_load_started.connect(self._on_before_load_started) + self.shutting_down.connect(self.abort_questions) + self.load_started.connect(self.abort_questions) # pylint: disable=protected-access self.audio._connect_signals() diff --git a/qutebrowser/browser/webengine/webview.py b/qutebrowser/browser/webengine/webview.py index e70226f30..f808af592 100644 --- a/qutebrowser/browser/webengine/webview.py +++ b/qutebrowser/browser/webengine/webview.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2014-2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2014-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # @@ -64,6 +64,8 @@ class WebEngineView(QWebEngineView): Normally, this would always be the focusProxy(). However, it sometimes isn't, so we use this as a WORKAROUND for https://bugreports.qt.io/browse/QTBUG-68727 + + This got introduced in Qt 5.11.0 and fixed in 5.12.0. """ if 'lost-focusproxy' not in objreg.get('args').debug_flags: proxy = self.focusProxy() diff --git a/qutebrowser/browser/webkit/__init__.py b/qutebrowser/browser/webkit/__init__.py index 5100b7a53..e276c8b2b 100644 --- a/qutebrowser/browser/webkit/__init__.py +++ b/qutebrowser/browser/webkit/__init__.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2014-2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2014-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # diff --git a/qutebrowser/browser/webkit/cache.py b/qutebrowser/browser/webkit/cache.py index 163612ce9..4844ea0d3 100644 --- a/qutebrowser/browser/webkit/cache.py +++ b/qutebrowser/browser/webkit/cache.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2014-2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2014-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # diff --git a/qutebrowser/browser/webkit/certificateerror.py b/qutebrowser/browser/webkit/certificateerror.py index cad17fba5..646de0bdc 100644 --- a/qutebrowser/browser/webkit/certificateerror.py +++ b/qutebrowser/browser/webkit/certificateerror.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2016-2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2016-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # diff --git a/qutebrowser/browser/webkit/cookies.py b/qutebrowser/browser/webkit/cookies.py index 01b6842a0..9dce9bc11 100644 --- a/qutebrowser/browser/webkit/cookies.py +++ b/qutebrowser/browser/webkit/cookies.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2014-2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2014-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # diff --git a/qutebrowser/browser/webkit/http.py b/qutebrowser/browser/webkit/http.py index 73e620015..d4d3802cd 100644 --- a/qutebrowser/browser/webkit/http.py +++ b/qutebrowser/browser/webkit/http.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2014-2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2014-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # diff --git a/qutebrowser/browser/webkit/mhtml.py b/qutebrowser/browser/webkit/mhtml.py index 70a22351f..e0d714dce 100644 --- a/qutebrowser/browser/webkit/mhtml.py +++ b/qutebrowser/browser/webkit/mhtml.py @@ -1,5 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: +# Copyright 2015-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # Copyright 2015-2018 Daniel Schadt # # This file is part of qutebrowser. diff --git a/qutebrowser/browser/webkit/network/filescheme.py b/qutebrowser/browser/webkit/network/filescheme.py index a29674e25..c036bd6e6 100644 --- a/qutebrowser/browser/webkit/network/filescheme.py +++ b/qutebrowser/browser/webkit/network/filescheme.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2014-2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2014-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # Copyright 2015-2018 Antoni Boucher (antoyo) <bouanto@zoho.com> # # This file is part of qutebrowser. diff --git a/qutebrowser/browser/webkit/network/networkmanager.py b/qutebrowser/browser/webkit/network/networkmanager.py index dd3643c87..fd95f29fb 100644 --- a/qutebrowser/browser/webkit/network/networkmanager.py +++ b/qutebrowser/browser/webkit/network/networkmanager.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2014-2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2014-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # diff --git a/qutebrowser/browser/webkit/network/networkreply.py b/qutebrowser/browser/webkit/network/networkreply.py index c56fe2a9b..99546c90d 100644 --- a/qutebrowser/browser/webkit/network/networkreply.py +++ b/qutebrowser/browser/webkit/network/networkreply.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2014-2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2014-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # Based on the Eric5 helpviewer, # Copyright (c) 2009 - 2014 Detlev Offenbach <detlev@die-offenbachs.de> @@ -34,8 +34,7 @@ class FixedDataNetworkReply(QNetworkReply): """QNetworkReply subclass for fixed data.""" - def __init__(self, request, fileData, mimeType, # noqa: N803 - parent=None): + def __init__(self, request, fileData, mimeType, parent=None): # noqa: N803 """Constructor. Args: diff --git a/qutebrowser/browser/webkit/network/webkitqutescheme.py b/qutebrowser/browser/webkit/network/webkitqutescheme.py index c05097b79..a90255323 100644 --- a/qutebrowser/browser/webkit/network/webkitqutescheme.py +++ b/qutebrowser/browser/webkit/network/webkitqutescheme.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2014-2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2014-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # diff --git a/qutebrowser/browser/webkit/rfc6266.py b/qutebrowser/browser/webkit/rfc6266.py index 139b4f9df..2ffc39f88 100644 --- a/qutebrowser/browser/webkit/rfc6266.py +++ b/qutebrowser/browser/webkit/rfc6266.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2014-2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2014-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # diff --git a/qutebrowser/browser/webkit/tabhistory.py b/qutebrowser/browser/webkit/tabhistory.py index 263bf6334..a4fd2ce85 100644 --- a/qutebrowser/browser/webkit/tabhistory.py +++ b/qutebrowser/browser/webkit/tabhistory.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2015-2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2015-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # @@ -89,8 +89,7 @@ def serialize(items): if current_idx is not None: raise ValueError("Multiple active items ({} and {}) " "found!".format(current_idx, i)) - else: - current_idx = i + current_idx = i if items: if current_idx is None: diff --git a/qutebrowser/browser/webkit/webkitelem.py b/qutebrowser/browser/webkit/webkitelem.py index af0db295d..c0188b683 100644 --- a/qutebrowser/browser/webkit/webkitelem.py +++ b/qutebrowser/browser/webkit/webkitelem.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2014-2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2014-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # diff --git a/qutebrowser/browser/webkit/webkithistory.py b/qutebrowser/browser/webkit/webkithistory.py index 65d9bbb01..a0d41088d 100644 --- a/qutebrowser/browser/webkit/webkithistory.py +++ b/qutebrowser/browser/webkit/webkithistory.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2015-2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2015-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # diff --git a/qutebrowser/browser/webkit/webkitinspector.py b/qutebrowser/browser/webkit/webkitinspector.py index d590d4adf..e2652b9f4 100644 --- a/qutebrowser/browser/webkit/webkitinspector.py +++ b/qutebrowser/browser/webkit/webkitinspector.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2015-2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2015-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # diff --git a/qutebrowser/browser/webkit/webkitsettings.py b/qutebrowser/browser/webkit/webkitsettings.py index cce1dcec0..fac86285e 100644 --- a/qutebrowser/browser/webkit/webkitsettings.py +++ b/qutebrowser/browser/webkit/webkitsettings.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2016-2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2016-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # diff --git a/qutebrowser/browser/webkit/webkittab.py b/qutebrowser/browser/webkit/webkittab.py index c10c2aeec..8c72dbbf0 100644 --- a/qutebrowser/browser/webkit/webkittab.py +++ b/qutebrowser/browser/webkit/webkittab.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2016-2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2016-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # diff --git a/qutebrowser/browser/webkit/webpage.py b/qutebrowser/browser/webkit/webpage.py index 0195ec17f..1b4b85c65 100644 --- a/qutebrowser/browser/webkit/webpage.py +++ b/qutebrowser/browser/webkit/webpage.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2014-2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2014-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # diff --git a/qutebrowser/browser/webkit/webview.py b/qutebrowser/browser/webkit/webview.py index 8921e211c..b6b4c0683 100644 --- a/qutebrowser/browser/webkit/webview.py +++ b/qutebrowser/browser/webkit/webview.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2014-2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2014-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # diff --git a/qutebrowser/commands/__init__.py b/qutebrowser/commands/__init__.py index 6ba8a9ae3..25b9e9763 100644 --- a/qutebrowser/commands/__init__.py +++ b/qutebrowser/commands/__init__.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2014-2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2014-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # diff --git a/qutebrowser/commands/argparser.py b/qutebrowser/commands/argparser.py index 707324ede..289cdb54b 100644 --- a/qutebrowser/commands/argparser.py +++ b/qutebrowser/commands/argparser.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2014-2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2014-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # diff --git a/qutebrowser/commands/cmdexc.py b/qutebrowser/commands/cmdexc.py index f342f2436..5eb465a24 100644 --- a/qutebrowser/commands/cmdexc.py +++ b/qutebrowser/commands/cmdexc.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2014-2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2014-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # diff --git a/qutebrowser/commands/command.py b/qutebrowser/commands/command.py index 46f92772f..044816fdb 100644 --- a/qutebrowser/commands/command.py +++ b/qutebrowser/commands/command.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2014-2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2014-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # @@ -402,7 +402,8 @@ class Command: if isinstance(typ, tuple): raise TypeError("{}: Legacy tuple type annotation!".format( self.name)) - elif getattr(typ, '__origin__', None) is typing.Union or ( + + if getattr(typ, '__origin__', None) is typing.Union or ( # Older Python 3.5 patch versions # pylint: disable=no-member,useless-suppression hasattr(typing, 'UnionMeta') and diff --git a/qutebrowser/commands/runners.py b/qutebrowser/commands/runners.py index 666c79f3e..556a54d69 100644 --- a/qutebrowser/commands/runners.py +++ b/qutebrowser/commands/runners.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2014-2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2014-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # diff --git a/qutebrowser/commands/userscripts.py b/qutebrowser/commands/userscripts.py index 8d95db07d..6470a5365 100644 --- a/qutebrowser/commands/userscripts.py +++ b/qutebrowser/commands/userscripts.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2014-2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2014-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # diff --git a/qutebrowser/completion/__init__.py b/qutebrowser/completion/__init__.py index 2c9121699..ab188f92e 100644 --- a/qutebrowser/completion/__init__.py +++ b/qutebrowser/completion/__init__.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2014-2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2014-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # diff --git a/qutebrowser/completion/completer.py b/qutebrowser/completion/completer.py index ea64225d5..678a28af9 100644 --- a/qutebrowser/completion/completer.py +++ b/qutebrowser/completion/completer.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2014-2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2014-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # diff --git a/qutebrowser/completion/completiondelegate.py b/qutebrowser/completion/completiondelegate.py index b58f36372..63818598d 100644 --- a/qutebrowser/completion/completiondelegate.py +++ b/qutebrowser/completion/completiondelegate.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2014-2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2014-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # diff --git a/qutebrowser/completion/completionwidget.py b/qutebrowser/completion/completionwidget.py index 0af4ecbe1..53eecc522 100644 --- a/qutebrowser/completion/completionwidget.py +++ b/qutebrowser/completion/completionwidget.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2014-2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2014-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # diff --git a/qutebrowser/completion/models/__init__.py b/qutebrowser/completion/models/__init__.py index 7f62829ba..960e0766c 100644 --- a/qutebrowser/completion/models/__init__.py +++ b/qutebrowser/completion/models/__init__.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2014-2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2014-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # diff --git a/qutebrowser/completion/models/completionmodel.py b/qutebrowser/completion/models/completionmodel.py index 36a465fb7..d7cef71e2 100644 --- a/qutebrowser/completion/models/completionmodel.py +++ b/qutebrowser/completion/models/completionmodel.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2017-2018 Ryan Roden-Corrent (rcorre) <ryan@rcorre.net> +# Copyright 2017-2019 Ryan Roden-Corrent (rcorre) <ryan@rcorre.net> # # This file is part of qutebrowser. # diff --git a/qutebrowser/completion/models/configmodel.py b/qutebrowser/completion/models/configmodel.py index 19b252242..9c1093532 100644 --- a/qutebrowser/completion/models/configmodel.py +++ b/qutebrowser/completion/models/configmodel.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2014-2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2014-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # diff --git a/qutebrowser/completion/models/histcategory.py b/qutebrowser/completion/models/histcategory.py index 83eafef50..8b1be213a 100644 --- a/qutebrowser/completion/models/histcategory.py +++ b/qutebrowser/completion/models/histcategory.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2017-2018 Ryan Roden-Corrent (rcorre) <ryan@rcorre.net> +# Copyright 2017-2019 Ryan Roden-Corrent (rcorre) <ryan@rcorre.net> # # This file is part of qutebrowser. # diff --git a/qutebrowser/completion/models/listcategory.py b/qutebrowser/completion/models/listcategory.py index 78844f53f..1ff9dbab4 100644 --- a/qutebrowser/completion/models/listcategory.py +++ b/qutebrowser/completion/models/listcategory.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2017-2018 Ryan Roden-Corrent (rcorre) <ryan@rcorre.net> +# Copyright 2017-2019 Ryan Roden-Corrent (rcorre) <ryan@rcorre.net> # # This file is part of qutebrowser. # diff --git a/qutebrowser/completion/models/miscmodels.py b/qutebrowser/completion/models/miscmodels.py index 74b75aeb1..9c1cc20fc 100644 --- a/qutebrowser/completion/models/miscmodels.py +++ b/qutebrowser/completion/models/miscmodels.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2014-2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2014-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # diff --git a/qutebrowser/completion/models/urlmodel.py b/qutebrowser/completion/models/urlmodel.py index f2e6fe5f5..137afb00a 100644 --- a/qutebrowser/completion/models/urlmodel.py +++ b/qutebrowser/completion/models/urlmodel.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2014-2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2014-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # diff --git a/qutebrowser/completion/models/util.py b/qutebrowser/completion/models/util.py index 08f99eb6c..32f32f1c6 100644 --- a/qutebrowser/completion/models/util.py +++ b/qutebrowser/completion/models/util.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2017-2018 Ryan Roden-Corrent (rcorre) <ryan@rcorre.net> +# Copyright 2017-2019 Ryan Roden-Corrent (rcorre) <ryan@rcorre.net> # # This file is part of qutebrowser. # diff --git a/qutebrowser/components/__init__.py b/qutebrowser/components/__init__.py index 1a13763bf..63b8d8db3 100644 --- a/qutebrowser/components/__init__.py +++ b/qutebrowser/components/__init__.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2018-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # diff --git a/qutebrowser/components/adblock.py b/qutebrowser/components/adblock.py index 9baa12d7c..8ceeccc1a 100644 --- a/qutebrowser/components/adblock.py +++ b/qutebrowser/components/adblock.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2014-2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2014-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # diff --git a/qutebrowser/components/caretcommands.py b/qutebrowser/components/caretcommands.py index 4bab6b6c6..c12dab270 100644 --- a/qutebrowser/components/caretcommands.py +++ b/qutebrowser/components/caretcommands.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2018-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # diff --git a/qutebrowser/components/misccommands.py b/qutebrowser/components/misccommands.py index a65bdd235..fc5fce225 100644 --- a/qutebrowser/components/misccommands.py +++ b/qutebrowser/components/misccommands.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2018-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # @@ -292,8 +292,7 @@ def debug_crash(typ: str = 'exception') -> None: if typ == 'segfault': os.kill(os.getpid(), signal.SIGSEGV) raise Exception("Segfault failed (wat.)") - else: - raise Exception("Forced crash") + raise Exception("Forced crash") @cmdutils.register(debug=True, maxsplit=0, no_cmd_split=True) diff --git a/qutebrowser/components/scrollcommands.py b/qutebrowser/components/scrollcommands.py index 0b8943f2d..15030ec3d 100644 --- a/qutebrowser/components/scrollcommands.py +++ b/qutebrowser/components/scrollcommands.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2018-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # diff --git a/qutebrowser/components/zoomcommands.py b/qutebrowser/components/zoomcommands.py index 51d01cfea..f2796cfcc 100644 --- a/qutebrowser/components/zoomcommands.py +++ b/qutebrowser/components/zoomcommands.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2018-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # diff --git a/qutebrowser/config/__init__.py b/qutebrowser/config/__init__.py index e2c25cce8..b124d26ae 100644 --- a/qutebrowser/config/__init__.py +++ b/qutebrowser/config/__init__.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2014-2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2014-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # diff --git a/qutebrowser/config/config.py b/qutebrowser/config/config.py index 201b87fde..a51126c1b 100644 --- a/qutebrowser/config/config.py +++ b/qutebrowser/config/config.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2014-2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2014-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # diff --git a/qutebrowser/config/configcache.py b/qutebrowser/config/configcache.py index 15f343478..b417f2a8e 100644 --- a/qutebrowser/config/configcache.py +++ b/qutebrowser/config/configcache.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2018 Jay Kamat <jaygkamat@gmail.com> +# Copyright 2018-2019 Jay Kamat <jaygkamat@gmail.com> # # This file is part of qutebrowser. # diff --git a/qutebrowser/config/configcommands.py b/qutebrowser/config/configcommands.py index 5d5b2db7e..410d415d5 100644 --- a/qutebrowser/config/configcommands.py +++ b/qutebrowser/config/configcommands.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2014-2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2014-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # diff --git a/qutebrowser/config/configdata.py b/qutebrowser/config/configdata.py index 61e35fd53..73ccf6eda 100644 --- a/qutebrowser/config/configdata.py +++ b/qutebrowser/config/configdata.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2014-2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2014-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # @@ -91,15 +91,15 @@ def _parse_yaml_type( ) -> configtypes.BaseType: if isinstance(node, str): # e.g: - # type: Bool + # > type: Bool # -> create the type object without any arguments type_name = node kwargs = {} # type: typing.MutableMapping[str, typing.Any] elif isinstance(node, dict): # e.g: - # type: - # name: String - # none_ok: true + # > type: + # > name: String + # > none_ok: true # -> create the type object and pass arguments type_name = node.pop('name') kwargs = node @@ -164,6 +164,7 @@ def _parse_yaml_backends_dict( 'Qt 5.9.2': qtutils.version_check('5.9.2'), 'Qt 5.10': qtutils.version_check('5.10'), 'Qt 5.11': qtutils.version_check('5.11'), + 'Qt 5.12': qtutils.version_check('5.12'), } for key in sorted(node.keys()): if conditionals[node[key]]: diff --git a/qutebrowser/config/configdata.yml b/qutebrowser/config/configdata.yml index b6d4736ae..e2d443280 100644 --- a/qutebrowser/config/configdata.yml +++ b/qutebrowser/config/configdata.yml @@ -379,7 +379,9 @@ content.developer_extras: content.dns_prefetch: default: true type: Bool - backend: QtWebKit + backend: + QtWebKit: true + QtWebEngine: Qt 5.12 supports_pattern: true desc: Try to pre-fetch DNS entries to speed up browsing. @@ -476,46 +478,14 @@ content.headers.user_agent: # 'ua_fetch.py' # Vim-protip: Place your cursor below this comment and run # :r!python scripts/dev/ua_fetch.py - - - "Mozilla/5.0 (Windows NT 6.3; WOW64; rv:53.0) Gecko/20100101 - Firefox/53.0" - - Firefox 53.0 Win8.1 - - - "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:53.0) Gecko/20100101 - Firefox/53.0" - - Firefox 53.0 Linux - - - "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:53.0) - Gecko/20100101 Firefox/53.0" - - Firefox 53.0 MacOSX - - - - "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_5) AppleWebKit/603.2.4 - (KHTML, like Gecko) Version/10.1.1 Safari/603.2.4" - - Safari Generic MacOSX - - - "Mozilla/5.0 (iPad; CPU OS 10_3_1 like Mac OS X) AppleWebKit/603.1.30 - (KHTML, like Gecko) Version/10.0 Mobile/14E304 Safari/602.1" - - Mobile Safari 10.0 iOS - - - "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, - like Gecko) Chrome/58.0.3029.110 Safari/537.36" - - Chrome Generic Win10 - - - "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_5) AppleWebKit/537.36 - (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36" - - Chrome Generic MacOSX + like Gecko) Chrome/71.0.3578.98 Safari/537.36" + - Chrome 71.0 Win10 - - "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like - Gecko) Chrome/58.0.3029.110 Safari/537.36" - - Chrome Generic Linux - - - - "Mozilla/5.0 (compatible; Googlebot/2.1; - +http://www.google.com/bot.html" - - Google Bot - - - "Wget/1.16.1 (linux-gnu)" - - wget 1.16.1 - - - "curl/7.40.0" - - curl 7.40.0 - - - "Mozilla/5.0 (Linux; U; Android 7.1.2) AppleWebKit/534.30 (KHTML, - like Gecko) Version/4.0 Mobile Safari/534.30" - - Mobile Generic Android - - - "Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like - Gecko" - - IE 11.0 for Desktop Win7 64-bit + Gecko) Chrome/71.0.3578.98 Safari/537.36" + - Chrome 71.0 Linux + - - "" + - Use default QtWebKit/QtWebEngine User-Agent supports_pattern: true desc: >- @@ -1266,6 +1236,16 @@ input.insert_mode.plugins: type: Bool desc: Switch to insert mode when clicking flash and other plugins. +input.insert_mode.leave_on_load: + default: true + type: Bool + supports_pattern: true + desc: >- + Leave insert mode when starting a new page load. + + Patterns may be unreliable on this setting, and they may match the url you + are navigating to, or the URL you are navigating from. + input.links_included_in_focus_chain: default: true type: Bool diff --git a/qutebrowser/config/configdiff.py b/qutebrowser/config/configdiff.py index ba78f64b4..beefc3d8a 100644 --- a/qutebrowser/config/configdiff.py +++ b/qutebrowser/config/configdiff.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2017-2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2017-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # diff --git a/qutebrowser/config/configexc.py b/qutebrowser/config/configexc.py index 80a2cedb2..9f53847cb 100644 --- a/qutebrowser/config/configexc.py +++ b/qutebrowser/config/configexc.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2014-2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2014-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # diff --git a/qutebrowser/config/configfiles.py b/qutebrowser/config/configfiles.py index de50dfca9..0d1dcb22f 100644 --- a/qutebrowser/config/configfiles.py +++ b/qutebrowser/config/configfiles.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2014-2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2014-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # diff --git a/qutebrowser/config/configinit.py b/qutebrowser/config/configinit.py index ff0fd0e41..cfde2d076 100644 --- a/qutebrowser/config/configinit.py +++ b/qutebrowser/config/configinit.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2017-2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2017-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # diff --git a/qutebrowser/config/configtypes.py b/qutebrowser/config/configtypes.py index 3f134f770..2a855a42d 100644 --- a/qutebrowser/config/configtypes.py +++ b/qutebrowser/config/configtypes.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2014-2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2014-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # @@ -176,8 +176,7 @@ class BaseType: (pytype == dict and value == {})): if not self.none_ok: raise configexc.ValidationError(value, "may not be null!") - else: - return + return if (not isinstance(value, pytype) or pytype is int and isinstance(value, bool)): @@ -365,9 +364,9 @@ class String(BaseType): if minlen is not None and minlen < 1: raise ValueError("minlen ({}) needs to be >= 1!".format(minlen)) - elif maxlen is not None and maxlen < 1: + if maxlen is not None and maxlen < 1: raise ValueError("maxlen ({}) needs to be >= 1!".format(maxlen)) - elif maxlen is not None and minlen is not None and maxlen < minlen: + if maxlen is not None and minlen is not None and maxlen < minlen: raise ValueError("minlen ({}) needs to be <= maxlen ({})!".format( minlen, maxlen)) self.minlen = minlen @@ -1271,8 +1270,7 @@ class Regex(BaseType): str(w.message).startswith('bad escape')): raise configexc.ValidationError( pattern, "must be a valid regex - " + str(w.message)) - else: - warnings.warn(w.message) + warnings.warn(w.message) return compiled @@ -1803,7 +1801,7 @@ class ConfirmQuit(FlagList): raise configexc.ValidationError( values, "List cannot contain never!") # Always can't be set with other options - elif 'always' in values and len(values) > 1: + if 'always' in values and len(values) > 1: raise configexc.ValidationError( values, "List cannot contain always!") diff --git a/qutebrowser/config/configutils.py b/qutebrowser/config/configutils.py index 47cac4bff..6392e4ca6 100644 --- a/qutebrowser/config/configutils.py +++ b/qutebrowser/config/configutils.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2018-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # diff --git a/qutebrowser/config/websettings.py b/qutebrowser/config/websettings.py index 5a21af7e3..8883864fc 100644 --- a/qutebrowser/config/websettings.py +++ b/qutebrowser/config/websettings.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2014-2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2014-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # diff --git a/qutebrowser/extensions/interceptors.py b/qutebrowser/extensions/interceptors.py index 7defcf213..7b95cff72 100644 --- a/qutebrowser/extensions/interceptors.py +++ b/qutebrowser/extensions/interceptors.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2018-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # @@ -20,6 +20,7 @@ """Infrastructure for intercepting requests.""" import typing +import enum import attr @@ -29,6 +30,34 @@ if MYPY: from PyQt5.QtCore import QUrl +class ResourceType(enum.Enum): + """Possible request types that can be received. + + Currently corresponds to the QWebEngineUrlRequestInfo Enum: + https://doc.qt.io/qt-5/qwebengineurlrequestinfo.html#ResourceType-enum + """ + + main_frame = 0 + sub_frame = 1 + stylesheet = 2 + script = 3 + image = 4 + font_resource = 5 + sub_resource = 6 + object = 7 + media = 8 + worker = 9 + shared_worker = 10 + prefetch = 11 + favicon = 12 + xhr = 13 + ping = 14 + service_worker = 15 + csp_report = 16 + plugin_resource = 17 + unknown = 255 + + @attr.s class Request: @@ -42,6 +71,9 @@ class Request: is_blocked = attr.ib(False) # type: bool + #: The resource type of the request. None if not supported on this backend. + resource_type = attr.ib(None) # type: typing.Optional[ResourceType] + def block(self) -> None: """Block this request.""" self.is_blocked = True diff --git a/qutebrowser/extensions/loader.py b/qutebrowser/extensions/loader.py index 1383adfef..d10e0919f 100644 --- a/qutebrowser/extensions/loader.py +++ b/qutebrowser/extensions/loader.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2018-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # diff --git a/qutebrowser/javascript/.eslintrc.yaml b/qutebrowser/javascript/.eslintrc.yaml index cb1bb1fcb..f4af6914b 100644 --- a/qutebrowser/javascript/.eslintrc.yaml +++ b/qutebrowser/javascript/.eslintrc.yaml @@ -60,3 +60,4 @@ rules: max-lines-per-function: "off" require-unicode-regexp: "off" max-params: "off" + prefer-named-capture-group: "off" diff --git a/qutebrowser/javascript/caret.js b/qutebrowser/javascript/caret.js index 5e6640311..73b763af2 100644 --- a/qutebrowser/javascript/caret.js +++ b/qutebrowser/javascript/caret.js @@ -30,7 +30,7 @@ default-case */ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /** - * Copyright 2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> + * Copyright 2018-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> * * This file is part of qutebrowser. * diff --git a/qutebrowser/javascript/history.js b/qutebrowser/javascript/history.js index 093b95b4e..706db9c65 100644 --- a/qutebrowser/javascript/history.js +++ b/qutebrowser/javascript/history.js @@ -1,4 +1,5 @@ /** + * Copyright 2017-2019 Florian Bruhin (The-Compiler) <me@the-compiler.org> * Copyright 2017 Imran Sobir * * This file is part of qutebrowser. diff --git a/qutebrowser/javascript/position_caret.js b/qutebrowser/javascript/position_caret.js index 0ead360fb..5aeff44fa 100644 --- a/qutebrowser/javascript/position_caret.js +++ b/qutebrowser/javascript/position_caret.js @@ -1,6 +1,6 @@ /** +* Copyright 2015-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> * Copyright 2015 Artur Shaik <ashaihullin@gmail.com> -* Copyright 2015-2017 Florian Bruhin (The Compiler) <mail@qutebrowser.org> * * This file is part of qutebrowser. * diff --git a/qutebrowser/javascript/print.js b/qutebrowser/javascript/print.js index ceb34aa65..b91b45c97 100644 --- a/qutebrowser/javascript/print.js +++ b/qutebrowser/javascript/print.js @@ -1,5 +1,5 @@ /** - * Copyright 2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> + * Copyright 2018-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> * * This file is part of qutebrowser. * diff --git a/qutebrowser/javascript/scroll.js b/qutebrowser/javascript/scroll.js index 7205cb151..1f74a9956 100644 --- a/qutebrowser/javascript/scroll.js +++ b/qutebrowser/javascript/scroll.js @@ -1,5 +1,5 @@ /** - * Copyright 2016-2017 Florian Bruhin (The Compiler) <mail@qutebrowser.org> + * Copyright 2016-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> * * This file is part of qutebrowser. * diff --git a/qutebrowser/javascript/stylesheet.js b/qutebrowser/javascript/stylesheet.js index b1cdeb26e..549d9b88b 100644 --- a/qutebrowser/javascript/stylesheet.js +++ b/qutebrowser/javascript/stylesheet.js @@ -1,4 +1,5 @@ /** + * Copyright 2017-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> * Copyright 2017 Ulrik de Muelenaere <ulrikdem@gmail.com> * * This file is part of qutebrowser. @@ -40,6 +41,11 @@ window._qutebrowser.stylesheet = (function() { // then move the stylesheet to the end. Partially inspired by Stylus: // https://github.com/openstyles/stylus/blob/1.1.4.2/content/apply.js#L235-L355 function watch_root() { + if (!document.documentElement) { + root_observer.observe(document, {"childList": true}); + return; + } + if (root_elem !== document.documentElement) { root_elem = document.documentElement; root_observer.disconnect(); @@ -53,7 +59,8 @@ window._qutebrowser.stylesheet = (function() { function create_style() { let ns = xhtml_ns; - if (document.documentElement.namespaceURI === svg_ns) { + if (document.documentElement && + document.documentElement.namespaceURI === svg_ns) { ns = svg_ns; } style_elem = document.createElementNS(ns, "style"); diff --git a/qutebrowser/javascript/webelem.js b/qutebrowser/javascript/webelem.js index c9d2d09a6..069b0484d 100644 --- a/qutebrowser/javascript/webelem.js +++ b/qutebrowser/javascript/webelem.js @@ -1,5 +1,5 @@ /** - * Copyright 2016-2017 Florian Bruhin (The Compiler) <mail@qutebrowser.org> + * Copyright 2016-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> * * This file is part of qutebrowser. * diff --git a/qutebrowser/keyinput/__init__.py b/qutebrowser/keyinput/__init__.py index 1cff4943b..c292f2df3 100644 --- a/qutebrowser/keyinput/__init__.py +++ b/qutebrowser/keyinput/__init__.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2014-2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2014-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # diff --git a/qutebrowser/keyinput/basekeyparser.py b/qutebrowser/keyinput/basekeyparser.py index 8161293cc..a6d257617 100644 --- a/qutebrowser/keyinput/basekeyparser.py +++ b/qutebrowser/keyinput/basekeyparser.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2014-2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2014-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # diff --git a/qutebrowser/keyinput/keyutils.py b/qutebrowser/keyinput/keyutils.py index 3d47aad80..0eaf91efc 100644 --- a/qutebrowser/keyinput/keyutils.py +++ b/qutebrowser/keyinput/keyutils.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2014-2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2014-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # diff --git a/qutebrowser/keyinput/macros.py b/qutebrowser/keyinput/macros.py index 5bf1ab18b..a0116c19f 100644 --- a/qutebrowser/keyinput/macros.py +++ b/qutebrowser/keyinput/macros.py @@ -1,5 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: +# Copyright 2016-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # Copyright 2016-2018 Jan Verbeek (blyxxyz) <ring@openmailbox.org> # # This file is part of qutebrowser. diff --git a/qutebrowser/keyinput/modeman.py b/qutebrowser/keyinput/modeman.py index e9b3f1db3..2fcf0df72 100644 --- a/qutebrowser/keyinput/modeman.py +++ b/qutebrowser/keyinput/modeman.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2014-2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2014-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # diff --git a/qutebrowser/keyinput/modeparsers.py b/qutebrowser/keyinput/modeparsers.py index 209d7dea2..e40d89f58 100644 --- a/qutebrowser/keyinput/modeparsers.py +++ b/qutebrowser/keyinput/modeparsers.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2014-2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2014-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # diff --git a/qutebrowser/mainwindow/__init__.py b/qutebrowser/mainwindow/__init__.py index 1b76e9b5a..50bf30add 100644 --- a/qutebrowser/mainwindow/__init__.py +++ b/qutebrowser/mainwindow/__init__.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2014-2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2014-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # diff --git a/qutebrowser/mainwindow/mainwindow.py b/qutebrowser/mainwindow/mainwindow.py index 34dc5c507..a80fa0150 100644 --- a/qutebrowser/mainwindow/mainwindow.py +++ b/qutebrowser/mainwindow/mainwindow.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2014-2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2014-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # diff --git a/qutebrowser/mainwindow/messageview.py b/qutebrowser/mainwindow/messageview.py index 43ddd5248..fd6beb2dc 100644 --- a/qutebrowser/mainwindow/messageview.py +++ b/qutebrowser/mainwindow/messageview.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2016-2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2016-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # diff --git a/qutebrowser/mainwindow/prompt.py b/qutebrowser/mainwindow/prompt.py index f666aa837..4f9457acd 100644 --- a/qutebrowser/mainwindow/prompt.py +++ b/qutebrowser/mainwindow/prompt.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2016-2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2016-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # diff --git a/qutebrowser/mainwindow/statusbar/__init__.py b/qutebrowser/mainwindow/statusbar/__init__.py index eee7cf990..a65da3461 100644 --- a/qutebrowser/mainwindow/statusbar/__init__.py +++ b/qutebrowser/mainwindow/statusbar/__init__.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2014-2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2014-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # diff --git a/qutebrowser/mainwindow/statusbar/backforward.py b/qutebrowser/mainwindow/statusbar/backforward.py index 5e244cf8c..63f502be7 100644 --- a/qutebrowser/mainwindow/statusbar/backforward.py +++ b/qutebrowser/mainwindow/statusbar/backforward.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2017-2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2017-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # diff --git a/qutebrowser/mainwindow/statusbar/bar.py b/qutebrowser/mainwindow/statusbar/bar.py index 13a368f05..545d6d288 100644 --- a/qutebrowser/mainwindow/statusbar/bar.py +++ b/qutebrowser/mainwindow/statusbar/bar.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2014-2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2014-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # diff --git a/qutebrowser/mainwindow/statusbar/command.py b/qutebrowser/mainwindow/statusbar/command.py index 1661d2362..bdac24d61 100644 --- a/qutebrowser/mainwindow/statusbar/command.py +++ b/qutebrowser/mainwindow/statusbar/command.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2014-2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2014-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # diff --git a/qutebrowser/mainwindow/statusbar/keystring.py b/qutebrowser/mainwindow/statusbar/keystring.py index 73b23a65d..6e4bf6520 100644 --- a/qutebrowser/mainwindow/statusbar/keystring.py +++ b/qutebrowser/mainwindow/statusbar/keystring.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2014-2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2014-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # diff --git a/qutebrowser/mainwindow/statusbar/percentage.py b/qutebrowser/mainwindow/statusbar/percentage.py index a362fd9d6..90aea7910 100644 --- a/qutebrowser/mainwindow/statusbar/percentage.py +++ b/qutebrowser/mainwindow/statusbar/percentage.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2014-2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2014-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # diff --git a/qutebrowser/mainwindow/statusbar/progress.py b/qutebrowser/mainwindow/statusbar/progress.py index 6c467150b..37d4bd41b 100644 --- a/qutebrowser/mainwindow/statusbar/progress.py +++ b/qutebrowser/mainwindow/statusbar/progress.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2014-2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2014-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # diff --git a/qutebrowser/mainwindow/statusbar/tabindex.py b/qutebrowser/mainwindow/statusbar/tabindex.py index 47a775f34..fca2a28a4 100644 --- a/qutebrowser/mainwindow/statusbar/tabindex.py +++ b/qutebrowser/mainwindow/statusbar/tabindex.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2015-2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2015-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # diff --git a/qutebrowser/mainwindow/statusbar/text.py b/qutebrowser/mainwindow/statusbar/text.py index 0a57446f1..f083889c5 100644 --- a/qutebrowser/mainwindow/statusbar/text.py +++ b/qutebrowser/mainwindow/statusbar/text.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2014-2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2014-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # diff --git a/qutebrowser/mainwindow/statusbar/textbase.py b/qutebrowser/mainwindow/statusbar/textbase.py index 399fafee7..f58c63402 100644 --- a/qutebrowser/mainwindow/statusbar/textbase.py +++ b/qutebrowser/mainwindow/statusbar/textbase.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2014-2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2014-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # diff --git a/qutebrowser/mainwindow/statusbar/url.py b/qutebrowser/mainwindow/statusbar/url.py index c6f436617..a99c23529 100644 --- a/qutebrowser/mainwindow/statusbar/url.py +++ b/qutebrowser/mainwindow/statusbar/url.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2014-2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2014-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # diff --git a/qutebrowser/mainwindow/tabbedbrowser.py b/qutebrowser/mainwindow/tabbedbrowser.py index 9c14df3ae..11fe0b600 100644 --- a/qutebrowser/mainwindow/tabbedbrowser.py +++ b/qutebrowser/mainwindow/tabbedbrowser.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2014-2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2014-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # @@ -586,10 +586,20 @@ class TabbedBrowser(QWidget): @pyqtSlot() def on_cur_load_started(self): """Leave insert/hint mode when loading started.""" - modeman.leave(self._win_id, usertypes.KeyMode.insert, 'load started', - maybe=True) - modeman.leave(self._win_id, usertypes.KeyMode.hint, 'load started', - maybe=True) + try: + url = self.current_url() + if not url.isValid(): + url = None + except qtutils.QtValueError: + url = None + if config.instance.get('input.insert_mode.leave_on_load', + url=url): + modeman.leave(self._win_id, usertypes.KeyMode.insert, + 'load started', maybe=True) + else: + log.modes.debug("Ignoring leave_on_load request due to setting.") + modeman.leave(self._win_id, usertypes.KeyMode.hint, + 'load started', maybe=True) @pyqtSlot(browsertab.AbstractTab, str) def on_title_changed(self, tab, text): diff --git a/qutebrowser/mainwindow/tabwidget.py b/qutebrowser/mainwindow/tabwidget.py index ca4be6d50..0df47bf76 100644 --- a/qutebrowser/mainwindow/tabwidget.py +++ b/qutebrowser/mainwindow/tabwidget.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2014-2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2014-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # @@ -355,6 +355,17 @@ class TabWidget(QTabWidget): if config.val.tabs.tabs_are_windows: self.window().setWindowIcon(self.window().windowIcon()) + def setTabIcon(self, idx: int, icon: QIcon): + """Always show tab icons for pinned tabs in some circumstances.""" + tab = self.widget(idx) + if (icon.isNull() and + config.cache['tabs.favicons.show'] != 'never' and + config.cache['tabs.pinned.shrink'] and + not self.tabBar().vertical and + tab is not None and tab.data.pinned): + icon = self.style().standardIcon(QStyle.SP_FileIcon) + super().setTabIcon(idx, icon) + class TabBar(QTabBar): diff --git a/qutebrowser/misc/__init__.py b/qutebrowser/misc/__init__.py index 2be43490a..5164c0fde 100644 --- a/qutebrowser/misc/__init__.py +++ b/qutebrowser/misc/__init__.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2014-2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2014-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # diff --git a/qutebrowser/misc/autoupdate.py b/qutebrowser/misc/autoupdate.py index d223bd366..51aa84112 100644 --- a/qutebrowser/misc/autoupdate.py +++ b/qutebrowser/misc/autoupdate.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2014-2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2014-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # diff --git a/qutebrowser/misc/backendproblem.py b/qutebrowser/misc/backendproblem.py index 74a2ad372..da9392f3d 100644 --- a/qutebrowser/misc/backendproblem.py +++ b/qutebrowser/misc/backendproblem.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2017-2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2017-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # @@ -178,6 +178,10 @@ def _nvidia_shader_workaround(): See https://bugs.launchpad.net/ubuntu/+source/python-qt4/+bug/941826 """ assert objects.backend == usertypes.Backend.QtWebEngine, objects.backend + + if os.environ.get('QUTE_SKIP_LIBGL_WORKAROUND'): + return + libgl = ctypes.util.find_library("GL") if libgl is not None: ctypes.CDLL(libgl, mode=ctypes.RTLD_GLOBAL) diff --git a/qutebrowser/misc/checkpyver.py b/qutebrowser/misc/checkpyver.py index cf8e13810..a25098e4d 100644 --- a/qutebrowser/misc/checkpyver.py +++ b/qutebrowser/misc/checkpyver.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2014-2018 Florian Bruhin (The-Compiler) <mail@qutebrowser.org> +# Copyright 2014-2019 Florian Bruhin (The-Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # @@ -31,7 +31,7 @@ except ImportError: # pragma: no cover try: # Python2 from Tkinter import Tk # type: ignore - import tkMessageBox as messagebox # type: ignore + import tkMessageBox as messagebox # type: ignore # noqa: N813 except ImportError: # Some Python without Tk Tk = None # type: ignore diff --git a/qutebrowser/misc/cmdhistory.py b/qutebrowser/misc/cmdhistory.py index 0a3ac9fa9..ef51b60e1 100644 --- a/qutebrowser/misc/cmdhistory.py +++ b/qutebrowser/misc/cmdhistory.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2014-2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2014-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # diff --git a/qutebrowser/misc/consolewidget.py b/qutebrowser/misc/consolewidget.py index 661c7b805..138ce76c8 100644 --- a/qutebrowser/misc/consolewidget.py +++ b/qutebrowser/misc/consolewidget.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2014-2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2014-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # @@ -162,7 +162,7 @@ class ConsoleWidget(QWidget): namespace = { '__name__': '__console__', '__doc__': None, - 'qApp': QApplication.instance(), + 'q_app': QApplication.instance(), # We use parent as self here because the user "feels" the whole # console, not just the line edit. 'self': parent, diff --git a/qutebrowser/misc/crashdialog.py b/qutebrowser/misc/crashdialog.py index 06a5aabc5..eec9ec955 100644 --- a/qutebrowser/misc/crashdialog.py +++ b/qutebrowser/misc/crashdialog.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2014-2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2014-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # diff --git a/qutebrowser/misc/crashsignal.py b/qutebrowser/misc/crashsignal.py index 7890380e8..35f554c4a 100644 --- a/qutebrowser/misc/crashsignal.py +++ b/qutebrowser/misc/crashsignal.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2014-2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2014-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # diff --git a/qutebrowser/misc/earlyinit.py b/qutebrowser/misc/earlyinit.py index 690ede60f..e8040c670 100644 --- a/qutebrowser/misc/earlyinit.py +++ b/qutebrowser/misc/earlyinit.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2014-2018 Florian Bruhin (The-Compiler) <mail@qutebrowser.org> +# Copyright 2014-2019 Florian Bruhin (The-Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # @@ -173,8 +173,10 @@ def check_qt_version(): PYQT_VERSION_STR) from pkg_resources import parse_version from qutebrowser.utils import log + parsed_qversion = parse_version(qVersion()) + if (QT_VERSION < 0x050701 or PYQT_VERSION < 0x050700 or - parse_version(qVersion()) < parse_version('5.7.1')): + parsed_qversion < parse_version('5.7.1')): text = ("Fatal error: Qt >= 5.7.1 and PyQt >= 5.7 are required, " "but Qt {} / PyQt {} is installed.".format(qt_version(), PYQT_VERSION_STR)) @@ -184,6 +186,12 @@ def check_qt_version(): log.init.warning("Running qutebrowser with Qt 5.8 is untested and " "unsupported!") + if (parsed_qversion >= parse_version('5.12') and + (PYQT_VERSION < 0x050c00 or QT_VERSION < 0x050c00)): + log.init.warning("Combining PyQt {} with Qt {} is unsupported! Ensure " + "all versions are newer than 5.12 to avoid potential " + "issues.".format(PYQT_VERSION_STR, qt_version())) + def check_ssl_support(): """Check if SSL support is available.""" @@ -199,19 +207,11 @@ def _check_modules(modules): for name, text in modules.items(): try: - # https://github.com/pallets/jinja/pull/628 - # https://bitbucket.org/birkenfeld/pygments-main/issues/1314/ - # https://github.com/pallets/jinja/issues/646 # https://bitbucket.org/fdik/pypeg/commits/dd15ca462b532019c0a3be1d39b8ee2f3fa32f4e - messages = ['invalid escape sequence', - 'Flags not at the start of the expression'] # pylint: disable=bad-continuation with log.ignore_py_warnings( category=DeprecationWarning, - message=r'({})'.format('|'.join(messages)) - ), log.ignore_py_warnings( - category=PendingDeprecationWarning, - module='imp' + message=r'invalid escape sequence' ), log.ignore_py_warnings( category=ImportWarning, message=r'Not importing directory .*: missing __init__' diff --git a/qutebrowser/misc/editor.py b/qutebrowser/misc/editor.py index 3c5b7471e..c5b423708 100644 --- a/qutebrowser/misc/editor.py +++ b/qutebrowser/misc/editor.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2014-2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2014-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # diff --git a/qutebrowser/misc/guiprocess.py b/qutebrowser/misc/guiprocess.py index 52dc352a7..ae5e26f1e 100644 --- a/qutebrowser/misc/guiprocess.py +++ b/qutebrowser/misc/guiprocess.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2015-2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2015-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # diff --git a/qutebrowser/misc/httpclient.py b/qutebrowser/misc/httpclient.py index 0b162befd..3478884da 100644 --- a/qutebrowser/misc/httpclient.py +++ b/qutebrowser/misc/httpclient.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2014-2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2014-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # diff --git a/qutebrowser/misc/ipc.py b/qutebrowser/misc/ipc.py index 3c718de7b..1cf4b9ff0 100644 --- a/qutebrowser/misc/ipc.py +++ b/qutebrowser/misc/ipc.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2014-2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2014-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # @@ -65,11 +65,9 @@ def _get_socketname(basedir): data_to_hash = '-'.join(parts_to_hash).encode('utf-8') md5 = hashlib.md5(data_to_hash).hexdigest() - target_dir = standarddir.runtime() - - parts = ['ipc'] - parts.append(md5) - return os.path.join(target_dir, '-'.join(parts)) + prefix = 'i-' if utils.is_mac else 'ipc-' + filename = '{}{}'.format(prefix, md5) + return os.path.join(standarddir.runtime(), filename) class Error(Exception): @@ -209,8 +207,7 @@ class IPCServer(QObject): if not ok: if self._server.serverError() == QAbstractSocket.AddressInUseError: raise AddressInUseError(self._server) - else: - raise ListenError(self._server) + raise ListenError(self._server) if not utils.is_windows: # pragma: no cover # If we use setSocketOptions on Unix with Qt < 5.4, we get a # NameError while listening. @@ -454,19 +451,17 @@ def send_to_running_instance(socketname, command, target_arg, *, socket=None): socket.waitForBytesWritten(WRITE_TIMEOUT) if socket.error() != QLocalSocket.UnknownSocketError: raise SocketError("writing to running instance", socket) - else: - socket.disconnectFromServer() - if socket.state() != QLocalSocket.UnconnectedState: - socket.waitForDisconnected(CONNECT_TIMEOUT) - return True + socket.disconnectFromServer() + if socket.state() != QLocalSocket.UnconnectedState: + socket.waitForDisconnected(CONNECT_TIMEOUT) + return True else: if socket.error() not in [QLocalSocket.ConnectionRefusedError, QLocalSocket.ServerNotFoundError]: raise SocketError("connecting to running instance", socket) - else: - log.ipc.debug("No existing instance present (error {})".format( - socket.error())) - return False + log.ipc.debug("No existing instance present (error {})".format( + socket.error())) + return False def display_error(exc, args): diff --git a/qutebrowser/misc/keyhintwidget.py b/qutebrowser/misc/keyhintwidget.py index 9d3f4c594..7c23b230c 100644 --- a/qutebrowser/misc/keyhintwidget.py +++ b/qutebrowser/misc/keyhintwidget.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2016-2018 Ryan Roden-Corrent (rcorre) <ryan@rcorre.net> +# Copyright 2016-2019 Ryan Roden-Corrent (rcorre) <ryan@rcorre.net> # # This file is part of qutebrowser. # diff --git a/qutebrowser/misc/lineparser.py b/qutebrowser/misc/lineparser.py index e9fc67e18..b40532eb2 100644 --- a/qutebrowser/misc/lineparser.py +++ b/qutebrowser/misc/lineparser.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2014-2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2014-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # diff --git a/qutebrowser/misc/miscwidgets.py b/qutebrowser/misc/miscwidgets.py index 085b2fdd1..dd22c220f 100644 --- a/qutebrowser/misc/miscwidgets.py +++ b/qutebrowser/misc/miscwidgets.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2014-2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2014-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # diff --git a/qutebrowser/misc/msgbox.py b/qutebrowser/misc/msgbox.py index 053534158..241951b84 100644 --- a/qutebrowser/misc/msgbox.py +++ b/qutebrowser/misc/msgbox.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2015-2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2015-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # diff --git a/qutebrowser/misc/objects.py b/qutebrowser/misc/objects.py index 0bb26954c..a400e6cc0 100644 --- a/qutebrowser/misc/objects.py +++ b/qutebrowser/misc/objects.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2017-2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2017-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # diff --git a/qutebrowser/misc/pastebin.py b/qutebrowser/misc/pastebin.py index f317670ec..7fc0534c1 100644 --- a/qutebrowser/misc/pastebin.py +++ b/qutebrowser/misc/pastebin.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2014-2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2014-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # diff --git a/qutebrowser/misc/readline.py b/qutebrowser/misc/readline.py index 14c25cd6d..9c42d5b02 100644 --- a/qutebrowser/misc/readline.py +++ b/qutebrowser/misc/readline.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2014-2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2014-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # diff --git a/qutebrowser/misc/savemanager.py b/qutebrowser/misc/savemanager.py index 9985c5191..384522bf0 100644 --- a/qutebrowser/misc/savemanager.py +++ b/qutebrowser/misc/savemanager.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2015-2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2015-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # diff --git a/qutebrowser/misc/sessions.py b/qutebrowser/misc/sessions.py index 2a557ef50..3901efd4c 100644 --- a/qutebrowser/misc/sessions.py +++ b/qutebrowser/misc/sessions.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2015-2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2015-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # @@ -136,8 +136,7 @@ class SessionManager(QObject): path = os.path.join(self._base_path, name + '.yml') if check_exists and not os.path.exists(path): raise SessionNotFoundError(path) - else: - return path + return path def exists(self, name): """Check if a named session exists.""" diff --git a/qutebrowser/misc/split.py b/qutebrowser/misc/split.py index 31738fbcc..cf3fe4829 100644 --- a/qutebrowser/misc/split.py +++ b/qutebrowser/misc/split.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2014-2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2014-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # diff --git a/qutebrowser/misc/sql.py b/qutebrowser/misc/sql.py index eda778194..03895d31f 100644 --- a/qutebrowser/misc/sql.py +++ b/qutebrowser/misc/sql.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2016-2018 Ryan Roden-Corrent (rcorre) <ryan@rcorre.net> +# Copyright 2016-2019 Ryan Roden-Corrent (rcorre) <ryan@rcorre.net> # # This file is part of qutebrowser. # @@ -112,8 +112,7 @@ def raise_sqlite_error(msg, error): if error_code in environmental_errors or qtbug_70506: raise SqlEnvironmentError(msg, error) - else: - raise SqlBugError(msg, error) + raise SqlBugError(msg, error) def init(db_path): diff --git a/qutebrowser/misc/utilcmds.py b/qutebrowser/misc/utilcmds.py index c2b2e6168..1936395c3 100644 --- a/qutebrowser/misc/utilcmds.py +++ b/qutebrowser/misc/utilcmds.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2014-2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2014-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # @@ -243,9 +243,8 @@ def log_capacity(capacity: int) -> None: """ if capacity < 0: raise cmdutils.CommandError("Can't set a negative log capacity!") - else: - assert log.ram_handler is not None - log.ram_handler.change_log_capacity(capacity) + assert log.ram_handler is not None + log.ram_handler.change_log_capacity(capacity) @cmdutils.register(debug=True) @@ -311,7 +310,7 @@ def version(win_id, paste=False): """ tabbed_browser = objreg.get('tabbed-browser', scope='window', window=win_id) - tabbed_browser.load_url(QUrl('qute://version'), newtab=True) + tabbed_browser.load_url(QUrl('qute://version/'), newtab=True) if paste: pastebin_version() diff --git a/qutebrowser/qt.py b/qutebrowser/qt.py index d9f1dc58d..823170b29 100644 --- a/qutebrowser/qt.py +++ b/qutebrowser/qt.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2018-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # diff --git a/qutebrowser/qutebrowser.py b/qutebrowser/qutebrowser.py index f01bf5f18..65b150b3f 100644 --- a/qutebrowser/qutebrowser.py +++ b/qutebrowser/qutebrowser.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2014-2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2014-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # This file is part of qutebrowser. # diff --git a/qutebrowser/utils/__init__.py b/qutebrowser/utils/__init__.py index 16069f3ae..7a062ad2c 100644 --- a/qutebrowser/utils/__init__.py +++ b/qutebrowser/utils/__init__.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2014-2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2014-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # diff --git a/qutebrowser/utils/debug.py b/qutebrowser/utils/debug.py index 2868d8390..7bb2d6992 100644 --- a/qutebrowser/utils/debug.py +++ b/qutebrowser/utils/debug.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2014-2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2014-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # diff --git a/qutebrowser/utils/docutils.py b/qutebrowser/utils/docutils.py index 9ae2039ac..cf346fb81 100644 --- a/qutebrowser/utils/docutils.py +++ b/qutebrowser/utils/docutils.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2014-2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2014-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # diff --git a/qutebrowser/utils/error.py b/qutebrowser/utils/error.py index b9abcdfe1..fe8077526 100644 --- a/qutebrowser/utils/error.py +++ b/qutebrowser/utils/error.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2015-2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2015-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # diff --git a/qutebrowser/utils/javascript.py b/qutebrowser/utils/javascript.py index 6127804a5..42da9759d 100644 --- a/qutebrowser/utils/javascript.py +++ b/qutebrowser/utils/javascript.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2016-2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2016-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # diff --git a/qutebrowser/utils/jinja.py b/qutebrowser/utils/jinja.py index d2ddfaeb7..24b31a784 100644 --- a/qutebrowser/utils/jinja.py +++ b/qutebrowser/utils/jinja.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2014-2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2014-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # diff --git a/qutebrowser/utils/log.py b/qutebrowser/utils/log.py index 115c53352..4ad995b4e 100644 --- a/qutebrowser/utils/log.py +++ b/qutebrowser/utils/log.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2014-2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2014-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # diff --git a/qutebrowser/utils/message.py b/qutebrowser/utils/message.py index 6731721aa..b663cbfa4 100644 --- a/qutebrowser/utils/message.py +++ b/qutebrowser/utils/message.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2014-2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2014-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # diff --git a/qutebrowser/utils/objreg.py b/qutebrowser/utils/objreg.py index b68ca133c..a00460a34 100644 --- a/qutebrowser/utils/objreg.py +++ b/qutebrowser/utils/objreg.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2014-2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2014-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # @@ -304,6 +304,5 @@ def window_by_index(idx): """Get the Nth opened window object.""" if not window_registry: raise NoWindow() - else: - key = sorted(window_registry)[idx] - return window_registry[key] + key = sorted(window_registry)[idx] + return window_registry[key] diff --git a/qutebrowser/utils/qtutils.py b/qutebrowser/utils/qtutils.py index 5373e76aa..f3e513369 100644 --- a/qutebrowser/utils/qtutils.py +++ b/qutebrowser/utils/qtutils.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2014-2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2014-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # @@ -40,7 +40,7 @@ from PyQt5.QtCore import (qVersion, QEventLoop, QDataStream, QByteArray, try: from PyQt5.QtWebKit import qWebKitVersion except ImportError: # pragma: no cover - qWebKitVersion = None # type: ignore + qWebKitVersion = None # type: ignore # noqa: N816 MAXVALS = { @@ -131,13 +131,11 @@ def check_overflow(arg: int, ctype: str, fatal: bool = True) -> int: if arg > maxval: if fatal: raise OverflowError(arg) - else: - return maxval + return maxval elif arg < minval: if fatal: raise OverflowError(arg) - else: - return minval + return minval else: return arg diff --git a/qutebrowser/utils/standarddir.py b/qutebrowser/utils/standarddir.py index 7abb4429d..92d7ef54e 100644 --- a/qutebrowser/utils/standarddir.py +++ b/qutebrowser/utils/standarddir.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2014-2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2014-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # diff --git a/qutebrowser/utils/urlmatch.py b/qutebrowser/utils/urlmatch.py index 79e02c37f..6096b3f2b 100644 --- a/qutebrowser/utils/urlmatch.py +++ b/qutebrowser/utils/urlmatch.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2018-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # @@ -205,7 +205,7 @@ class UrlPattern: if self._host.endswith('.*'): # Special case to have a nicer error raise ParseError("TLD wildcards are not implemented yet") - elif '*' in self._host: + if '*' in self._host: # Only * or *.foo is allowed as host. raise ParseError("Invalid host wildcard") diff --git a/qutebrowser/utils/urlutils.py b/qutebrowser/utils/urlutils.py index 1acd9cd4e..59cf31348 100644 --- a/qutebrowser/utils/urlutils.py +++ b/qutebrowser/utils/urlutils.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2014-2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2014-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # diff --git a/qutebrowser/utils/usertypes.py b/qutebrowser/utils/usertypes.py index 84b7e7f9b..209eb6439 100644 --- a/qutebrowser/utils/usertypes.py +++ b/qutebrowser/utils/usertypes.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2014-2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2014-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # @@ -200,9 +200,8 @@ class NeighborList(collections.abc.Sequence): """Reset the position to the default.""" if self._default is _UNSET: raise ValueError("No default set!") - else: - self._idx = self._items.index(self._default) - return self.curitem() + self._idx = self._items.index(self._default) + return self.curitem() # The mode of a Question. diff --git a/qutebrowser/utils/utils.py b/qutebrowser/utils/utils.py index 2d517043a..0629be36e 100644 --- a/qutebrowser/utils/utils.py +++ b/qutebrowser/utils/utils.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2014-2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2014-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # @@ -30,6 +30,7 @@ import datetime import traceback import functools import contextlib +import posixpath import socket import shlex import glob @@ -165,6 +166,9 @@ def read_file(filename, binary=False): Return: The file contents as string. """ + assert not posixpath.isabs(filename), filename + assert os.path.pardir not in filename.split(posixpath.sep), filename + if not binary and filename in _resource_cache: return _resource_cache[filename] @@ -655,7 +659,15 @@ def expand_windows_drive(path): def yaml_load(f): """Wrapper over yaml.load using the C loader if possible.""" start = datetime.datetime.now() - data = yaml.load(f, Loader=YamlLoader) + + # WORKAROUND for https://github.com/yaml/pyyaml/pull/181 + with log.ignore_py_warnings( + category=DeprecationWarning, + message=r"Using or importing the ABCs from 'collections' instead " + r"of from 'collections\.abc' is deprecated, and in 3\.8 it will " + r"stop working"): + data = yaml.load(f, Loader=YamlLoader) + end = datetime.datetime.now() delta = (end - start).total_seconds() diff --git a/qutebrowser/utils/version.py b/qutebrowser/utils/version.py index a52e31ed8..dfe113edc 100644 --- a/qutebrowser/utils/version.py +++ b/qutebrowser/utils/version.py @@ -1,6 +1,6 @@ # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: -# Copyright 2014-2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org> +# Copyright 2014-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # # This file is part of qutebrowser. # @@ -42,7 +42,7 @@ from PyQt5.QtWidgets import QApplication try: from PyQt5.QtWebKit import qWebKitVersion except ImportError: # pragma: no cover - qWebKitVersion = None # type: ignore + qWebKitVersion = None # type: ignore # noqa: N816 try: from PyQt5.QtWebEngineWidgets import QWebEngineProfile @@ -324,7 +324,7 @@ def _chromium_version(): Qt 5.9: Chromium 56 (LTS) 56.0.2924.122 (2017-01-25) - 5.9.6: Security fixes up to 66.0.3359.170 (2018-05-10) + 5.9.7: Security fixes up to 69.0.3497.113 (2018-09-27) Qt 5.10: Chromium 61 61.0.3163.140 (2017-09-05) @@ -332,11 +332,14 @@ def _chromium_version(): Qt 5.11: Chromium 65 65.0.3325.151 (.1: .230) (2018-03-06) - 5.11.2: Security fixes up to 68.0.3440.75 (2018-07-24) + 5.11.3: Security fixes up to 70.0.3538.102 (2018-11-09) Qt 5.12: Chromium 69 - 69.0.3497.128 (~2018-09-17) - 5.12.0: Security fixes up to 70.0.3538.67 (2018-10-16) + (LTS) 69.0.3497.113 (2018-09-27) + 5.12.1: Security fixes up to 71.0.3578.94 (2018-12-14) + 5.12.2: Security fixes up to 72.0.3626.96 (2019-02-06) + + Qt 5.13: (in development) Chromium 71 merged, 73 in review. Also see https://www.chromium.org/developers/calendar and https://chromereleases.googleblog.com/ |