From 39700a85ffcd49501a7a5f2711dae395b412dc5c Mon Sep 17 00:00:00 2001 From: hickert Date: Thu, 29 Mar 2007 08:23:05 +0000 Subject: [PATCH] Updated String handling in My_Tree class. To avoid losing quotes an every editing process. Updated Vacation to save the reason attribute as > text: ... < git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@5920 594d385d-05f5-0310-b6e9-bd551577e9d8 --- include/sieve/class_My_Tree.inc | 7 +++++-- include/sieve/class_sieveElement_Vacation.inc | 15 ++++++++++----- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/include/sieve/class_My_Tree.inc b/include/sieve/class_My_Tree.inc index ee1276a36..cc9600b6b 100644 --- a/include/sieve/class_My_Tree.inc +++ b/include/sieve/class_My_Tree.inc @@ -731,9 +731,9 @@ function sieve_create_strings($data,$force_string = FALSE) $ret = "text: \r\n".$data."\r\n.\r\n"; }else{ $ret = "\"".$data."\""; + $ret = preg_replace("/\"\"/","\"",$ret); } } - $ret = preg_replace("/\"\"/","\"",$ret); $ret = preg_replace("/\n/","\r\n",$ret); return($ret); @@ -759,7 +759,10 @@ function sieve_get_strings($data,$id) $id ++; } }elseif($data[$id]['class'] == "quoted-string"){ - $ret[] = $data[$id]['text']; + $text = $data[$id]['text']; + $text= preg_replace("/^\"/","",$text); + $text= preg_replace("/\"$/","",$text); + $ret[] = $text; }elseif($data[$id]['class'] == "number"){ $ret[] = $data[$id]['text']; }elseif($data[$id]['class'] == "multi-line"){ diff --git a/include/sieve/class_sieveElement_Vacation.inc b/include/sieve/class_sieveElement_Vacation.inc index 9bb4a41b4..477a7fe0c 100644 --- a/include/sieve/class_sieveElement_Vacation.inc +++ b/include/sieve/class_sieveElement_Vacation.inc @@ -71,7 +71,7 @@ class sieve_vacation foreach($strs as $str){ $data .= $str; } - $this->reason = $data;//preg_replace("/\"/","",$data); + $this->reason = $data; } } } @@ -92,7 +92,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"); } @@ -116,7 +121,7 @@ class sieve_vacation foreach($tmp2 as $val){ $ad = trim(preg_replace("/\"/","",$val)); if(!empty($ad)){ - $tmp[] = "\"".$ad."\""; + $tmp[] = $ad; } } $this->addresses = $tmp; @@ -125,7 +130,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,7 +139,7 @@ class sieve_vacation $msgs = array(); $err = FALSE; foreach($this->addresses as $addr){ - if(!is_email(preg_replace("/\"/","",$addr))){ + if(!is_email($addr)){ $err = true; } } -- 2.30.2