urlmatch: Improve matching error for TLD wildcards

This commit is contained in:
Florian Bruhin 2018-02-15 14:31:08 +01:00
parent fa329c698e
commit 3d6cbcf396
2 changed files with 6 additions and 2 deletions

View File

@ -119,7 +119,11 @@ class UrlPattern:
host_parts = host_parts[1:]
self._match_subdomains = True
self._host = '.'.join(host_parts)
if '*' in self._host:
if self._host.endswith('.*'):
# Special case to have a nicer error
raise ParseError("TLD wildcards are not implemented yet")
elif '*' in self._host:
# Only * or *.foo is allowed as host.
raise ParseError("Invalid host wildcard")

View File

@ -52,7 +52,7 @@ from qutebrowser.utils import urlmatch
("http://*foo/bar", "Invalid host wildcard"),
("http://foo.*.bar/baz", "Invalid host wildcard"),
("http://fo.*.ba:123/baz", "Invalid host wildcard"),
("http://foo.*/bar", "Invalid host wildcard"),
("http://foo.*/bar", "TLD wildcards are not implemented yet"),
# Chromium: PARSE_ERROR_INVALID_PORT
("http://foo:/", "Empty port"),