svn: /pear/packages/Mail_Mime/trunk/ mimeDecode.php tests/parse_header_value.phpt
| From: | Alan Knowles | Date: | Sun, 05 Sep 2010 09:16:12 +0000 |
| Subject: | svn: /pear/packages/Mail_Mime/trunk/ mimeDecode.php tests/parse_header_value.phpt | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-60246@lists.php.net to get a copy of this message | ||
alan_k Sun, 05 Sep 2010 09:16:12 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=303047
Log:
fix #17844 - all regression tests fixed - remove the last of the while list each() .. this is 2010
;)...
Bug: http://pear.php.net/bugs/17844 (unknown)
Changed paths:
U pear/packages/Mail_Mime/trunk/mimeDecode.php
U pear/packages/Mail_Mime/trunk/tests/parse_header_value.phpt
Modified: pear/packages/Mail_Mime/trunk/mimeDecode.php
===================================================================
--- pear/packages/Mail_Mime/trunk/mimeDecode.php 2010-09-05 08:46:41 UTC (rev 303046)
+++ pear/packages/Mail_Mime/trunk/mimeDecode.php 2010-09-05 09:16:12 UTC (rev 303047)
@@ -260,8 +260,8 @@
}
}
- reset($headers);
- while (list($key, $value) = each($headers)) {
+
+ foreach ($headers as $key => $value) {
$headers[$key]['name'] = strtolower($headers[$key]['name']);
switch ($headers[$key]['name']) {
@@ -274,7 +274,7 @@
}
if (isset($content_type['other'])) {
- while (list($p_name, $p_value) = each($content_type['other'])) {
+ foreach($content_type['other'] as $p_name => $p_value) {
$return->ctype_parameters[$p_name] = $p_value;
}
}
@@ -505,12 +505,18 @@
$val = false; // our string - including quotes..
$q = false; // in quote..
$lq = ''; // last quote..
+
while ($i < $l) {
- // echo "READ:". $c ."\n";
+
$c = $input[$i];
+ //var_dump(array('i'=>$i,'c'=>$c,'q'=>$q,
'lq'=>$lq, 'key'=>$key, 'val' =>$val));
+
$escaped = false;
if ($c == '\\') {
$i++;
+ if ($i == $l-1) { // end of string.
+ break;
+ }
$escaped = true;
$c = $input[$i];
}
@@ -541,7 +547,7 @@
if ($q === false) {
// not in quote yet.
- if ((!strlen($val) || $lq) && $c == ' ' || $c == "\t")
{
+ if ((!strlen($val) || $lq !== false) && $c == ' ' || $c ==
"\t") {
$i++;
continue; // skip leading spaces after '=' or after
'"'
}
@@ -560,7 +566,8 @@
$val = trim($val);
$added = false;
if (preg_match('/\*[0-9]+$/', $key)) {
- // no dupes due to our crazy regexp.
+ // this is the extended aaa*0=...;aaa*1=.... code
+ // it assumes the pieces arrive in order, and are valid...
$key = preg_replace('/\*[0-9]+$/', '', $key);
if (isset($return['other'][$key])) {
$return['other'][$key] .= $val;
@@ -604,9 +611,7 @@
// do we have anything left..
if (strlen(trim($key)) || $val !== false) {
- if ($lq) {
- $val = str_replace('\\'.$lq, $lq, $val); // replace out quoted values..
- }
+
$val = trim($val);
$added = false;
if ($val !== false && preg_match('/\*[0-9]+$/', $key)) {
@@ -626,10 +631,11 @@
$return['other'][strtolower($key)] = $val;
}
}
+ // decode values.
foreach($return['other'] as $key =>$val) {
$return['other'][$key] = $this->_decode_headers ?
$this->_decodeHeader($val) : $val;
}
-
+ //print_r($return);
return $return;
}
Modified: pear/packages/Mail_Mime/trunk/tests/parse_header_value.phpt
===================================================================
--- pear/packages/Mail_Mime/trunk/tests/parse_header_value.phpt 2010-09-05 08:46:41 UTC (rev 303046)
+++ pear/packages/Mail_Mime/trunk/tests/parse_header_value.phpt 2010-09-05 09:16:12 UTC (rev 303047)
@@ -5,7 +5,7 @@
<?php
error_reporting(E_ALL); // suppress E_STRICT errors
-require_once('Mail/mime.php');
+require_once 'Mail/mime.php';
$Mime = new Mail_Mime();
$Mime->setTXTBody('Test message.');
@@ -24,7 +24,7 @@
$hdrs .= "From: Sender <sender@example.com>\n";
$hdrs .= "Subject: PEAR::Mail_Mime test mail\n";
-require_once('Mail/mimeDecode.php');
+require_once 'Mail/mimeDecode.php';
$mime_message = "$hdrs\n$body";
$Decoder = new Mail_mimeDecode($mime_message);