diff --git a/apps/user_ldap/lib/Configuration.php b/apps/user_ldap/lib/Configuration.php index 22b244e4a7ec1..b2e22f1b007ca 100644 --- a/apps/user_ldap/lib/Configuration.php +++ b/apps/user_ldap/lib/Configuration.php @@ -235,7 +235,9 @@ public function setConfiguration(array $config, ?array &$applied = null): void { $setMethod = 'setValue'; switch ($key) { + case 'ldapAgentName': case 'ldapAgentPassword': + $val = \filter_var($val, FILTER_UNSAFE_RAW, FILTER_FLAG_STRIP_LOW); $setMethod = 'setRawValue'; break; case 'homeFolderNamingRule': diff --git a/apps/user_ldap/tests/ConfigurationTest.php b/apps/user_ldap/tests/ConfigurationTest.php index 5d297aae32b98..4e0270882eb09 100644 --- a/apps/user_ldap/tests/ConfigurationTest.php +++ b/apps/user_ldap/tests/ConfigurationTest.php @@ -55,6 +55,9 @@ public static function configurationDataProvider(): array { $password = ' such a passw0rd '; + $dnWithCrlf = "cn=admin\r\nset foo bar\r\n,dc=example,dc=org"; + $expectedDn = 'cn=adminset foo bar,dc=example,dc=org'; + return [ 'set general base' => ['ldapBase', $inputWithDN, $expectWithDN], 'set user base' => ['ldapBaseUsers', $inputWithDN, $expectWithDN], @@ -70,6 +73,7 @@ public static function configurationDataProvider(): array { 'set login filter attributes' => ['ldapLoginFilterAttributes', $inputNames, $expectedNames], 'set agent password' => ['ldapAgentPassword', $password, $password], + 'set agent name strips CRLF' => ['ldapAgentName', $dnWithCrlf, $expectedDn], 'set home folder, variant 1' => ['homeFolderNamingRule', $inputHomeFolder[0], $expectedHomeFolder[0]], 'set home folder, variant 2' => ['homeFolderNamingRule', $inputHomeFolder[1], $expectedHomeFolder[1]],