Commit c76c861e authored by Matt Traudt's avatar Matt Traudt
Browse files

Allow most symbols in nicks

GH: closes #139
parent b7e77c25
......@@ -11,6 +11,8 @@ _ALPHANUM = 'abcdefghijklmnopqrstuvwxyz'
_ALPHANUM += _ALPHANUM.upper()
_ALPHANUM += '0123456789'
_SYMBOLS_NO_QUOTES = '!@#$%^&*()-_=+\\|[]{}:;/?.,<>'
_HEX = '0123456789ABCDEF'
log = logging.getLogger(__name__)
......@@ -417,7 +419,7 @@ def _validate_fingerprint(section, key):
def _validate_nickname(section, key):
alphabet = _ALPHANUM
alphabet = _ALPHANUM + _SYMBOLS_NO_QUOTES
min_len = 1
max_len = 32
return _validate_string(section, key, min_len=min_len, max_len=max_len,
......
......@@ -206,3 +206,25 @@ def test_validate_url():
d = {'': val}
valid, reason = con._validate_url(d, '')
assert not valid, '{} should not have been a valid URL'.format(val)
def test_nickname():
max_len = 32
goods = [
'aaa', 'AAA', 'aAa', 'A1a', '1aA', 'aA1',
'!!!', '!@#',
'a!A', '!Aa', 'Aa!',
'a' * max_len,
]
bads = [
'', 'a' * (max_len + 1),
'"', '\'',
]
for nick in goods:
d = {'n': nick}
valid, reason = con._validate_nickname(d, 'n')
assert valid, reason
for nick in bads:
d = {'n': nick}
valid, reason = con._validate_nickname(d, 'n')
assert not valid, reason
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment