Skip to content

Commit

Permalink
BF: generally check for no inappropriate characters in the ssh RI beg…
Browse files Browse the repository at this point in the history
…inning
  • Loading branch information
yarikoptic committed May 16, 2019
1 parent f636b04 commit 6831aa7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
8 changes: 6 additions & 2 deletions datalad/support/network.py
Expand Up @@ -342,8 +342,12 @@ def _guess_ri_cls(ri):

if not fields['scheme'] and not fields['hostname']:
parts = _split_colon(ri)
if fields['path'] and '@' in fields['path'] \
or (len(parts) > 1 and not set(parts[0]).intersection(set('/\\#'))):
# if no illegal for hostname/username characters in the first part and
if not set(parts[0]).intersection(set('/\\#')) and (
fields['path'] and
'@' in fields['path'] or
len(parts) > 1
):
# user@host:path/sp1
# or host_name: (hence parts check)
# TODO: we need a regex to catch those really, parts check is not suff
Expand Down
1 change: 1 addition & 0 deletions datalad/support/tests/test_network.py
Expand Up @@ -282,6 +282,7 @@ def test_url_samples():
it is e.g. a file).
"""
_check_ri('e.com/p/sp:f', PathRI, localpath='e.com/p/sp:f', path='e.com/p/sp:f')
_check_ri('user@someho.st/mydir', PathRI, localpath='user@someho.st/mydir', path='user@someho.st/mydir')

# SSHRIs have .port, but it is empty
eq_(SSHRI(hostname='example.com').port, '')
Expand Down

0 comments on commit 6831aa7

Please sign in to comment.