From 45657141a030844ea1f28f7515543bec56ad3519 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Fri, 8 Aug 2014 13:04:52 +0200 Subject: [PATCH] utils.url: Always treat URLs with explicit scheme as URL. --- qutebrowser/utils/url.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/qutebrowser/utils/url.py b/qutebrowser/utils/url.py index 0698d8b7e..ee19c5c4f 100644 --- a/qutebrowser/utils/url.py +++ b/qutebrowser/utils/url.py @@ -78,14 +78,11 @@ def _is_url_naive(urlstr): Return: True if the URL really is a URL, False otherwise. """ - schemes = ('http', 'https') url = QUrl.fromUserInput(urlstr) # We don't use url here because fromUserInput appends http:// # automatically. if not url.isValid(): return False - elif QUrl(urlstr).scheme() in schemes: - return True elif '.' in url.host(): return True elif url.host() == 'localhost': @@ -171,16 +168,21 @@ def is_url(urlstr): logger.debug("Checking if '{}' is a URL (autosearch={}).".format( urlstr, autosearch)) + qurl = QUrl(urlstr) if not autosearch: # no autosearch, so everything is a URL. return True - if ' ' in urlstr: + if qurl.isValid() and qurl.scheme(): + # URLs with explicit schemes are always URLs + logger.debug("Contains explicit scheme") + return True + elif ' ' in urlstr: # A URL will never contain a space logger.debug("Contains space -> no URL") return False - elif is_special_url(QUrl(urlstr)): + elif is_special_url(qurl): # Special URLs are always URLs, even with autosearch=False logger.debug("Is an special URL.") return True