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:
@ -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
|
||||
|
@ -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"))
|
||||
|
Reference in New Issue
Block a user