Can't edit groups/roles with spaces which exists in LDAP
Description
I can't edit "Roles membership" for user when I add/remove a role with spaces which exists in my LDAP. I receive an error "The field 'Name' contains invalid characters. ' ' is not allowed:"
Distribution Name and Version
Debian 11.3 amd64
FusionDirectory Version
fusiondirectory 1.3-4
PHP version used
php 7.4.28-1+deb11u1
Origin of php packages
php 7.4.28-1+deb11u1
Steps to Reproduce
- Create a Role/Group in LDAP (use openldap binaries or phpldapadmin or ...) with spaces (if you have one, please skip this)
- Try to change group members: add/remove and press apply button. Or try to change group/roles in user profile: add/remove groups and press apply button
Expected behavior:
There no errors
Actual behavior:
Receive an error - "The field 'Name' contains invalid characters. ' ' is not allowed:"
Reproduces how often: Every time
Additional Information
"strict naming policy" adds only "." character. So, we need to include spaces to this. As a workaround, below a patches
--- plugins/admin/groups/class_ogroup.inc 2022-05-03 10:14:54.074638909 +0000
+++ plugins/admin/groups/class_ogroup.inc 2022-05-03 14:53:56.306877987 +0000
@@ -214,7 +214,7 @@
new StringAttribute(
_('Name'), _('Name of this group'),
'cn', TRUE,
- '', '', (strict_uid_mode() ? '/^[a-z0-9_-]+$/' : '/^[a-z0-9_.-]+$/i')
+ '', '', (strict_uid_mode() ? '/^[a-z0-9_-]+$/' : '/^[-a-z0-9_.\s]+$/i')
),
new TextAreaAttribute(
_('Description'), _('Short description of this group'),
--- plugins/admin/groups/class_roleGeneric.inc 2022-05-03 10:12:53.815556610 +0000
+++ plugins/admin/groups/class_roleGeneric.inc 2022-05-03 14:53:43.778973578 +0000
@@ -85,7 +85,7 @@
new StringAttribute(
_('Name'), _('Name of this group'),
'cn', TRUE,
- '', '', (strict_uid_mode() ? '/^[a-z0-9_-]+$/i' : '/^[a-z0-9_.-]+$/i')
+ '', '', (strict_uid_mode() ? '/^[a-z0-9_-]+$/i' : '/^[-a-z0-9_.\s]+$/i')
),
new StringAttribute (
_('Description'), _('Description of the role'),