Permalink
Browse files

Allow underscores, dots and dashes in SSH username local parts.

  • Loading branch information...
1 parent cbea178 commit b5e966c10771ccc02a084d3b0e5ebeb760214508 @tv42 committed Dec 11, 2007
Showing with 28 additions and 1 deletion.
  1. +1 −1 gitosis/ssh.py
  2. +27 −0 gitosis/test/test_init.py
View
@@ -3,7 +3,7 @@
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)
View
@@ -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 '

0 comments on commit b5e966c

Please sign in to comment.