urlmatch: Use None as default for host
This commit is contained in:
parent
5419d1caa1
commit
2d43a1d2e7
@ -53,7 +53,7 @@ class UrlPattern:
|
|||||||
Note that with Chromium, '*'/None only matches http/https and
|
Note that with Chromium, '*'/None only matches http/https and
|
||||||
not file/ftp. We deviate from that as per-URL settings aren't
|
not file/ftp. We deviate from that as per-URL settings aren't
|
||||||
security relevant.
|
security relevant.
|
||||||
_host: The host to match to, or None for any host. (FIXME true?)
|
_host: The host to match to, or None for any host.
|
||||||
_path: The path to match to, or None for any path. (FIXME true?)
|
_path: The path to match to, or None for any path. (FIXME true?)
|
||||||
_port: The port to match to as integer, or None for any port.
|
_port: The port to match to as integer, or None for any port.
|
||||||
"""
|
"""
|
||||||
@ -139,6 +139,10 @@ class UrlPattern:
|
|||||||
host_parts = host_parts[1:]
|
host_parts = host_parts[1:]
|
||||||
self._match_subdomains = True
|
self._match_subdomains = True
|
||||||
|
|
||||||
|
if not host_parts:
|
||||||
|
self._host = None
|
||||||
|
return
|
||||||
|
|
||||||
self._host = '.'.join(host_parts)
|
self._host = '.'.join(host_parts)
|
||||||
|
|
||||||
if self._host.endswith('.*'):
|
if self._host.endswith('.*'):
|
||||||
@ -184,6 +188,9 @@ class UrlPattern:
|
|||||||
# FIXME what about multiple dots?
|
# FIXME what about multiple dots?
|
||||||
host = host.rstrip('.')
|
host = host.rstrip('.')
|
||||||
|
|
||||||
|
if self._host is None:
|
||||||
|
return True
|
||||||
|
|
||||||
# If the hosts are exactly equal, we have a match.
|
# If the hosts are exactly equal, we have a match.
|
||||||
if host == self._host:
|
if host == self._host:
|
||||||
return True
|
return True
|
||||||
|
@ -103,7 +103,7 @@ class TestMatchAllPagesForGivenScheme:
|
|||||||
|
|
||||||
def test_attrs(self, up):
|
def test_attrs(self, up):
|
||||||
assert up._scheme == 'http'
|
assert up._scheme == 'http'
|
||||||
assert up._host == '' # FIXME '' or None?
|
assert up._host is None
|
||||||
assert up._match_subdomains
|
assert up._match_subdomains
|
||||||
assert not up._match_all
|
assert not up._match_all
|
||||||
assert up._path == '/*'
|
assert up._path == '/*'
|
||||||
@ -127,7 +127,7 @@ class TestMatchAllDomains:
|
|||||||
|
|
||||||
def test_attrs(self, up):
|
def test_attrs(self, up):
|
||||||
assert up._scheme == 'https'
|
assert up._scheme == 'https'
|
||||||
assert up._host == '' # FIXME '' or None?
|
assert up._host is None
|
||||||
assert up._match_subdomains
|
assert up._match_subdomains
|
||||||
assert not up._match_all
|
assert not up._match_all
|
||||||
assert up._path == '/foo*'
|
assert up._path == '/foo*'
|
||||||
@ -175,7 +175,7 @@ class TestMatchGlobEscaping:
|
|||||||
|
|
||||||
def test_attrs(self, up):
|
def test_attrs(self, up):
|
||||||
assert up._scheme == 'file'
|
assert up._scheme == 'file'
|
||||||
assert up._host == '' # FIXME '' or None?
|
assert up._host is None
|
||||||
assert not up._match_subdomains
|
assert not up._match_subdomains
|
||||||
assert not up._match_all
|
assert not up._match_all
|
||||||
assert up._path == r'/foo-bar\*baz'
|
assert up._path == r'/foo-bar\*baz'
|
||||||
|
Loading…
Reference in New Issue
Block a user