mirror of https://github.com/borgbackup/borg.git
use same host regex for ssh and scp style, refactor/clean up
although bug #6526 did not show with ssh style URLs, we should not have different regexes for the host part for ssh and scp style. thus i extracted the host_re from both and also cleaned up a bit.
This commit is contained in:
parent
f24979bc09
commit
b2eaa2fba4
|
@ -341,26 +341,31 @@ class Location:
|
||||||
(?P<archive>[^/]+) # archive name must not contain "/"
|
(?P<archive>[^/]+) # archive name must not contain "/"
|
||||||
)?$""" # must match until the end
|
)?$""" # must match until the end
|
||||||
|
|
||||||
|
# host NAME, or host IP ADDRESS (v4 or v6, v6 must be in square brackets)
|
||||||
|
host_re = r"""
|
||||||
|
(?P<host>(
|
||||||
|
(?!\[)[^:/]+(?<!\]) # hostname or v4 addr, not containing : or / (does not match v6 addr: no brackets!)
|
||||||
|
|
|
||||||
|
\[[0-9a-fA-F:.]+\]) # ipv6 address in brackets
|
||||||
|
)
|
||||||
|
"""
|
||||||
|
|
||||||
# regexes for misc. kinds of supported location specifiers:
|
# regexes for misc. kinds of supported location specifiers:
|
||||||
ssh_re = re.compile(r"""
|
ssh_re = re.compile(r"""
|
||||||
(?P<proto>ssh):// # ssh://
|
(?P<proto>ssh):// # ssh://
|
||||||
""" + optional_user_re + r""" # user@ (optional)
|
""" + optional_user_re + host_re + r""" # user@ (optional), host name or address
|
||||||
(?P<host>([^:/]+|\[[0-9a-fA-F:.]+\]))(?::(?P<port>\d+))? # host or host:port or [ipv6] or [ipv6]:port
|
(?::(?P<port>\d+))? # :port (optional)
|
||||||
""" + abs_path_re + optional_archive_re, re.VERBOSE) # path or path::archive
|
""" + abs_path_re + optional_archive_re, re.VERBOSE) # path or path::archive
|
||||||
|
|
||||||
file_re = re.compile(r"""
|
file_re = re.compile(r"""
|
||||||
(?P<proto>file):// # file://
|
(?P<proto>file):// # file://
|
||||||
""" + file_path_re + optional_archive_re, re.VERBOSE) # servername/path, path or path::archive
|
""" + file_path_re + optional_archive_re, re.VERBOSE) # servername/path, path or path::archive
|
||||||
|
|
||||||
# note: scp_re is also use for local paths
|
# note: scp_re is also used for local paths
|
||||||
scp_re = re.compile(r"""
|
scp_re = re.compile(r"""
|
||||||
(
|
(
|
||||||
""" + optional_user_re + r""" # user@ (optional)
|
""" + optional_user_re + host_re + r""" # user@ (optional), host name or address
|
||||||
(?P<host>( # host can be ipv6 addr in brackets or something else
|
: # : (required!)
|
||||||
(?!\[)[^:/]+(?<!\]) # host: hostname, not containing : or /, also not ipv6: not in brackets
|
|
||||||
|
|
|
||||||
\[[0-9a-fA-F:.]+\]) # host: ipv6 addr in brackets
|
|
||||||
):
|
|
||||||
)? # user@host: part is optional
|
)? # user@host: part is optional
|
||||||
""" + scp_path_re + optional_archive_re, re.VERBOSE) # path with optional archive
|
""" + scp_path_re + optional_archive_re, re.VERBOSE) # path with optional archive
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue