Skip to content

Commit 9f22685

Browse files
committed
fix: filter special characters from password field
Signed-off-by: Carl Schwan <carl@carlschwan.eu>
1 parent 0ab8881 commit 9f22685

2 files changed

Lines changed: 6 additions & 0 deletions

File tree

apps/user_ldap/lib/Configuration.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,9 @@ public function setConfiguration(array $config, ?array &$applied = null): void {
235235

236236
$setMethod = 'setValue';
237237
switch ($key) {
238+
case 'ldapAgentName':
238239
case 'ldapAgentPassword':
240+
$val = \filter_var($val, FILTER_UNSAFE_RAW, FILTER_FLAG_STRIP_LOW);
239241
$setMethod = 'setRawValue';
240242
break;
241243
case 'homeFolderNamingRule':

apps/user_ldap/tests/ConfigurationTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ public static function configurationDataProvider(): array {
5555

5656
$password = ' such a passw0rd ';
5757

58+
$dnWithCrlf = "cn=admin\r\nset foo bar\r\n,dc=example,dc=org";
59+
$expectedDn = 'cn=adminset foo bar,dc=example,dc=org';
60+
5861
return [
5962
'set general base' => ['ldapBase', $inputWithDN, $expectWithDN],
6063
'set user base' => ['ldapBaseUsers', $inputWithDN, $expectWithDN],
@@ -70,6 +73,7 @@ public static function configurationDataProvider(): array {
7073
'set login filter attributes' => ['ldapLoginFilterAttributes', $inputNames, $expectedNames],
7174

7275
'set agent password' => ['ldapAgentPassword', $password, $password],
76+
'set agent name strips CRLF' => ['ldapAgentName', $dnWithCrlf, $expectedDn],
7377

7478
'set home folder, variant 1' => ['homeFolderNamingRule', $inputHomeFolder[0], $expectedHomeFolder[0]],
7579
'set home folder, variant 2' => ['homeFolderNamingRule', $inputHomeFolder[1], $expectedHomeFolder[1]],

0 commit comments

Comments
 (0)