From b5e966c10771ccc02a084d3b0e5ebeb760214508 Mon Sep 17 00:00:00 2001 From: Tommi Virtanen Date: Tue, 11 Dec 2007 22:50:04 +0200 Subject: [PATCH] Allow underscores, dots and dashes in SSH username local parts. --- gitosis/ssh.py | 2 +- gitosis/test/test_init.py | 27 +++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/gitosis/ssh.py b/gitosis/ssh.py index 9e8d258..3fe846f 100644 --- a/gitosis/ssh.py +++ b/gitosis/ssh.py @@ -3,7 +3,7 @@ import logging log = logging.getLogger('gitosis.ssh') -_ACCEPTABLE_USER_RE = re.compile(r'^[a-z][a-z0-9]*(@[a-z][a-z0-9.-]*)?$') +_ACCEPTABLE_USER_RE = re.compile(r'^[a-z][a-z0-9_.-]*(@[a-z][a-z0-9.-]*)?$') def isSafeUsername(user): match = _ACCEPTABLE_USER_RE.match(user) diff --git a/gitosis/test/test_init.py b/gitosis/test/test_init.py index 559a0c8..e7f0150 100644 --- a/gitosis/test/test_init.py +++ b/gitosis/test/test_init.py @@ -36,6 +36,33 @@ def test_ssh_extract_user_domain_dashes(): +'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA= fakeuser@ridiculously-long.example.com') eq(got, 'fakeuser@ridiculously-long.example.com') +def test_ssh_extract_user_underscore(): + got = init.ssh_extract_user( + 'ssh-somealgo ' + +'0123456789ABCDEFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' + +'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' + +'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' + +'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA= fake_user@example.com') + eq(got, 'fake_user@example.com') + +def test_ssh_extract_user_dot(): + got = init.ssh_extract_user( + 'ssh-somealgo ' + +'0123456789ABCDEFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' + +'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' + +'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' + +'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA= fake.u.ser@example.com') + eq(got, 'fake.u.ser@example.com') + +def test_ssh_extract_user_dash(): + got = init.ssh_extract_user( + 'ssh-somealgo ' + +'0123456789ABCDEFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' + +'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' + +'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' + +'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA= fake.u-ser@example.com') + eq(got, 'fake.u-ser@example.com') + def test_ssh_extract_user_no_at(): got = init.ssh_extract_user( 'ssh-somealgo '