Browse files

* Bug #19497: Attachment filename is cut on slash character

  • Loading branch information...
1 parent fc6e3f7 commit 5d1e8e07f6612ac059359dbce11800353a73c207 @alecpl alecpl committed Jul 9, 2012
Showing with 29 additions and 6 deletions.
  1. +1 −2 Mail/mime.php
  2. +1 −0 package.xml
  3. +1 −2 tests/test_Bug_12411.phpt
  4. +1 −2 tests/test_Bug_14529.phpt
  5. +25 −0 tests/test_Bug_19497.phpt
View
3 Mail/mime.php
@@ -421,7 +421,7 @@ function addAttachment($file,
}
}
// Force the name the user supplied, otherwise use $file
- $filename = ($name ? $name : $file);
+ $filename = ($name ? $name : $this->_basename($file));
} else {
$filedata = $file;
$filename = $name;
@@ -432,7 +432,6 @@ function addAttachment($file,
$err = PEAR::raiseError($msg);
return $err;
}
- $filename = $this->_basename($filename);
$this->_parts[] = array(
'body' => $filedata,
View
1 package.xml
@@ -41,6 +41,7 @@ using RFC2047 and/or RFC2231.</description>
<license uri="http://www.opensource.org/licenses/bsd-license.php">BSD Style</license>
<notes>
* Bug #19473: PEAR::isError() compatibility problem with PHP 5.4 [alec]
+* Bug #19497: Attachment filename is cut on slash character [alec]
</notes>
<contents>
<dir name="/">
View
3 tests/test_Bug_12411.phpt
@@ -7,8 +7,7 @@ include "Mail/mime.php";
$m = new Mail_mime();
// some text with polish Unicode letter at the beginning
-$path = "/path/";
-$filename = $path . base64_decode("xZtjaWVtYQ==");
+$filename = base64_decode("xZtjaWVtYQ==");
$m->addAttachment('testfile', "text/plain", $filename, FALSE,
'base64', 'attachment', 'ISO-8859-1', 'pl', '',
'quoted-printable', 'base64');
View
3 tests/test_Bug_14529.phpt
@@ -6,8 +6,7 @@ Bug #14529 basename() workaround
include "Mail/mime.php";
$m = new Mail_mime();
// some text with polish Unicode letter at the beginning
-$path = "/path/";
-$filename = $path . base64_decode("xZtjaWVtYQ==");
+$filename = base64_decode("xZtjaWVtYQ==");
$m->addAttachment('testfile', "text/plain", $filename, FALSE, 'base64', 'attachment', 'ISO-8859-1');
$root = $m->_addMixedPart();
$enc = $m->_addAttachmentPart($root, $m->_parts[0]);
View
25 tests/test_Bug_19497.phpt
@@ -0,0 +1,25 @@
+--TEST--
+Bug #19497 Attachment filenames with a slash character
+--SKIPIF--
+--FILE--
+<?php
+include "Mail/mime.php";
+$m = new Mail_mime();
+
+$filename = "test/file.txt";
+$m->addAttachment('testfile', "text/plain", $filename, FALSE,
+ 'base64', 'attachment', 'ISO-8859-1', '', '', 'quoted-printable', 'base64');
+
+$root = $m->_addMixedPart();
+$enc = $m->_addAttachmentPart($root, $m->_parts[0]);
+
+echo $enc->_headers['Content-Type'];
+echo "\n";
+echo $enc->_headers['Content-Disposition'];
+?>
+--EXPECT--
+text/plain; charset=ISO-8859-1;
+ name="test/file.txt"
+attachment;
+ filename="test/file.txt";
+ size=8

0 comments on commit 5d1e8e0

Please sign in to comment.