From e3c92a9bae7987a3bd7d1555a5e59bdfcd19c8d5 Mon Sep 17 00:00:00 2001 From: Kevin Velghe Date: Wed, 5 Oct 2016 12:03:52 +0200 Subject: [PATCH 1/2] Set netrc location with QUTE_NETRC --- qutebrowser/browser/webkit/network/networkmanager.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qutebrowser/browser/webkit/network/networkmanager.py b/qutebrowser/browser/webkit/network/networkmanager.py index 04ce58975..151c06829 100644 --- a/qutebrowser/browser/webkit/network/networkmanager.py +++ b/qutebrowser/browser/webkit/network/networkmanager.py @@ -330,7 +330,7 @@ class NetworkManager(QNetworkAccessManager): # altogether. reply.netrc_used = True try: - net = netrc.netrc() + net = netrc.netrc(os.environ.get('QUTE_NETRC')) authenticators = net.authenticators(reply.url().host()) if authenticators is not None: (user, _account, password) = authenticators From 087342894ef6063932b2b624f8d4ab72ef684168 Mon Sep 17 00:00:00 2001 From: Kevin Velghe Date: Sun, 9 Oct 2016 00:11:52 +0200 Subject: [PATCH 2/2] Add setting for location of netrc file There is no reason I guess to do this with an environment variable. On top of that, introducing a settings also documents the netrc feature itself (Closes #1975?). --- README.asciidoc | 2 +- doc/help/settings.asciidoc | 7 +++++++ qutebrowser/browser/webkit/network/networkmanager.py | 2 +- qutebrowser/config/configdata.py | 4 ++++ 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/README.asciidoc b/README.asciidoc index 8574cb119..bae15c67b 100644 --- a/README.asciidoc +++ b/README.asciidoc @@ -160,9 +160,9 @@ Contributors, sorted by the number of commits in descending order: * Corentin Julé * meles5 * Philipp Hansch +* Kevin Velghe * Daniel Karbach * Panagiotis Ktistakis -* Kevin Velghe * Artur Shaik * Nathan Isom * Thorsten Wißmann diff --git a/doc/help/settings.asciidoc b/doc/help/settings.asciidoc index 8f416d3a4..8b1803fb2 100644 --- a/doc/help/settings.asciidoc +++ b/doc/help/settings.asciidoc @@ -69,6 +69,7 @@ |<>|Whether to validate SSL handshakes. |<>|Whether to try to pre-fetch DNS entries to speed up browsing. |<>|Set custom headers for qutebrowser HTTP requests. +|<>|Set location of netrc-file for HTTP authentication. |============== .Quick reference for section ``completion'' @@ -808,6 +809,12 @@ Set custom headers for qutebrowser HTTP requests. Default: empty +[[network-netrc-file]] +=== netrc-file +Set location of netrc-file for HTTP authentication. + +Default: empty + == completion Options related to completion and command history. diff --git a/qutebrowser/browser/webkit/network/networkmanager.py b/qutebrowser/browser/webkit/network/networkmanager.py index 151c06829..d28bd6be4 100644 --- a/qutebrowser/browser/webkit/network/networkmanager.py +++ b/qutebrowser/browser/webkit/network/networkmanager.py @@ -330,7 +330,7 @@ class NetworkManager(QNetworkAccessManager): # altogether. reply.netrc_used = True try: - net = netrc.netrc(os.environ.get('QUTE_NETRC')) + net = netrc.netrc(config.get('network', 'netrc-file')) authenticators = net.authenticators(reply.url().host()) if authenticators is not None: (user, _account, password) = authenticators diff --git a/qutebrowser/config/configdata.py b/qutebrowser/config/configdata.py index 3b62f3183..e503c3e45 100644 --- a/qutebrowser/config/configdata.py +++ b/qutebrowser/config/configdata.py @@ -438,6 +438,10 @@ def data(readonly=False): SettingValue(typ.HeaderDict(none_ok=True), ''), "Set custom headers for qutebrowser HTTP requests."), + ('netrc-file', + SettingValue(typ.File(none_ok=True), ''), + "Set location of netrc-file for HTTP authentication."), + readonly=readonly )),