Code

Heimdal stuff not needed. It's too insecure to read m-keys by php.
[gosa.git] / include / sieve / class_sieveElement_Redirect.inc
index 47cea6020effb68ac9eeb32dc459316b03296d6d..64e71b6f8bba0c88a5255be7681add920154da20 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 class sieve_redirect 
 {
-  var $data = array();
+  var $data = "";
   var $object_id = -1;
   var $LastError   ="";
   
@@ -10,7 +10,7 @@ class sieve_redirect
     if(isset($_POST['redirect_to_'.$this->object_id])){
       $rt = stripslashes($_POST['redirect_to_'.$this->object_id]);
 
-      $rt = "\"".trim(preg_replace("/\"/","",$rt))."\"";
+      $rt = trim($rt);
       $this->data = $rt;
     }
   }
@@ -20,7 +20,7 @@ class sieve_redirect
   {
     $msgs = array();
     
-    if(!is_email(preg_replace("/\"/","",$this->data))){
+    if(!is_email($this->data)){
       $msgs[] =_("Please specify a valid email address.");
     }
     
@@ -31,13 +31,15 @@ class sieve_redirect
   {
     $this->object_id = $object_id;
 
-    if($data == NULL){
-      $data = array('ELEMENTS' => array(array('class' => "quoted-string" ,"text" => _("Put a mail address here"))));
+    if($data === NULL){
+      $data = array('ELEMENTS' => array(array('class' => "quoted-string" ,"text" => _("Place a mail address here"))));
     }
 
-    foreach($data['ELEMENTS'] as $node ){
-      if(in_array($node['class'],array("quoted-string","text"))){
-        $this->data = $node['text'];
+    for($i = 0 ; $i < count($data['ELEMENTS']) ; $i++){
+      $tmp = sieve_get_strings($data['ELEMENTS'],$i);
+      $i  = $i + $tmp['OFFSET'];
+      foreach($tmp['STRINGS'] as $str){
+        $this->data .= $str;
       }
     }
   }
@@ -51,8 +53,7 @@ class sieve_redirect
  
   function execute()
   {
-    $values = $this->data;
-
+    $values = htmlentities($this->data);
     $smarty = get_smarty();
     $smarty->assign("ID", $this->object_id);
     $smarty->assign("Destinations" , $values);
@@ -60,7 +61,7 @@ class sieve_redirect
     $smarty->assign("LastErrorCnt" , count($this->check()));
     $object_container = $smarty->fetch(get_template_path("templates/object_container.tpl",TRUE,dirname(__FILE__)));
     $object= $smarty->fetch(get_template_path("templates/element_redirect.tpl",TRUE,dirname(__FILE__)));
-    $str = preg_replace("/%%OBJECT_CONTENT%%/",$object,$object_container);
+    $str = preg_replace("/%%OBJECT_CONTENT%%/",addcslashes($object,"\\"),$object_container);
     return($str);
   }
 }