21 lines
549 B
PHP
21 lines
549 B
PHP
|
<?php
|
||
|
namespace nur\ldap\syntaxes;
|
||
|
|
||
|
class PrintableSyntax extends StringSyntax {
|
||
|
const DISALLOWED = '/[^a-zA-Z0-9"()+,-.\/:? -]+/';
|
||
|
|
||
|
/** enlever les caractères interdit de la chaine */
|
||
|
function filter(?string $value): ?string {
|
||
|
if ($value === null) return null;
|
||
|
return preg_replace(self::DISALLOWED, "", $value);
|
||
|
}
|
||
|
|
||
|
function php2ldap($value): ?string {
|
||
|
$value = parent::php2ldap($value);
|
||
|
if (preg_match(self::DISALLOWED, $value)) {
|
||
|
throw new SyntaxException("invalid string: $value");
|
||
|
}
|
||
|
return $value;
|
||
|
}
|
||
|
}
|