Code

Replaced a couple of normalizePreg
authorcajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 31 Oct 2008 15:49:39 +0000 (15:49 +0000)
committercajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 31 Oct 2008 15:49:39 +0000 (15:49 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@12850 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-core/include/class_SnapShotDialog.inc
gosa-core/include/class_config.inc
gosa-core/include/class_gosaSupportDaemon.inc
gosa-core/include/class_plugin.inc
gosa-core/include/class_userinfo.inc
gosa-core/include/functions.inc
gosa-core/plugins/admin/groups/class_divListGroup.inc
gosa-core/plugins/admin/groups/class_groupGeneric.inc
gosa-core/plugins/admin/ogroups/class_ogroup.inc

index 50b3ae29bd56c3acf0daa8421f6e0ed03e43f3bd..56d3580bef4af48a4426401dc5ab8de75a1d4660 100644 (file)
@@ -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));
                        }               
index a3b09a8d8036ba617ec5502d46bf75ddba5e0553..d1afed386eaee1ae4319104569f692d151482f95 100644 (file)
@@ -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;
index 0a782df027e2d30274561b831fd137096b59d619..1b55bbdc499e9140c042751df78f92d196b623b5 100644 (file)
@@ -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);
index de802b12923ddae7d9294e8e239d5cbc81bc7adc..baafda8721f6a373c6e5ff0db84bfe0f035ef931 100644 (file)
@@ -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();
index f6de37d19a33ab88a6433a59b338c4306ca78cbe..cf36489cfbd0bbee642a1eed64826405f9500a14 100644 (file)
@@ -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;
             }
index 18d72a7a66b66c0e0c00d8e637aa39a196ef7dad..ea81f1ce68c1bbb6a79c6b4c48953f95fff6038f 100644 (file)
@@ -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)
 {
index d47541f31cc47d72626c07c73ba2b35b1c64d971..342d490bcfa33986a6e8ee066d88bb5ec7efb943 100644 (file)
@@ -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;
     }
 
index acf6dc50dc6e012142b4a01ee7fe56e2cbf5471b..de4d235107092178724aa6554ac9cac7ad7f1691 100644 (file)
@@ -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;
 
index 761b4d9fabaa9d6aa895040c73067610a21ced55..0a3146bf3e8e6b45f32e9c276ed3e8181881f2aa 100644 (file)
@@ -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'])){