svn: /pear/packages/Mail_Mime/trunk/ mimePart.php tests/test_Bug_14779.phpt
| From: | Aleksander Machniak | Date: | Thu, 17 Dec 2009 14:04:59 +0000 |
| Subject: | svn: /pear/packages/Mail_Mime/trunk/ mimePart.php tests/test_Bug_14779.phpt | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-58293@lists.php.net to get a copy of this message | ||
alec Thu, 17 Dec 2009 14:04:59 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=292255
Log:
- Fix problem with an empty attachment (#14779)
Bug: http://pear.php.net/bugs/14779 (unknown)
Changed paths:
U pear/packages/Mail_Mime/trunk/mimePart.php
A pear/packages/Mail_Mime/trunk/tests/test_Bug_14779.phpt
Modified: pear/packages/Mail_Mime/trunk/mimePart.php
===================================================================
--- pear/packages/Mail_Mime/trunk/mimePart.php 2009-12-17 13:29:46 UTC (rev 292254)
+++ pear/packages/Mail_Mime/trunk/mimePart.php 2009-12-17 14:04:59 UTC (rev 292255)
@@ -240,7 +240,7 @@
if (count($this->_subparts)) {
$boundary = '=_' . md5(rand() . microtime());
- $this->_headers['Content-Type'] .= ';' . MAIL_MIMEPART_CRLF .
"\t" . 'boundary="' . $boundary . '"';
+ $this->_headers['Content-Type'] .= ';' . MAIL_MIMEPART_CRLF .
' boundary="' . $boundary . '"';
// Add body parts to $subparts
for ($i = 0; $i < count($this->_subparts); $i++) {
@@ -253,8 +253,8 @@
}
$encoded['body'] = '--' . $boundary . MAIL_MIMEPART_CRLF .
- rtrim(implode('--' . $boundary . MAIL_MIMEPART_CRLF ,
$subparts), MAIL_MIMEPART_CRLF) . MAIL_MIMEPART_CRLF .
- '--' . $boundary.'--' . MAIL_MIMEPART_CRLF;
+ implode('--' . $boundary . MAIL_MIMEPART_CRLF , $subparts)
.
+ '--' . $boundary . '--' . MAIL_MIMEPART_CRLF;
} else {
$encoded['body'] = $this->_getEncodedData($this->_body,
$this->_encoding);
Added: pear/packages/Mail_Mime/trunk/tests/test_Bug_14779.phpt
===================================================================
--- pear/packages/Mail_Mime/trunk/tests/test_Bug_14779.phpt (rev 0)
+++ pear/packages/Mail_Mime/trunk/tests/test_Bug_14779.phpt 2009-12-17 14:04:59 UTC (rev 292255)
@@ -0,0 +1,26 @@
+--TEST--
+Bug #14779 Proper header-body separator for empty attachment
+--SKIPIF--
+--FILE--
+<?php
+error_reporting(E_ALL); // ignore E_STRICT
+include "Mail/mime.php";
+
+$m = new Mail_mime();
+$m->addAttachment('', "text/plain", 'file.txt', FALSE,
'base64', 'attachment');
+$result = $m->get();
+
+if (preg_match('/(Content.*)--=.*/s', $result, $matches)) {
+ print_r($matches[1]."END");
+}
+
+?>
+--EXPECT--
+Content-Transfer-Encoding: base64
+Content-Type: text/plain;
+ name="file.txt"
+Content-Disposition: attachment;
+ filename="file.txt"
+
+
+END
\ No newline at end of file