Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

Commit

Permalink
Merge branch 'master' of git://github.com/zendframework/zf2 into cach…
Browse files Browse the repository at this point in the history
…e_plugin_priority

Conflicts:
	library/Zend/Cache/Storage/Adapter/AbstractAdapter.php
	library/Zend/Cache/Storage/Plugin/ClearByFactor.php
	library/Zend/Cache/Storage/Plugin/ExceptionHandler.php
	library/Zend/Cache/Storage/Plugin/IgnoreUserAbort.php
	library/Zend/Cache/Storage/Plugin/OptimizeByFactor.php
	library/Zend/Cache/Storage/Plugin/Serializer.php
  • Loading branch information
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 62 deletions.
8 changes: 4 additions & 4 deletions src/Decode.php
Original file line number Diff line number Diff line change
Expand Up @@ -181,13 +181,13 @@ public static function splitContentType($type, $wantedPart = null)
/**
* split a header field like content type in its different parts
*
* @param string $type header field
* @param string $field header field
* @param string $wantedPart the wanted part, else an array with all parts is returned
* @param string $firstName key name for the first part
* @return string|array wanted part or all parts as array($firstName => firstPart, partname => value)
* @throws Exception\RuntimeException
*/
public static function splitHeaderField($field, $wantedPart = null, $firstName = 0)
public static function splitHeaderField($field, $wantedPart = null, $firstName = '0')
{
$wantedPart = strtolower($wantedPart);
$firstName = strtolower($firstName);
Expand Down Expand Up @@ -234,11 +234,11 @@ public static function splitHeaderField($field, $wantedPart = null, $firstName =
*
* The charset of the returned string depends on your iconv settings.
*
* @param string encoded string
* @param string $string encoded string
* @return string decoded string
*/
public static function decodeQuotedPrintable($string)
{
return quoted_printable_decode($string);
return iconv_mime_decode($string, ICONV_MIME_DECODE_CONTINUE_ON_ERROR);
}
}
4 changes: 2 additions & 2 deletions src/Exception.php → src/Exception/ExceptionInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@
* @license http://framework.zend.com/license/new-bsd New BSD License
*/

namespace Zend\Mime;
namespace Zend\Mime\Exception;

/**
* @category Zend
* @package Zend_Mime
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
interface Exception
interface ExceptionInterface
{}

3 changes: 1 addition & 2 deletions src/Exception/RuntimeException.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
*/

namespace Zend\Mime\Exception;
use Zend\Mime\Exception;

/**
* Exception for Zend_Mime component.
Expand All @@ -33,6 +32,6 @@
*/
class RuntimeException
extends \RuntimeException
implements Exception
implements ExceptionInterface
{
}
4 changes: 1 addition & 3 deletions src/Part.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@
/**
* Class representing a MIME part.
*
* @uses \Zend\Mime\Mime
* @uses \Zend\Mime\Exception
* @category Zend
* @package Zend_Mime
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
Expand Down Expand Up @@ -85,7 +83,7 @@ public function isStream()
* reading the content. very useful for large file attachments.
*
* @return stream
* @throws \Zend\Mime\Exception if not a stream or unable to append filter
* @throws Exception\RuntimeException if not a stream or unable to append filter
*/
public function getEncodedStream()
{
Expand Down
67 changes: 16 additions & 51 deletions test/MimeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,9 @@
* @license http://framework.zend.com/license/new-bsd New BSD License
*/

namespace Zend;
use Zend\Mime;
use Zend\Mail;
namespace ZendTest\Mime;

use Zend\Mime;

/**
* @category Zend
Expand All @@ -36,6 +35,7 @@ class MimeTest extends \PHPUnit_Framework_TestCase
{
/**
* Stores the original set timezone
*
* @var string
*/
private $_originaltimezone;
Expand All @@ -49,7 +49,7 @@ public function setUp()
}

/**
* Teardown environment
* Tear down environment
*/
public function tearDown()
{
Expand All @@ -65,7 +65,7 @@ public function testBoundary()

// check instantiating with arbitrary boundary string
$myBoundary = 'mySpecificBoundary';
$m3 = new Mime\Mime($myBoundary);
$m3 = new Mime\Mime($myBoundary);
$this->assertEquals($m3->boundary(), $myBoundary);

}
Expand Down Expand Up @@ -102,25 +102,13 @@ public function testBase64()

public function testZf1058WhitespaceAtEndOfBodyCausesInfiniteLoop()
{
// Set timezone to avoid "date(): It is not safe to rely on the system's timezone settings."
// message.
date_default_timezone_set('GMT');

$mail = new \Zend\Mail\Mail();
$mail->setSubject('my subject');
$mail->setBodyText("my body\r\n\r\n...after two newlines\r\n ");
$mail->setFrom('test@email.com');
$mail->addTo('test@email.com');

// test with generic transport
$mock = new SendmailTransportMock();
$mail->send($mock);
$body = quoted_printable_decode($mock->body);
$this->assertContains("my body\r\n\r\n...after two newlines", $body, $body);
$text = "my body\r\n\r\n...after two newlines\r\n ";
$result = quoted_printable_decode(Mime\Mime::encodeQuotedPrintable($text));
$this->assertContains("my body\r\n\r\n...after two newlines", $result, $result);
}

/**
* @group ZF-1688
* @group ZF-1688
* @dataProvider dataTestEncodeMailHeaderQuotedPrintable
*/
public function testEncodeMailHeaderQuotedPrintable($str, $charset, $result)
Expand All @@ -142,7 +130,7 @@ public static function dataTestEncodeMailHeaderQuotedPrintable()
}

/**
* @group ZF-1688
* @group ZF-1688
* @dataProvider dataTestEncodeMailHeaderBase64
*/
public function testEncodeMailHeaderBase64($str, $charset, $result)
Expand All @@ -167,39 +155,16 @@ public function testLineLengthInQuotedPrintableHeaderEncoding()
{
$subject = "Alle meine Entchen schwimmen in dem See, schwimmen in dem See, Köpfchen in das Wasser, Schwänzchen in die Höh!";
$encoded = Mime\Mime::encodeQuotedPrintableHeader($subject, "UTF-8", 100);
foreach(explode(Mime\Mime::LINEEND, $encoded) AS $line ) {
if(strlen($line) > 100) {
$this->fail("Line '".$line."' is ".strlen($line)." chars long, only 100 allowed.");
foreach (explode(Mime\Mime::LINEEND, $encoded) AS $line) {
if (strlen($line) > 100) {
$this->fail("Line '" . $line . "' is " . strlen($line) . " chars long, only 100 allowed.");
}
}
$encoded = Mime\Mime::encodeQuotedPrintableHeader($subject, "UTF-8", 40);
foreach(explode(Mime\Mime::LINEEND, $encoded) AS $line ) {
if(strlen($line) > 40) {
$this->fail("Line '".$line."' is ".strlen($line)." chars long, only 40 allowed.");
foreach (explode(Mime\Mime::LINEEND, $encoded) AS $line) {
if (strlen($line) > 40) {
$this->fail("Line '" . $line . "' is " . strlen($line) . " chars long, only 40 allowed.");
}
}
}
}


/**
* Mock mail transport class for testing Sendmail transport
*/
class SendmailTransportMock extends Mail\Transport\Sendmail
{
/**
* @var Zend_Mail
*/
public $mail = null;
public $from = null;
public $subject = null;
public $called = false;

public function _sendMail()
{
$this->mail = $this->_mail;
$this->from = $this->_mail->getFrom();
$this->subject = $this->_mail->getSubject();
$this->called = true;
}
}

0 comments on commit 54c204b

Please sign in to comment.