Don't treat things like "31c3" as IP address.

Fixes #388.
This commit is contained in:
Florian Bruhin 2014-12-22 18:32:58 +01:00
parent b01041e455
commit 4363db90c0
2 changed files with 4 additions and 4 deletions

View File

@ -156,6 +156,7 @@ class IsUrlTests(unittest.TestCase):
'23.42', '23.42',
'1337', '1337',
'deadbeef', 'deadbeef',
'31c3',
) )
def test_urls(self, configmock): def test_urls(self, configmock):

View File

@ -26,10 +26,10 @@ import posixpath
import urllib.parse import urllib.parse
from PyQt5.QtCore import QUrl from PyQt5.QtCore import QUrl
from PyQt5.QtNetwork import QHostInfo from PyQt5.QtNetwork import QHostInfo, QHostAddress
from qutebrowser.config import config, configexc from qutebrowser.config import config, configexc
from qutebrowser.utils import log, qtutils, message, utils from qutebrowser.utils import log, qtutils, message
from qutebrowser.commands import cmdexc from qutebrowser.commands import cmdexc
@ -91,8 +91,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.
if ((not utils.raises(ValueError, int, urlstr, 0)) or if not QHostAddress(urlstr).isNull():
(not utils.raises(ValueError, float, urlstr))):
return False return False
if not url.isValid(): if not url.isValid():