mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 09:06:17 +00:00
parent
9deb966657
commit
6ce4a3a1ec
2 changed files with 50 additions and 3 deletions
|
@ -1355,7 +1355,10 @@ class CakeEmail {
|
|||
$msg[] = '--' . $boundary;
|
||||
$msg[] = 'Content-Type: ' . $fileInfo['mimetype'];
|
||||
$msg[] = 'Content-Transfer-Encoding: base64';
|
||||
if (!isset($fileInfo['contentDisposition']) || $fileInfo['contentDisposition']) {
|
||||
if (
|
||||
!isset($fileInfo['contentDisposition']) ||
|
||||
$fileInfo['contentDisposition']
|
||||
) {
|
||||
$msg[] = 'Content-Disposition: attachment; filename="' . $filename . '"';
|
||||
}
|
||||
$msg[] = '';
|
||||
|
|
|
@ -640,13 +640,20 @@ class CakeEmailTest extends CakeTestCase {
|
|||
*/
|
||||
public function testAttachments() {
|
||||
$this->CakeEmail->attachments(CAKE . 'basics.php');
|
||||
$expected = array('basics.php' => array('file' => CAKE . 'basics.php', 'mimetype' => 'application/octet-stream'));
|
||||
$expected = array(
|
||||
'basics.php' => array(
|
||||
'file' => CAKE . 'basics.php',
|
||||
'mimetype' => 'application/octet-stream'
|
||||
)
|
||||
);
|
||||
$this->assertSame($this->CakeEmail->attachments(), $expected);
|
||||
|
||||
$this->CakeEmail->attachments(array());
|
||||
$this->assertSame($this->CakeEmail->attachments(), array());
|
||||
|
||||
$this->CakeEmail->attachments(array(array('file' => CAKE . 'basics.php', 'mimetype' => 'text/plain')));
|
||||
$this->CakeEmail->attachments(array(
|
||||
array('file' => CAKE . 'basics.php', 'mimetype' => 'text/plain')
|
||||
));
|
||||
$this->CakeEmail->addAttachments(CAKE . 'bootstrap.php');
|
||||
$this->CakeEmail->addAttachments(array(CAKE . 'bootstrap.php'));
|
||||
$this->CakeEmail->addAttachments(array('other.txt' => CAKE . 'bootstrap.php', 'license' => CAKE . 'LICENSE.txt'));
|
||||
|
@ -937,6 +944,43 @@ class CakeEmailTest extends CakeTestCase {
|
|||
$this->assertContains('--' . $boundary . '--', $result['message']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test disabling content-disposition.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testSendWithNoContentDispositionAttachments() {
|
||||
$this->CakeEmail->transport('debug');
|
||||
$this->CakeEmail->from('cake@cakephp.org');
|
||||
$this->CakeEmail->to('cake@cakephp.org');
|
||||
$this->CakeEmail->subject('My title');
|
||||
$this->CakeEmail->emailFormat('text');
|
||||
$this->CakeEmail->attachments(array(
|
||||
'cake.png' => array(
|
||||
'file' => CAKE . 'VERSION.txt',
|
||||
'contentDisposition' => false
|
||||
)
|
||||
));
|
||||
$result = $this->CakeEmail->send('Hello');
|
||||
|
||||
$boundary = $this->CakeEmail->getBoundary();
|
||||
$this->assertContains('Content-Type: multipart/mixed; boundary="' . $boundary . '"', $result['headers']);
|
||||
$expected = "--$boundary\r\n" .
|
||||
"Content-Type: text/plain; charset=UTF-8\r\n" .
|
||||
"Content-Transfer-Encoding: 8bit\r\n" .
|
||||
"\r\n" .
|
||||
"Hello" .
|
||||
"\r\n" .
|
||||
"\r\n" .
|
||||
"\r\n" .
|
||||
"--{$boundary}\r\n" .
|
||||
"Content-Type: application/octet-stream\r\n" .
|
||||
"Content-Transfer-Encoding: base64\r\n" .
|
||||
"\r\n";
|
||||
|
||||
$this->assertContains($expected, $result['message']);
|
||||
$this->assertContains('--' . $boundary . '--', $result['message']);
|
||||
}
|
||||
/**
|
||||
* testSendWithLog method
|
||||
*
|
||||
|
|
Loading…
Add table
Reference in a new issue