From f2f481d991ed73fd54abf79929841ad51a53962d Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Sun, 24 Jun 2018 21:38:37 +0200 Subject: [PATCH] Support URL patterns for permissions and ssl_strict See #3636 --- doc/changelog.asciidoc | 7 +++++++ doc/help/settings.asciidoc | 14 ++++++++++++++ qutebrowser/browser/shared.py | 4 ++-- qutebrowser/config/configdata.yml | 7 +++++++ 4 files changed, 30 insertions(+), 2 deletions(-) diff --git a/doc/changelog.asciidoc b/doc/changelog.asciidoc index dd0b03092..efd451976 100644 --- a/doc/changelog.asciidoc +++ b/doc/changelog.asciidoc @@ -40,11 +40,14 @@ Added * Support for requesting persistent storage via `navigator.webkitPersistentStorage.requestQuota` with a new `content.persistent_storage` setting (requires Qt 5.11). + This setting also supports URL patterns. * Support for registering custom protocol handlers via `navigator.registerProtocolHandler` with a new `content.register_protocol_handler` setting (requires Qt 5.11). + This setting also supports URL patterns. * Support for WebRTC screen sharing with a new `content.desktop_capture` setting (requires Qt 5.10). + This setting also supports URL patterns. * New `content.autoplay` setting to enable/disable automatic video playback (requires Qt 5.10). * New `content.webrtc_public_interfaces_only` setting to only expose public @@ -60,6 +63,10 @@ Changed - content.headers.custom - content.headers.accept_language - content.headers.user_agent + - content.ssl_strict + - content.geolocation + - content.notifications + - content.media_capture - The Windows/macOS releases now bundle Qt 5.11.1 which is based on Chromium 65.0.3325.151 with security fixes up to Chromium 67.0.3396.87. - New short flags for commandline arguments: `-B` and `-T` for `--basedir` and diff --git a/doc/help/settings.asciidoc b/doc/help/settings.asciidoc index 13818716d..75e684ffc 100644 --- a/doc/help/settings.asciidoc +++ b/doc/help/settings.asciidoc @@ -1570,6 +1570,8 @@ Default: +pass:[iso-8859-1]+ Allow websites to share screen content. On Qt < 5.10, a dialog box is always displayed, even if this is set to "true". +This setting supports URL patterns. + Type: <> Valid values: @@ -1609,6 +1611,8 @@ This setting is only available with the QtWebKit backend. === content.geolocation Allow websites to request geolocations. +This setting supports URL patterns. + Type: <> Valid values: @@ -1853,6 +1857,8 @@ Default: +pass:[true]+ === content.media_capture Allow websites to record audio/video. +This setting supports URL patterns. + Type: <> Valid values: @@ -1878,6 +1884,8 @@ Default: empty === content.notifications Allow websites to show notifications. +This setting supports URL patterns. + Type: <> Valid values: @@ -1905,6 +1913,8 @@ This setting is only available with the QtWebKit backend. === content.persistent_storage Allow websites to request persistent storage quota via `navigator.webkitPersistentStorage.requestQuota`. +This setting supports URL patterns. + Type: <> Valid values: @@ -1977,6 +1987,8 @@ This setting is only available with the QtWebKit backend. === content.register_protocol_handler Allow websites to register protocol handlers via `navigator.registerProtocolHandler`. +This setting supports URL patterns. + Type: <> Valid values: @@ -1995,6 +2007,8 @@ On QtWebKit, this setting is unavailable. === content.ssl_strict Validate SSL handshakes. +This setting supports URL patterns. + Type: <> Valid values: diff --git a/qutebrowser/browser/shared.py b/qutebrowser/browser/shared.py index 92dfdeb03..01ccab13b 100644 --- a/qutebrowser/browser/shared.py +++ b/qutebrowser/browser/shared.py @@ -156,7 +156,7 @@ def ignore_certificate_errors(url, errors, abort_on): Return: True if the error should be ignored, False otherwise. """ - ssl_strict = config.val.content.ssl_strict + ssl_strict = config.instance.get('content.ssl_strict', url=url) log.webview.debug("Certificate errors {!r}, strict {}".format( errors, ssl_strict)) @@ -213,7 +213,7 @@ def feature_permission(url, option, msg, yes_action, no_action, abort_on, The Question object if a question was asked (and blocking=False), None otherwise. """ - config_val = config.instance.get(option) + config_val = config.instance.get(option, url=url) if config_val == 'ask': if url.isValid(): urlstr = url.toString(QUrl.RemovePassword | QUrl.FullyEncoded) diff --git a/qutebrowser/config/configdata.yml b/qutebrowser/config/configdata.yml index cf8e60771..2698c34b1 100644 --- a/qutebrowser/config/configdata.yml +++ b/qutebrowser/config/configdata.yml @@ -321,6 +321,7 @@ content.windowed_fullscreen: content.desktop_capture: type: BoolAsk default: ask + supports_pattern: true desc: >- Allow websites to share screen content. @@ -350,6 +351,7 @@ content.frame_flattening: content.geolocation: default: ask type: BoolAsk + supports_pattern: true desc: Allow websites to request geolocations. content.headers.accept_language: @@ -604,6 +606,7 @@ content.local_storage: content.media_capture: default: ask type: BoolAsk + supports_pattern: true backend: QtWebEngine desc: Allow websites to record audio/video. @@ -620,6 +623,7 @@ content.netrc_file: content.notifications: default: ask type: BoolAsk + supports_pattern: true backend: QtWebKit desc: Allow websites to show notifications. @@ -636,6 +640,7 @@ content.pdfjs: content.persistent_storage: default: ask type: BoolAsk + supports_pattern: true backend: QtWebKit: false QtWebEngine: Qt 5.11 @@ -682,6 +687,7 @@ content.proxy_dns_requests: content.register_protocol_handler: default: ask type: BoolAsk + supports_pattern: true backend: QtWebKit: false QtWebEngine: Qt 5.11 @@ -691,6 +697,7 @@ content.register_protocol_handler: content.ssl_strict: default: ask type: BoolAsk + supports_pattern: true desc: Validate SSL handshakes. content.user_stylesheets: