From bc140271bcfaa3091f5c16a3fcb1edb24908696a Mon Sep 17 00:00:00 2001 From: Carsten Wolff Date: Wed, 12 May 2004 09:55:30 +0000 Subject: [PATCH] added escape-function for ldap-queries - will be used by contacts soon --- phpgwapi/inc/class.common.inc.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/phpgwapi/inc/class.common.inc.php b/phpgwapi/inc/class.common.inc.php index 9cb97da247..31e772b296 100644 --- a/phpgwapi/inc/class.common.inc.php +++ b/phpgwapi/inc/class.common.inc.php @@ -225,6 +225,19 @@ return $retValue; } + /*! + @function ldap_addslashes + @abstract escapes a string for use in searchfilters meant for ldap_search. + Escaped Characters are: '*', '(', ')', ' ', '\', NUL + It's actually a PHP-Bug, that we have to escape space. + For all other Characters, refer to RFC2254. + @param $string string to be escaped + */ + function ldap_addslashes($string='') + { + return str_replace(array('\\','*','(',')','\0',' '),array('\\\\','\*','\(','\)','\\0','\20'),$string); + } + // connect to the ldap server and return a handle /*! @function ldapConnect