Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Added automatic setting of attachment size via Content-Disposition si…

…ze parameter
  • Loading branch information...
commit 2202d28f025a3ef13105e69d334b3580000ae433 1 parent ad596b0
Aleksander Machniak alecpl authored
6 Mail/mimePart.php
@@ -247,6 +247,12 @@ function Mail_mimePart($body = '', $params = array())
247 247 !empty($params['filename_encoding']) ? $params['filename_encoding'] : null
248 248 );
249 249 }
  250 +
  251 + // add attachment size
  252 + $size = $this->_body_file ? filesize($this->_body_file) : strlen($body);
  253 + if ($size) {
  254 + $headers['Content-Disposition'] .= ';' . $this->_eol . ' size=' . $size;
  255 + }
250 256 }
251 257
252 258 if (!empty($params['description'])) {
1  package.xml
@@ -41,6 +41,7 @@ using RFC2047 and/or RFC2231.</description>
41 41 <license uri="http://www.opensource.org/licenses/bsd-license.php">BSD Style</license>
42 42 <notes>
43 43 * Added possibility to set additional parameters of message part header, e.g. attachment size [alec]
  44 + * Added automatic setting of attachment size via Content-Disposition header size parameter [alec]
44 45 </notes>
45 46 <contents>
46 47 <dir name="/">
3  tests/test_Bug_12411.phpt
@@ -24,4 +24,5 @@ echo $enc->_headers['Content-Disposition'];
24 24 text/plain; charset=ISO-8859-1;
25 25 name="=?ISO-8859-1?Q?=C5=9Bciema?="
26 26 attachment;
27   - filename="=?ISO-8859-1?B?xZtjaWVtYQ==?="
  27 + filename="=?ISO-8859-1?B?xZtjaWVtYQ==?=";
  28 + size=8
3  tests/test_Bug_14529.phpt
@@ -15,4 +15,5 @@ print_r($enc->_headers['Content-Disposition']);
15 15 ?>
16 16 --EXPECT--
17 17 attachment;
18   - filename*=ISO-8859-1''%C5%9Bciema
  18 + filename*=ISO-8859-1''%C5%9Bciema;
  19 + size=8
3  tests/test_Bug_18083.phpt
@@ -22,4 +22,5 @@ echo $enc->_headers['Content-Disposition'];
22 22 text/plain; charset=ISO-8859-1;
23 23 name="=?UTF-8?Q?=C5=9Bciema?="
24 24 attachment;
25   - filename="=?UTF-8?B?xZtjaWVtYQ==?="
  25 + filename="=?UTF-8?B?xZtjaWVtYQ==?=";
  26 + size=8
3  tests/test_Bug_3513_1.phpt
@@ -12,4 +12,5 @@ $enc = $Mime->_addAttachmentPart($root, $Mime->_parts[0]);
12 12 print($enc->_headers['Content-Disposition']);
13 13 --EXPECT--
14 14 attachment;
15   - filename*=ISO-8859-1''F%F3%F3b%E6r.txt
  15 + filename*=ISO-8859-1''F%F3%F3b%E6r.txt;
  16 + size=8
3  tests/test_Bug_3513_2.phpt
@@ -13,4 +13,5 @@ print($enc->_headers['Content-Disposition']);
13 13 --EXPECT--
14 14 attachment;
15 15 filename*0*=UTF-8'de'S%C3%BCper%20gr%C3%B6se%20tolle%20tolle%20gr%C3%BC;
16   - filename*1*=%C3%9Fe.txt
  16 + filename*1*=%C3%9Fe.txt;
  17 + size=8
4 tests/test_Bug_3513_3.phpt
@@ -15,4 +15,6 @@ print($enc->_headers['Content-Disposition']);
15 15 ?>
16 16 --EXPECT--
17 17 attachment;
18   - filename*=iso-2022-jp''%1B$BF|K%5C8l%1B%28B.txt
  18 + filename*=iso-2022-jp''%1B$BF|K%5C8l%1B%28B.txt;
  19 + size=8
  20 +

0 comments on commit 2202d28

Please sign in to comment.
Something went wrong with that request. Please try again.