From: indiri69 Date: Fri, 23 Aug 2002 16:31:32 +0000 (+0000) Subject: Cleaned up parseComments so it handles comments inside of comments. Changed X-Git-Url: https://vcs.fsf.org/?p=squirrelmail.git;a=commitdiff_plain;h=20760c79d646dd44c2308f9a2a3b79561501649b Cleaned up parseComments so it handles comments inside of comments. Changed a for to a foreach for simplify the clean up function. git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@3434 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- diff --git a/class/mime.class.php b/class/mime.class.php index dd2eec53..e6d9c3b8 100644 --- a/class/mime.class.php +++ b/class/mime.class.php @@ -67,24 +67,35 @@ class rfc822_header { $result = ''; $cnt = strlen($value); - for ($i = 0; $i < $cnt; ++$i) { + for ($i = 0; $i < $cnt; $i++) { switch ($value{$i}) { case '"': $result .= '"'; - ++$i; - while ($value{$i} != '"') { + while ((++$i < $cnt) && ($value{$i} != '"')) { if ($value{$i} == '\\') { $result .= '\\'; - ++$i; + $i++; } $result .= $value{$i}; - if (++$i > $cnt) { break; } } $result .= $value{$i}; break; case '(': - while ($value{$i} != ')') { - $i += ($value{$i} == '\\' ? 2 : 1); + $depth = 1; + while (($depth > 0) && (++$i < $cnt)) { + switch($value{$i}) { + case '\\': + $i++; + break; + case '(': + $depth++; + break; + case ')': + $depth--; + break; + default: + break; + } } break; default: @@ -397,7 +408,6 @@ class rfc822_header { } } } - return $s; } @@ -491,7 +501,7 @@ class address_structure { $result = ''; if (is_object($this)) { - if (isset($this->host) &&( $this->host != '')) { + if (isset($this->host) && ($this->host != '')) { $email = $this->mailbox.'@'.$this->host; } else { $email = $this->mailbox; @@ -509,7 +519,6 @@ class address_structure { } $result = ($full ? $addr : $best_dpl); } - return $result; } } @@ -552,11 +561,9 @@ class message { $filename = $this->header->disposition->getproperty('name'); } } - if (!$filename) { $filename = 'untitled-'.$this->entity_id; } - return $filename; } @@ -569,7 +576,7 @@ class message { function getEntity($ent) { $cur_ent = $this->entity_id; $msg = $this; - if (($cur_ent == '') ||( $cur_ent == '0')) { + if (($cur_ent == '') || ($cur_ent == '0')) { $cur_ent_a = array(); } else { $cur_ent_a = explode('.', $this->entity_id); @@ -618,8 +625,8 @@ class message { $msg = $this; $msg->body_part = ''; - for ($i = 0; isset($msg->entities[$i]); ++$i) { - $msg->entities[$i]->clean_up(); + foreach ($msg->entities as $m) { + $m->clean_up(); } } @@ -643,7 +650,7 @@ class message { if ($par_ent == '0') { $ent_no = count($this->entities) + 1; if ($ent_no > 0) { - $ent = substr($this->entity_id, 0,strrpos($this->entity_id, '.')); + $ent = substr($this->entity_id, 0, strrpos($this->entity_id, '.')); $ent = ($ent ? $ent . ".$ent_no" : $ent_no); $msg->entity_id = $ent; } else {