[Pkg-owncloud-commits] [owncloud] 117/145: LDAP: improve compilation of filters

David Prévot taffit at moszumanska.debian.org
Wed Feb 26 16:27:47 UTC 2014


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository owncloud.

commit 75c7fd2886053068cb8d7b87530c56047ef1a19b
Author: Arthur Schiwon <blizzz at owncloud.com>
Date:   Wed Feb 19 13:13:01 2014 +0100

    LDAP: improve compilation of filters
---
 apps/user_ldap/lib/access.php | 11 +++++++++++
 apps/user_ldap/user_ldap.php  |  3 +++
 2 files changed, 14 insertions(+)

diff --git a/apps/user_ldap/lib/access.php b/apps/user_ldap/lib/access.php
index b619f62..45a8799 100644
--- a/apps/user_ldap/lib/access.php
+++ b/apps/user_ldap/lib/access.php
@@ -896,6 +896,17 @@ class Access extends LDAPUtility {
 	}
 
 	/**
+	* @brief escapes (user provided) parts for LDAP filter
+	* @param String $input, the provided value
+	* @returns the escaped string
+	*/
+	public function escapeFilterPart($input) {
+		$search  = array('*', '\\', '(', ')');
+		$replace = array('\\*', '\\\\', '\\(', '\\)');
+		return str_replace($search, $replace, $input);
+	}
+
+	/**
 	 * @brief combines the input filters with AND
 	 * @param $filters array, the filters to connect
 	 * @returns the combined filter
diff --git a/apps/user_ldap/user_ldap.php b/apps/user_ldap/user_ldap.php
index 619a992..c993a1d 100644
--- a/apps/user_ldap/user_ldap.php
+++ b/apps/user_ldap/user_ldap.php
@@ -164,6 +164,8 @@ class USER_LDAP extends BackendUtility implements \OCP\UserInterface {
 	 * Check if the password is correct without logging in the user
 	 */
 	public function checkPassword($uid, $password) {
+		$uid = $this->access->escapeFilterPart($uid);
+
 		//find out dn of the user name
 		$filter = \OCP\Util::mb_str_replace(
 			'%uid', $uid, $this->access->connection->ldapLoginFilter, 'UTF-8');
@@ -204,6 +206,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);
 		$cachekey = 'getUsers-'.$search.'-'.$limit.'-'.$offset;
 
 		//check if users are cached, if so return

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud.git



More information about the Pkg-owncloud-commits mailing list