Don't treat floats as IPs either.
This commit is contained in:
parent
683a306c51
commit
010efcee93
@ -68,6 +68,18 @@ def _get_search_url(txt):
|
|||||||
return url
|
return url
|
||||||
|
|
||||||
|
|
||||||
|
def _is_numeric(s):
|
||||||
|
"""Check if the given string is some valid number."""
|
||||||
|
try:
|
||||||
|
int(s, 0)
|
||||||
|
except ValueError:
|
||||||
|
try:
|
||||||
|
float(s)
|
||||||
|
except ValueError:
|
||||||
|
return False
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
def _is_url_naive(urlstr):
|
def _is_url_naive(urlstr):
|
||||||
"""Naive check if given URL is really a URL.
|
"""Naive check if given URL is really a URL.
|
||||||
|
|
||||||
@ -89,11 +101,7 @@ def _is_url_naive(urlstr):
|
|||||||
# Qt treats things like "23.42" or "1337" or "0xDEAD" as valid URLs
|
# Qt treats things like "23.42" or "1337" or "0xDEAD" as valid URLs
|
||||||
# which we don't want to. Note we already filtered *real* valid IPs
|
# which we don't want to. Note we already filtered *real* valid IPs
|
||||||
# above.
|
# above.
|
||||||
try:
|
if _is_numeric(urlstr):
|
||||||
int(urlstr, 0)
|
|
||||||
except ValueError:
|
|
||||||
pass
|
|
||||||
else:
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
if not url.isValid():
|
if not url.isValid():
|
||||||
|
Loading…
Reference in New Issue
Block a user