From daa0ee497b124e472e51de36c9c78d59da02d71d Mon Sep 17 00:00:00 2001 From: cajus Date: Fri, 31 Oct 2008 15:49:39 +0000 Subject: [PATCH] Replaced a couple of normalizePreg git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@12850 594d385d-05f5-0310-b6e9-bd551577e9d8 --- gosa-core/include/class_SnapShotDialog.inc | 2 +- gosa-core/include/class_config.inc | 2 +- gosa-core/include/class_gosaSupportDaemon.inc | 2 +- gosa-core/include/class_plugin.inc | 18 +++++++++--------- gosa-core/include/class_userinfo.inc | 2 +- gosa-core/include/functions.inc | 13 +++---------- .../admin/groups/class_divListGroup.inc | 2 +- .../admin/groups/class_groupGeneric.inc | 2 +- .../plugins/admin/ogroups/class_ogroup.inc | 2 +- 9 files changed, 19 insertions(+), 26 deletions(-) diff --git a/gosa-core/include/class_SnapShotDialog.inc b/gosa-core/include/class_SnapShotDialog.inc index 50b3ae29b..56d3580be 100644 --- a/gosa-core/include/class_SnapShotDialog.inc +++ b/gosa-core/include/class_SnapShotDialog.inc @@ -153,7 +153,7 @@ class SnapShotDialog extends plugin $field0 = array("string"=> $time_stamp , "attach"=> "style='vertical-align:top;width:120px;'"); $field1 = array("string"=> htmlentities (utf8_decode($display_data)), "attach"=> ""); - $field2 = array("string"=> preg_replace("/%KEY/",base64_encode($entry['dn']),$actions) , + $field2 = array("string"=> str_replace("/%KEY/",base64_encode($entry['dn']),$actions) , "attach"=> "style='border-right:0px;vertical-align:top;width:40px;text-align:right;'"); $DivListSnapShots->AddEntry(array($field0,$field1,$field2)); } diff --git a/gosa-core/include/class_config.inc b/gosa-core/include/class_config.inc index a3b09a8d8..d1afed386 100644 --- a/gosa-core/include/class_config.inc +++ b/gosa-core/include/class_config.inc @@ -740,7 +740,7 @@ class config { /* Split dn into single department pieces. */ - $elements = array_reverse(split(",",preg_replace("/".normalizePreg($base)."$/","",$val))); + $elements = array_reverse(split(",",preg_replace("/".preg_quote($base)."$/","",$val))); /* Add last ou element of current dn to our array */ $last = &$arr; diff --git a/gosa-core/include/class_gosaSupportDaemon.inc b/gosa-core/include/class_gosaSupportDaemon.inc index 0a782df02..1b55bbdc4 100644 --- a/gosa-core/include/class_gosaSupportDaemon.inc +++ b/gosa-core/include/class_gosaSupportDaemon.inc @@ -1859,7 +1859,7 @@ class gosaSupportDaemon There may be some Header lines like: -----BEGIN PGP PUBLIC KEY BLOCK----- Version: GnuPG v1.4.6 (GNU/Linux) */ - if(preg_match("/".normalizePreg("BEGIN PGP PUBLIC KEY BLOCK")."/",$key)){ + if(preg_match("/BEGIN PGP PUBLIC KEY BLOCK/",$key)){ /* Remove header */ $key = preg_replace("/^.*\n\n/sim","",$key); diff --git a/gosa-core/include/class_plugin.inc b/gosa-core/include/class_plugin.inc index de802b129..baafda872 100644 --- a/gosa-core/include/class_plugin.inc +++ b/gosa-core/include/class_plugin.inc @@ -886,7 +886,7 @@ class plugin $ldap->search("objectClass=*",array("dn")); while($attrs = $ldap->fetch()){ $src = $attrs['dn']; - $dst = preg_replace("/".normalizePreg($src_dn)."$/",$dst_dn,$attrs['dn']); + $dst = preg_replace("/".preg_quote($src_dn)."$/",$dst_dn,$attrs['dn']); $this->_copy($src,$dst); } return (TRUE); @@ -933,14 +933,14 @@ class plugin /* Updated acls set for this groups */ foreach($leaf_groups as $group){ $new_dn = $group['dn']; - $old_dn = preg_replace("/".normalizePreg($dst_dn)."$/i",$src_dn,$new_dn); + $old_dn = preg_replace("/".preg_quote($dst_dn)."$/i",$src_dn,$new_dn); $this->update_acls($old_dn,$new_dn); } /* Updated acls set for this users */ foreach($leaf_users as $user){ $new_dn = $user['dn']; - $old_dn = preg_replace("/".normalizePreg($dst_dn)."$/i",$src_dn,$new_dn); + $old_dn = preg_replace("/".preg_quote($dst_dn)."$/i",$src_dn,$new_dn); $this->update_acls($old_dn,$new_dn); } @@ -965,9 +965,9 @@ class plugin $c_mem = $ogroup['member'][$i]; - if(preg_match("/".normalizePreg($src_dn)."$/i",$c_mem)){ + if(preg_match("/".preg_quote($src_dn)."$/i",$c_mem)){ - $d_mem = preg_replace("/".normalizePreg($src_dn)."$/i",$dst_dn,$ogroup['member'][$i]); + $d_mem = preg_replace("/".preg_quote($src_dn)."$/i",$dst_dn,$ogroup['member'][$i]); if($o_ogroup == NULL){ $o_ogroup = new ogroup($this->config,$ogroup['dn']); @@ -1158,7 +1158,7 @@ class plugin } /* This one matches with the latter part. Break and don't fix this entry */ - if (preg_match('/(^|,)'.normalizePreg($key).'$/', $dn)){ + if (preg_match('/(^|,)'.preg_quote($key).'$/', $dn)){ @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, "DEBUG: Possibly relevant: $key", "Tagging"); $relevant[strlen($key)]= $ntag; continue; @@ -1256,7 +1256,7 @@ class plugin $base = $this->config->current['BASE']; $snap_base = $config->get_cfg_value("snapshotBase"); $base_of_object = preg_replace ('/^[^,]+,/i', '', $this->dn); - $new_base = preg_replace("/".normalizePreg($base)."$/","",$base_of_object).$snap_base; + $new_base = preg_replace("/".preg_quote($base)."$/","",$base_of_object).$snap_base; /* Create object */ #$data = preg_replace('/^dn:.*\n/', '', $ldap->gen_ldif($this->dn,"(!(objectClass=gosaDepartment))")); @@ -1374,7 +1374,7 @@ class plugin $base = $this->config->current['BASE']; $snap_base = $this->config->get_cfg_value("snapshotBase"); $base_of_object = preg_replace ('/^[^,]+,/i', '', $dn); - $new_base = preg_replace("/".normalizePreg($base)."$/","",$base_of_object).$snap_base; + $new_base = preg_replace("/".preg_quote($base)."$/","",$base_of_object).$snap_base; $tmp = array(); /* Fetch all objects with gosaSnapshotDN=$dn */ @@ -1431,7 +1431,7 @@ class plugin /* Prepare bases */ $base = $this->config->current['BASE']; $snap_base = $this->config->get_cfg_value("snapshotBase"); - $new_base = preg_replace("/".normalizePreg($base)."$/","",$base_of_object).$snap_base; + $new_base = preg_replace("/".preg_quote($base)."$/","",$base_of_object).$snap_base; /* Fetch all objects and check if they do not exist anymore */ $ui = get_userinfo(); diff --git a/gosa-core/include/class_userinfo.inc b/gosa-core/include/class_userinfo.inc index f6de37d19..cf36489cf 100644 --- a/gosa-core/include/class_userinfo.inc +++ b/gosa-core/include/class_userinfo.inc @@ -498,7 +498,7 @@ class userinfo /* Skip self acls? */ if($skip_self_acls && isset($data['0']) && strpos($data['0'], "s")) continue; - if(preg_match("/^".normalizePreg($mod)."/",$cat)){ + if(preg_match("/^".preg_quote($mod)."/",$cat)){ $found =TRUE; break; } diff --git a/gosa-core/include/functions.inc b/gosa-core/include/functions.inc index 18d72a7a6..ea81f1ce6 100644 --- a/gosa-core/include/functions.inc +++ b/gosa-core/include/functions.inc @@ -870,7 +870,7 @@ function get_sub_list($filter, $category,$sub_deps, $base= "", $attributes= arra * departments like this "ou=servers,ou=blafasel,..." * Here we filter out those blafasel departments. */ - if(preg_match("/".normalizePreg($sub_dep)."/",$attrs['dn'])){ + if(preg_match("/".preg_quote($sub_dep)."/",$attrs['dn'])){ $departments[$attrs['dn']] = $attrs['dn']; break; } @@ -1124,7 +1124,7 @@ function convert_department_dn($dn, $base = NULL) /* Build a sub-directory style list of the tree level specified in $dn */ - $dn = preg_replace("/".normalizePreg($base)."$/i","",$dn); + $dn = preg_replace("/".preg_quote($base)."$/i","",$dn); if(empty($dn)) return("/"); @@ -1201,7 +1201,7 @@ function get_ou($name) $ou = @LDAP::convert("$ou"); } - if(preg_match("/".normalizePreg($config->current['BASE'])."$/",$ou)){ + if(preg_match("/".preg_quote($config->current['BASE'])."$/",$ou)){ return($ou); }else{ return("$ou,"); @@ -2066,13 +2066,6 @@ function saveFilter($a_filter, $values) } -/* Escape all preg_* relevant characters */ -function normalizePreg($input) -{ - return (addcslashes($input, '[]()|/.*+-')); -} - - /* Escape all LDAP filter relevant characters */ function normalizeLdap($input) { diff --git a/gosa-core/plugins/admin/groups/class_divListGroup.inc b/gosa-core/plugins/admin/groups/class_divListGroup.inc index d47541f31..342d490bc 100644 --- a/gosa-core/plugins/admin/groups/class_divListGroup.inc +++ b/gosa-core/plugins/admin/groups/class_divListGroup.inc @@ -213,7 +213,7 @@ class divListGroup extends MultiSelectWindow $ldap->search("(objectClass=gotoMenuEntry)",array("dn")); $configured_apps = array(); while($entry = $ldap->fetch()){ - $dn = preg_replace("/^.*(cn=[^,]+,".normalizePreg(get_groups_ou()).")/","\\1",$entry['dn']); + $dn = preg_replace("/^.*(cn=[^,]+,".preg_quote(get_groups_ou()).")/","\\1",$entry['dn']); $configured_apps[$dn] = $dn; } diff --git a/gosa-core/plugins/admin/groups/class_groupGeneric.inc b/gosa-core/plugins/admin/groups/class_groupGeneric.inc index acf6dc50d..de4d23510 100644 --- a/gosa-core/plugins/admin/groups/class_groupGeneric.inc +++ b/gosa-core/plugins/admin/groups/class_groupGeneric.inc @@ -194,7 +194,7 @@ class group extends plugin } else { /* Get object base */ - $this->base =preg_replace ("/^[^,]+,".normalizePreg(get_groups_ou())."/","",$this->dn); + $this->base =preg_replace ("/^[^,]+,".preg_quote(get_groups_ou())."/","",$this->dn); } $this->orig_base = $this->base; diff --git a/gosa-core/plugins/admin/ogroups/class_ogroup.inc b/gosa-core/plugins/admin/ogroups/class_ogroup.inc index 761b4d9fa..0a3146bf3 100644 --- a/gosa-core/plugins/admin/ogroups/class_ogroup.inc +++ b/gosa-core/plugins/admin/ogroups/class_ogroup.inc @@ -124,7 +124,7 @@ class ogroup extends plugin if ($this->dn == "new"){ $this->base = session::get('CurrentMainBase'); } else { - $this->base= preg_replace("/^[^,]+,".normalizePreg(get_ou("ogroupRDN"))."/","",$this->dn); + $this->base= preg_replace("/^[^,]+,".preg_quote(get_ou("ogroupRDN"))."/","",$this->dn); /* Is this account a trustAccount? */ if ($this->is_account && isset($this->attrs['trustModel'])){ -- 2.30.2