Merge pull request #12704 from owncloud/fix-12647-2
preserve an asterisk at the start when escaping a search term
This commit is contained in:
commit
de3ead5ab9
|
@ -1085,12 +1085,18 @@ class Access extends LDAPUtility implements user\IUserTools {
|
||||||
/**
|
/**
|
||||||
* escapes (user provided) parts for LDAP filter
|
* escapes (user provided) parts for LDAP filter
|
||||||
* @param string $input, the provided value
|
* @param string $input, the provided value
|
||||||
|
* @param bool $allowAsterisk wether in * at the beginning should be preserved
|
||||||
* @return string the escaped string
|
* @return string the escaped string
|
||||||
*/
|
*/
|
||||||
public function escapeFilterPart($input) {
|
public function escapeFilterPart($input, $allowAsterisk = false) {
|
||||||
|
$asterisk = '';
|
||||||
|
if($allowAsterisk && strlen($input) > 0 && $input[0] === '*') {
|
||||||
|
$asterisk = '*';
|
||||||
|
$input = mb_substr($input, 1, null, 'UTF-8');
|
||||||
|
}
|
||||||
$search = array('*', '\\', '(', ')');
|
$search = array('*', '\\', '(', ')');
|
||||||
$replace = array('\\*', '\\\\', '\\(', '\\)');
|
$replace = array('\\*', '\\\\', '\\(', '\\)');
|
||||||
return str_replace($search, $replace, $input);
|
return $asterisk . str_replace($search, $replace, $input);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -93,7 +93,7 @@ class USER_LDAP extends BackendUtility implements \OCP\UserInterface {
|
||||||
* Get a list of all users.
|
* Get a list of all users.
|
||||||
*/
|
*/
|
||||||
public function getUsers($search = '', $limit = 10, $offset = 0) {
|
public function getUsers($search = '', $limit = 10, $offset = 0) {
|
||||||
$search = $this->access->escapeFilterPart($search);
|
$search = $this->access->escapeFilterPart($search, true);
|
||||||
$cachekey = 'getUsers-'.$search.'-'.$limit.'-'.$offset;
|
$cachekey = 'getUsers-'.$search.'-'.$limit.'-'.$offset;
|
||||||
|
|
||||||
//check if users are cached, if so return
|
//check if users are cached, if so return
|
||||||
|
|
Loading…
Reference in New Issue