1
0
mirror of https://github.com/samba-team/samba.git synced 2025-07-29 15:42:04 +03:00

Make valid_netbios_name() check a bit stricter.

This commit is contained in:
Jelmer Vernooij
2009-04-05 23:17:43 +02:00
parent 15f6d5e805
commit b1db78c595
2 changed files with 16 additions and 2 deletions

View File

@ -233,10 +233,12 @@ def check_all_substituted(text):
def valid_netbios_name(name):
"""Check whether a name is valid as a NetBIOS name. """
# FIXME: There are probably more constraints here.
# crh has a paragraph on this in his book (1.4.1.1)
# See crh's book (1.4.1.1)
if len(name) > 15:
return False
for x in name:
if not x.isalnum() and not x in " !#$%&'()-.@^_{}~":
return False
return True
version = glue.version

View File

@ -96,3 +96,15 @@ class RpcInterfaceTestCase(unittest.TestCase):
def get_credentials(self):
return cmdline_credentials
class ValidNetbiosNameTests(unittest.TestCase):
def test_valid(self):
self.assertTrue(valid_netbios_name("FOO"))
def test_too_long(self):
self.assertFalse(valid_netbios_name("FOO"*10))
def test_invalid_characters(self):
self.assertFalse(valid_netbios_name("()BLA"))