Code

Heimdal stuff not needed. It's too insecure to read m-keys by php.
[gosa.git] / include / sieve / class_sieveElement_Vacation.inc
index e1306b2231ba11c7be5ad29d27bcddabdfcd70e4..43c7546377215877efee4065959c00d61d3a8980 100644 (file)
@@ -27,10 +27,11 @@ class sieve_vacation
     $known_attrs = array(":days",":subject",":from",":mime",":handle");
 
     /* skip if empty */
-    if(($data == NULL) || !is_array($data)) return;
+    if(($data === NULL) || !is_array($data)) return;
 
     /* Walk through elements */
-    for($i = 0 ; $i < count($data['ELEMENTS']) ; $i ++){
+    $p= count($data['ELEMENTS']);
+    for ($i= 0; $i < $p; $i++){
 
       /* get current element */
       $node = $data['ELEMENTS'][$i];
@@ -57,7 +58,7 @@ class sieve_vacation
             }
           }
         }else{
-              $this->addresses[] = $data['ELEMENTS'][$i]['text'] ;
+              $this->addresses[] =  preg_replace("/\"/i","",$data['ELEMENTS'][$i]['text']);
         }
       }
 
@@ -71,7 +72,7 @@ class sieve_vacation
         foreach($strs as $str){
           $data .= $str;
         }
-        $this->reason = $data;//preg_replace("/\"/","",$data);
+        $this->reason = $data;
       }
     }
   }
@@ -92,7 +93,12 @@ class sieve_vacation
     if($this->mime){
       $str.= ":mime ".sieve_create_strings($this->mime);
     }
-    $str .= "\n ".sieve_create_strings($this->reason);
+  
+    /* Append reason and ensure that this will be 
+     *  handled as multiline text element 
+     *  by adding a "\n" new line 
+     */
+    $str .= "\n ".sieve_create_strings($this->reason."\n");
     return($str." ; \n");
   }
 
@@ -100,7 +106,7 @@ class sieve_vacation
   {
     /* Get release date */
     if(isset($_POST['vacation_release_'.$this->object_id])){
-      $this->days = $_POST['vacation_release_'.$this->object_id];
+      $this->days = stripslashes($_POST['vacation_release_'.$this->object_id]);
     }
 
     /* Check if we want to toggle the expert mode */
@@ -114,9 +120,9 @@ class sieve_vacation
       $tmp = array();
       $tmp2 = split(",",$vr);
       foreach($tmp2 as $val){
-        $ad = trim(preg_replace("/\"/","",$val));
+        $ad = trim($val);
         if(!empty($ad)){
-          $tmp[] = "\"".$ad."\"";
+          $tmp[] = $ad;
         }
       }
       $this->addresses = $tmp;
@@ -125,7 +131,7 @@ class sieve_vacation
     /* Get reason */
     if(isset($_POST['vacation_reason_'.$this->object_id])){
       $vr = stripslashes ($_POST['vacation_reason_'.$this->object_id]);
-      $this->reason = "\"".trim(preg_replace("/\"/","",$vr))."\"";
+      $this->reason = trim($vr);
     }
   }
 
@@ -134,12 +140,12 @@ class sieve_vacation
     $msgs = array();
     $err = FALSE;
     foreach($this->addresses as $addr){
-      if(!is_email(preg_replace("/\"/","",$addr))){
+      if(!is_email($addr)){
         $err = true;
       }
     }
     if($err){
-      $msgs[] = _("Alternative sender addresse must be valid email addresses.");
+      $msgs[] = _("Alternative sender address must be a valid email addresses.");
     }
     return($msgs);
   }
@@ -164,7 +170,7 @@ class sieve_vacation
 
     $object_container = $smarty->fetch(get_template_path("templates/object_container.tpl",TRUE,dirname(__FILE__)));
     $object= $smarty->fetch(get_template_path("templates/element_vacation.tpl",TRUE,dirname(__FILE__)));
-    $str = preg_replace("/%%OBJECT_CONTENT%%/",$object,$object_container);
+    $str = preg_replace("/%%OBJECT_CONTENT%%/",addcslashes($object,"\\"),$object_container);
     return($str);
   }
 }