Skip to content

Commit 3e32210

Browse files
CarlSchwanbackportbot[bot]
authored andcommitted
fix: filter special characters from password field
Signed-off-by: Carl Schwan <carl@carlschwan.eu>
1 parent c0f62c7 commit 3e32210

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
@@ -234,7 +234,9 @@ public function setConfiguration(array $config, ?array &$applied = null): void {
234234

235235
$setMethod = 'setValue';
236236
switch ($key) {
237+
case 'ldapAgentName':
237238
case 'ldapAgentPassword':
239+
$val = \filter_var($val, FILTER_UNSAFE_RAW, FILTER_FLAG_STRIP_LOW);
238240
$setMethod = 'setRawValue';
239241
break;
240242
case 'homeFolderNamingRule':

apps/user_ldap/tests/ConfigurationTest.php

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

5555
$password = ' such a passw0rd ';
5656

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

7174
'set agent password' => ['ldapAgentPassword', $password, $password],
75+
'set agent name strips CRLF' => ['ldapAgentName', $dnWithCrlf, $expectedDn],
7276

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

0 commit comments

Comments
 (0)