Skip to content

Commit 0cd6220

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

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

259259
$setMethod = 'setValue';
260260
switch ($key) {
261+
case 'ldapAgentName':
261262
case 'ldapAgentPassword':
263+
$val = \filter_var($val, FILTER_UNSAFE_RAW, FILTER_FLAG_STRIP_LOW);
262264
$setMethod = 'setRawValue';
263265
break;
264266
case 'homeFolderNamingRule':

apps/user_ldap/tests/ConfigurationTest.php

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

7272
$password = ' such a passw0rd ';
7373

74+
$dnWithCrlf = "cn=admin\r\nset foo bar\r\n,dc=example,dc=org";
75+
$expectedDn = 'cn=adminset foo bar,dc=example,dc=org';
76+
7477
return [
7578
'set general base' => ['ldapBase', $inputWithDN, $expectWithDN],
7679
'set user base' => ['ldapBaseUsers', $inputWithDN, $expectWithDN],
@@ -86,6 +89,7 @@ public function configurationDataProvider() {
8689
'set login filter attributes' => ['ldapLoginFilterAttributes', $inputNames, $expectedNames],
8790

8891
'set agent password' => ['ldapAgentPassword', $password, $password],
92+
'set agent name strips CRLF' => ['ldapAgentName', $dnWithCrlf, $expectedDn],
8993

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

0 commit comments

Comments
 (0)