Don't treat single words as URL
This commit is contained in:
parent
8e122abd35
commit
7fb0a7745b
@ -137,6 +137,7 @@ class IsUrlNaiveTests(TestCase):
|
||||
'foo bar',
|
||||
'localhost test',
|
||||
'another . test',
|
||||
'foo',
|
||||
]
|
||||
|
||||
def test_urls(self):
|
||||
|
@ -73,11 +73,14 @@ def _is_url_naive(url):
|
||||
True if the url really is an URL, False otherwise.
|
||||
"""
|
||||
protocols = ['http', 'https']
|
||||
u = qurl(url)
|
||||
urlstr = urlstring(url)
|
||||
if isinstance(url, QUrl):
|
||||
u = url
|
||||
else:
|
||||
u = QUrl.fromUserInput(url)
|
||||
if u.scheme() in protocols:
|
||||
# We don't use u here because fromUserInput appends http:// automatically.
|
||||
if any(urlstr.startswith(proto) for proto in protocols):
|
||||
return True
|
||||
elif '.' in u.host():
|
||||
return True
|
||||
|
Loading…
Reference in New Issue
Block a user