From a17b8bec9049851773e9a3419dde72edfe6889ee Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Tue, 23 Aug 2016 09:02:39 +0200 Subject: [PATCH] Don't treat "Hello." as URL with auto-search=naive --- qutebrowser/utils/urlutils.py | 3 ++- tests/unit/utils/test_urlutils.py | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/qutebrowser/utils/urlutils.py b/qutebrowser/utils/urlutils.py index 7e1b8ea9e..0ba14c479 100644 --- a/qutebrowser/utils/urlutils.py +++ b/qutebrowser/utils/urlutils.py @@ -127,7 +127,8 @@ def _is_url_naive(urlstr): if not QHostAddress(urlstr).isNull(): return False - return '.' in url.host() + host = url.host() + return '.' in host and not host.endswith('.') def _is_url_dns(urlstr): diff --git a/tests/unit/utils/test_urlutils.py b/tests/unit/utils/test_urlutils.py index 8ae217b1c..d827625cb 100644 --- a/tests/unit/utils/test_urlutils.py +++ b/tests/unit/utils/test_urlutils.py @@ -336,6 +336,7 @@ def test_get_search_url_invalid(urlutils_config_stub, url): (False, True, False, '23.42'), # no DNS because bogus-IP (False, True, False, '1337'), # no DNS because bogus-IP (False, True, True, 'deadbeef'), + (False, True, True, 'hello.'), # no DNS because bogus-IP pytest.mark.xfail(qtutils.version_check('5.6.1'), reason='Qt behavior changed')(