]> source.dussan.org Git - nextcloud-server.git/commitdiff
preserve an asterisk at the start when escaping a search term
authorArthur Schiwon <blizzz@owncloud.com>
Mon, 8 Dec 2014 16:12:13 +0000 (17:12 +0100)
committerArthur Schiwon <blizzz@owncloud.com>
Mon, 8 Dec 2014 16:19:57 +0000 (17:19 +0100)
apps/user_ldap/lib/access.php
apps/user_ldap/user_ldap.php

index 5a4d324fba22b9ad644d73cdf56b798f454c7999..1adb25690d0f674cf91dd133bd2d132f17f42970 100644 (file)
@@ -1087,10 +1087,15 @@ class Access extends LDAPUtility implements user\IUserTools {
        * @param string $input, the provided value
        * @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('*', '\\', '(', ')');
                $replace = array('\\*', '\\\\', '\\(', '\\)');
-               return str_replace($search, $replace, $input);
+               return $asterisk . str_replace($search, $replace, $input);
        }
 
        /**
index 38c32cbda4adca3c1140c5c9d5ed4100ab73d5fa..52278082312bf41b3d2230e40d8548dd084b717a 100644 (file)
@@ -93,7 +93,7 @@ class USER_LDAP extends BackendUtility implements \OCP\UserInterface {
         * Get a list of all users.
         */
        public function getUsers($search = '', $limit = 10, $offset = 0) {
-               $search = $this->access->escapeFilterPart($search);
+               $search = $this->access->escapeFilterPart($search, true);
                $cachekey = 'getUsers-'.$search.'-'.$limit.'-'.$offset;
 
                //check if users are cached, if so return