fix: preserve leading dots in group folders

This commit is contained in:
Ludwig Lehnert
2026-07-02 21:28:12 +00:00
parent 618f9ebd06
commit ba5fc6cfcb
2 changed files with 12 additions and 1 deletions

View File

@@ -277,7 +277,7 @@ def parse_groups_from_ldap_output(output: str) -> List[Dict[str, object]]:
def sanitize_group_folder_name(raw_name: str) -> str:
candidate = GROUP_FOLDER_INVALID_RE.sub("_", raw_name.strip())
candidate = candidate.strip().strip(".")
candidate = candidate.strip().rstrip(".")
candidate = re.sub(r"\s+", " ", candidate)
if not candidate:
return ""

View File

@@ -24,6 +24,17 @@ def principal(dn, sam, classes, members=()):
}
class GroupFolderNameTests(unittest.TestCase):
def test_sanitizer_preserves_leading_dot(self):
self.assertEqual(rs.sanitize_group_folder_name(".Finance"), ".Finance")
self.assertEqual(rs.sanitize_group_folder_name("..Finance"), "..Finance")
def test_sanitizer_still_rejects_dot_only_names(self):
self.assertEqual(rs.sanitize_group_folder_name("."), "")
self.assertEqual(rs.sanitize_group_folder_name(".."), "")
self.assertEqual(rs.sanitize_group_folder_name("Finance."), "Finance")
class LdapParsingTests(unittest.TestCase):
def test_parser_keeps_repeated_members_and_unfolds_lines(self):
display_name = base64.b64encode(b"Data Folder").decode("ascii")