From: hickert Date: Tue, 21 Sep 2010 09:57:23 +0000 (+0000) Subject: Updated class ldap X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=45b7069479efcf7ffd074bd6bfb37c791f91f705;p=gosa.git Updated class ldap -Added emthod which allows to replace all non readable characters by the readable ones. git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@19784 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/gosa-core/include/class_baseSelector.inc b/gosa-core/include/class_baseSelector.inc index 8a30178d7..84d76e3d6 100644 --- a/gosa-core/include/class_baseSelector.inc +++ b/gosa-core/include/class_baseSelector.inc @@ -170,7 +170,7 @@ class baseSelector { onmouseout=\" mouseIsStillOver=false; rtimer=Element.hide.delay(0.25,'bs_".$this->pid."')\" - value=\"".preg_replace('/"/','"',$this->pathMapping[$this->base])."\">"; + value=\"".htmlentities(LDAP::makeReadable($this->pathMapping[$this->base]),ENT_COMPAT,'utf-8')."\">"; // Autocompleter diff --git a/gosa-core/include/class_ldap.inc b/gosa-core/include/class_ldap.inc index ce237a6ac..0d22eb19e 100644 --- a/gosa-core/include/class_ldap.inc +++ b/gosa-core/include/class_ldap.inc @@ -33,6 +33,8 @@ class LDAP public static $characterMap = NULL; public static $characterMapRegFrom = NULL; public static $characterMapRegTo = NULL; + public static $readableMapRegFrom = NULL; + public static $readableMapRegTo = NULL; var $hascon =false; var $reconnect=false; @@ -117,6 +119,11 @@ class LDAP LDAP::$characterMapRegFrom = array("/\001CO/", "/\001OB/", "/\001CB/", "/\001SL/", "/\001DQ/"); LDAP::$characterMapRegTo = array("\,", "(", ")", "/", '\"'); + // Set a default mapping to make readable strings out of dns. + LDAP::$readableMapRegFrom = array("/\001CO/", "/\001OB/", "/\001CB/", "/\001SL/", "/\001DQ/", + "/\\\\,/", "/\\\\2C/", "/\(/", "/\)/", "/\//", "/\\\\22/", '/\\\\"/'); + LDAP::$readableMapRegTo = array(",", "(", ")", "/", '"',",", ",", "(", ")", "/", '"', '"'); + if(LDAP::$characterMap === NULL){ LDAP::$characterMap = detectLdapSpecialCharHandling(); @@ -124,10 +131,19 @@ class LDAP if(LDAP::$characterMap !== NULL){ LDAP::$characterMapRegFrom = array(); LDAP::$characterMapRegTo = array(); + LDAP::$readableMapRegFrom = array(); + LDAP::$readableMapRegTo = array(); foreach(LDAP::$characterMap as $from => $to){ - $from = LDAP::convert($from); - LDAP::$characterMapRegFrom[] = "/{$from}/"; + + // Append entry character conversion + LDAP::$characterMapRegFrom[] = "/".preg_quote(LDAP::convert($from),'/')."/"; LDAP::$characterMapRegTo[] = addslashes($to); + + // Append entry make readable array + LDAP::$readableMapRegFrom[] = "/".preg_quote(stripslashes($to),'/')."/"; + LDAP::$readableMapRegTo[] = stripslashes($from); + LDAP::$readableMapRegFrom[] = "/".preg_quote(LDAP::convert($to),'/')."/"; + LDAP::$readableMapRegTo[] = stripslashes($from); } }else{ // To avoid querying a hundred times without any success, stop here. @@ -140,6 +156,16 @@ class LDAP } + static function makeReadable($dn) + { + if(LDAP::$characterMap === NULL) LDAP::updateSpecialCharHandling(); + + print_a(array(LDAP::$readableMapRegFrom,LDAP::$readableMapRegTo,$dn, preg_replace(LDAP::$readableMapRegFrom,LDAP::$readableMapRegTo,$dn))); + + return (preg_replace(LDAP::$readableMapRegFrom,LDAP::$readableMapRegTo,$dn)); + } + + /* \brief Function to fix all problematic characters inside a DN by replacing \001XX * codes to their original values. See "convert" for more information. * The ',' characters are always expanded to \, (not \2C), since all tested LDAP