urlutils: Use utils.raises in _is_url_naive.

This commit is contained in:
Florian Bruhin 2015-05-20 13:20:01 +02:00
parent 1f048a38f8
commit c0b41d8c62

View File

@ -29,7 +29,7 @@ from PyQt5.QtCore import QUrl
from PyQt5.QtNetwork import QHostInfo, QHostAddress from PyQt5.QtNetwork import QHostInfo, QHostAddress
from qutebrowser.config import config, configexc from qutebrowser.config import config, configexc
from qutebrowser.utils import log, qtutils, message from qutebrowser.utils import log, qtutils, message, utils
from qutebrowser.commands import cmdexc from qutebrowser.commands import cmdexc
@ -94,11 +94,7 @@ def _is_url_naive(urlstr):
True if the URL really is a URL, False otherwise. True if the URL really is a URL, False otherwise.
""" """
url = qurl_from_user_input(urlstr) url = qurl_from_user_input(urlstr)
try: if not utils.raises(ValueError, ipaddress.ip_address, urlstr):
ipaddress.ip_address(urlstr)
except ValueError:
pass
else:
# Valid IPv4/IPv6 address # Valid IPv4/IPv6 address
return True return True