Permalink
Browse files

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

  • Loading branch information...
1 parent 8975966 commit 68bc85ad8c1eeea41fff77468662aac5e50c938d @alecpl alecpl committed Jul 9, 2012
Showing with 31 additions and 4 deletions.
  1. +1 −2 Mail/Mime2.php
  2. +1 −2 tests/test_Bug_14529.phpt
  3. +29 −0 tests/test_Bug_19497.phpt
View
@@ -420,7 +420,7 @@ public function addAttachment($file,
}
}
// Force the name the user supplied, otherwise use $file
- $filename = ($name ? $name : $file);
+ $filename = ($name ? $name : self::_basename($file));
} else {
$filedata = $file;
$filename = $name;
@@ -431,7 +431,6 @@ public function addAttachment($file,
$err = PEAR::raiseError($msg);
return $err;
}
- $filename = self::_basename($filename);
$this->_parts[] = array(
'body' => $filedata,
@@ -6,8 +6,7 @@ Bug #14529 basename() workaround
include "Mail/Mime2.php";
$m = new Mail_Mime2;
// 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');
$msg = $m->get();
View
@@ -0,0 +1,29 @@
+--TEST--
+Bug #19497 Attachment filenames with a slash character
+--SKIPIF--
+--FILE--
+<?php
+
+include "Mail/MimePart2.php";
+
+$part = new Mail_MimePart2('', array(
+ 'content-type' => 'text/plain',
+ 'filename' => "test/file.txt",
+ 'disposition' => 'attachment',
+ 'headers_charset' => 'UTF-8',
+ 'charset' => 'ISO-8859-1',
+ 'name_encoding' => 'quoted-printable',
+ 'filename_encoding' => 'base64',
+));
+
+$msg = $part->encode();
+
+echo $msg['headers']['Content-Type'];
+echo "\n";
+echo $msg['headers']['Content-Disposition'];
+?>
+--EXPECT--
+text/plain; charset=ISO-8859-1;
+ name="test/file.txt"
+attachment;
+ filename="test/file.txt"

0 comments on commit 68bc85a

Please sign in to comment.