urlutils: Remove some more dead code.
This commit is contained in:
parent
92abf4bdf8
commit
e10da78a1a
@ -94,6 +94,8 @@ 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)
|
||||||
|
assert url.isValid()
|
||||||
|
|
||||||
if not utils.raises(ValueError, ipaddress.ip_address, urlstr):
|
if not utils.raises(ValueError, ipaddress.ip_address, urlstr):
|
||||||
# Valid IPv4/IPv6 address
|
# Valid IPv4/IPv6 address
|
||||||
return True
|
return True
|
||||||
@ -104,9 +106,7 @@ def _is_url_naive(urlstr):
|
|||||||
if not QHostAddress(urlstr).isNull():
|
if not QHostAddress(urlstr).isNull():
|
||||||
return False
|
return False
|
||||||
|
|
||||||
if not url.isValid():
|
if '.' in url.host():
|
||||||
return False
|
|
||||||
elif '.' in url.host():
|
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
@ -122,9 +122,7 @@ def _is_url_dns(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)
|
||||||
if not url.isValid():
|
assert url.isValid()
|
||||||
log.url.debug("Invalid URL -> False")
|
|
||||||
return False
|
|
||||||
|
|
||||||
if (utils.raises(ValueError, ipaddress.ip_address, urlstr) and
|
if (utils.raises(ValueError, ipaddress.ip_address, urlstr) and
|
||||||
not QHostAddress(urlstr).isNull()):
|
not QHostAddress(urlstr).isNull()):
|
||||||
@ -246,16 +244,13 @@ def is_url(urlstr):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
if not qurl_userinput.isValid():
|
if not qurl_userinput.isValid():
|
||||||
|
# This will also catch URLs containing spaces.
|
||||||
return False
|
return False
|
||||||
|
|
||||||
if _has_explicit_scheme(qurl):
|
if _has_explicit_scheme(qurl):
|
||||||
# URLs with explicit schemes are always URLs
|
# URLs with explicit schemes are always URLs
|
||||||
log.url.debug("Contains explicit scheme")
|
log.url.debug("Contains explicit scheme")
|
||||||
url = True
|
url = True
|
||||||
elif ' ' in urlstr:
|
|
||||||
# A URL will never contain a space
|
|
||||||
log.url.debug("Contains space -> no URL")
|
|
||||||
url = False
|
|
||||||
elif qurl_userinput.host() in ('localhost', '127.0.0.1', '::1'):
|
elif qurl_userinput.host() in ('localhost', '127.0.0.1', '::1'):
|
||||||
log.url.debug("Is localhost.")
|
log.url.debug("Is localhost.")
|
||||||
url = True
|
url = True
|
||||||
@ -274,7 +269,7 @@ def is_url(urlstr):
|
|||||||
else:
|
else:
|
||||||
raise ValueError("Invalid autosearch value")
|
raise ValueError("Invalid autosearch value")
|
||||||
log.url.debug("url = {}".format(url))
|
log.url.debug("url = {}".format(url))
|
||||||
return url and qurl_userinput.isValid()
|
return url
|
||||||
|
|
||||||
|
|
||||||
def qurl_from_user_input(urlstr):
|
def qurl_from_user_input(urlstr):
|
||||||
|
Loading…
Reference in New Issue
Block a user