Also deduplicate SSL errors with ssl-strict false.
Otherwise, on OS X we got the same SSL error logged twice as on_ssl_errors is called twice. This means the tests only marked one as expected, and it failed because of the other one.
This commit is contained in:
parent
00f5b3cf74
commit
b13f2aa6f0
@ -196,44 +196,44 @@ class NetworkManager(QNetworkAccessManager):
|
|||||||
ssl_strict = config.get('network', 'ssl-strict')
|
ssl_strict = config.get('network', 'ssl-strict')
|
||||||
log.webview.debug("SSL errors {!r}, strict {}".format(
|
log.webview.debug("SSL errors {!r}, strict {}".format(
|
||||||
errors, ssl_strict))
|
errors, ssl_strict))
|
||||||
|
|
||||||
|
try:
|
||||||
|
host_tpl = urlutils.host_tuple(reply.url())
|
||||||
|
except ValueError:
|
||||||
|
host_tpl = None
|
||||||
|
is_accepted = False
|
||||||
|
is_rejected = False
|
||||||
|
else:
|
||||||
|
is_accepted = set(errors).issubset(
|
||||||
|
self._accepted_ssl_errors[host_tpl])
|
||||||
|
is_rejected = set(errors).issubset(
|
||||||
|
self._rejected_ssl_errors[host_tpl])
|
||||||
|
|
||||||
|
if ssl_strict or is_rejected:
|
||||||
|
return
|
||||||
|
elif is_accepted:
|
||||||
|
reply.ignoreSslErrors()
|
||||||
|
return
|
||||||
|
|
||||||
if ssl_strict == 'ask':
|
if ssl_strict == 'ask':
|
||||||
try:
|
err_string = '\n'.join('- ' + err.errorString() for err in errors)
|
||||||
host_tpl = urlutils.host_tuple(reply.url())
|
answer = self._ask('SSL errors - continue?\n{}'.format(err_string),
|
||||||
except ValueError:
|
mode=usertypes.PromptMode.yesno, owner=reply)
|
||||||
host_tpl = None
|
if answer:
|
||||||
is_accepted = False
|
|
||||||
is_rejected = False
|
|
||||||
else:
|
|
||||||
is_accepted = set(errors).issubset(
|
|
||||||
self._accepted_ssl_errors[host_tpl])
|
|
||||||
is_rejected = set(errors).issubset(
|
|
||||||
self._rejected_ssl_errors[host_tpl])
|
|
||||||
if is_accepted:
|
|
||||||
reply.ignoreSslErrors()
|
reply.ignoreSslErrors()
|
||||||
elif is_rejected:
|
err_dict = self._accepted_ssl_errors
|
||||||
pass
|
|
||||||
else:
|
else:
|
||||||
err_string = '\n'.join('- ' + err.errorString() for err in
|
err_dict = self._rejected_ssl_errors
|
||||||
errors)
|
if host_tpl is not None:
|
||||||
answer = self._ask('SSL errors - continue?\n{}'.format(
|
err_dict[host_tpl] += errors
|
||||||
err_string), mode=usertypes.PromptMode.yesno,
|
|
||||||
owner=reply)
|
|
||||||
if answer:
|
|
||||||
reply.ignoreSslErrors()
|
|
||||||
d = self._accepted_ssl_errors
|
|
||||||
else:
|
|
||||||
d = self._rejected_ssl_errors
|
|
||||||
if host_tpl is not None:
|
|
||||||
d[host_tpl] += errors
|
|
||||||
elif ssl_strict:
|
|
||||||
pass
|
|
||||||
else:
|
else:
|
||||||
for err in errors:
|
for err in errors:
|
||||||
# FIXME we might want to use warn here (non-fatal error)
|
# FIXME we might want to use warn here (non-fatal error)
|
||||||
# https://github.com/The-Compiler/qutebrowser/issues/114
|
# https://github.com/The-Compiler/qutebrowser/issues/114
|
||||||
message.error(self._win_id,
|
message.error(self._win_id, 'SSL error: {}'.format(
|
||||||
'SSL error: {}'.format(err.errorString()))
|
err.errorString()))
|
||||||
reply.ignoreSslErrors()
|
reply.ignoreSslErrors()
|
||||||
|
self._accepted_ssl_errors[host_tpl] += errors
|
||||||
|
|
||||||
@pyqtSlot(QUrl)
|
@pyqtSlot(QUrl)
|
||||||
def clear_rejected_ssl_errors(self, url):
|
def clear_rejected_ssl_errors(self, url):
|
||||||
|
Loading…
Reference in New Issue
Block a user