mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-25 11:38:44 +02:00
N°1285 & N°1278: Updated swiftmailer to v5.4.9
SVN:trunk[5754]
This commit is contained in:
@@ -1,6 +1,108 @@
|
||||
Changelog
|
||||
=========
|
||||
|
||||
5.4.9 (2018-01-23)
|
||||
------------------
|
||||
|
||||
* no changes, last version of the 5.x series
|
||||
|
||||
5.4.8 (2017-05-01)
|
||||
------------------
|
||||
|
||||
* fixed encoding inheritance in addPart()
|
||||
* fixed sorting MIME children when their types are equal
|
||||
|
||||
5.4.7 (2017-04-20)
|
||||
------------------
|
||||
|
||||
* fixed NTLMAuthenticator clobbering bcmath scale
|
||||
|
||||
5.4.6 (2017-02-13)
|
||||
------------------
|
||||
|
||||
* removed exceptions thrown in destructors as they lead to fatal errors
|
||||
* switched to use sha256 by default in DKIM as per the RFC
|
||||
* fixed an 'Undefined variable: pipes' PHP notice
|
||||
* fixed long To headers when using the mail transport
|
||||
* fixed NTLMAuthenticator when no domain is passed with the username
|
||||
* prevented fatal error during unserialization of a message
|
||||
* fixed a PHP warning when sending a message that has a length of a multiple of 8192
|
||||
|
||||
5.4.5 (2016-12-29)
|
||||
------------------
|
||||
|
||||
* SECURITY FIX: fixed CVE-2016-10074 by disallowing potentially unsafe shell characters
|
||||
|
||||
Prior to 5.4.5, the mail transport (Swift_Transport_MailTransport) was vulnerable to passing
|
||||
arbitrary shell arguments if the "From", "ReturnPath" or "Sender" header came
|
||||
from a non-trusted source, potentially allowing Remote Code Execution
|
||||
* deprecated the mail transport
|
||||
|
||||
5.4.4 (2016-11-23)
|
||||
------------------
|
||||
|
||||
* reverted escaping command-line args to mail (PHP mail() function already does it)
|
||||
|
||||
5.4.3 (2016-07-08)
|
||||
------------------
|
||||
|
||||
* fixed SimpleHeaderSet::has()/get() when the 0 index is removed
|
||||
* removed the need to have mcrypt installed
|
||||
* fixed broken MIME header encoding with quotes/colons and non-ascii chars
|
||||
* allowed mail transport send for messages without To header
|
||||
* fixed PHP 7 support
|
||||
|
||||
5.4.2 (2016-05-01)
|
||||
------------------
|
||||
|
||||
* fixed support for IPv6 sockets
|
||||
* added auto-retry when sending messages from the memory spool
|
||||
* fixed consecutive read calls in Swift_ByteStream_FileByteStream
|
||||
* added support for iso-8859-15 encoding
|
||||
* fixed PHP mail extra params on missing reversePath
|
||||
* added methods to set custom stream context options
|
||||
* fixed charset changes in QpContentEncoderProxy
|
||||
* added return-path header to the ignoredHeaders list of DKIMSigner
|
||||
* fixed crlf for subject using mail
|
||||
* fixed add soft line break only when necessary
|
||||
* fixed escaping command-line args to mail
|
||||
|
||||
5.4.1 (2015-06-06)
|
||||
------------------
|
||||
|
||||
* made Swiftmailer exceptions confirm to PHP base exception constructor signature
|
||||
* fixed MAIL FROM & RCPT TO headers to be RFC compliant
|
||||
|
||||
5.4.0 (2015-03-14)
|
||||
------------------
|
||||
|
||||
* added the possibility to add extra certs to PKCS#7 signature
|
||||
* fix base64 encoding with streams
|
||||
* added a new RESULT_SPOOLED status for SpoolTransport
|
||||
* fixed getBody() on attachments when called more than once
|
||||
* removed dots from generated filenames in filespool
|
||||
|
||||
5.3.1 (2014-12-05)
|
||||
------------------
|
||||
|
||||
* fixed cloning of messages with attachments
|
||||
|
||||
5.3.0 (2014-10-04)
|
||||
------------------
|
||||
|
||||
* fixed cloning when using signers
|
||||
* reverted removal of Swift_Encoding
|
||||
* drop support for PHP 5.2.x
|
||||
|
||||
5.2.2 (2014-09-20)
|
||||
------------------
|
||||
|
||||
* fixed Japanese support
|
||||
* fixed the memory spool when the message changes when in the pool
|
||||
* added support for cloning messages
|
||||
* fixed PHP warning in the redirect plugin
|
||||
* changed the way to and cc-ed email are sent to only use one transaction
|
||||
|
||||
5.2.1 (2014-06-13)
|
||||
------------------
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
Copyright (c) 2013 Fabien Potencier
|
||||
Copyright (c) 2013-2016 Fabien Potencier
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -4,9 +4,8 @@ Swift Mailer
|
||||
Swift Mailer is a component based mailing solution for PHP 5.
|
||||
It is released under the MIT license.
|
||||
|
||||
Homepage: http://swiftmailer.org
|
||||
Documentation: http://swiftmailer.org/docs
|
||||
Mailing List: http://groups.google.com/group/swiftmailer
|
||||
Homepage: https://swiftmailer.symfony.com/
|
||||
Documentation: https://swiftmailer.symfony.com/docs/introduction.html
|
||||
Bugs: https://github.com/swiftmailer/swiftmailer/issues
|
||||
Repository: https://github.com/swiftmailer/swiftmailer
|
||||
|
||||
|
||||
@@ -1 +1 @@
|
||||
Swift-5.2.1
|
||||
Swift-5.4.9
|
||||
|
||||
@@ -11,18 +11,17 @@
|
||||
/**
|
||||
* General utility class in Swift Mailer, not to be instantiated.
|
||||
*
|
||||
* @package Swift
|
||||
*
|
||||
* @author Chris Corbyn
|
||||
*/
|
||||
abstract class Swift
|
||||
{
|
||||
public static $initialized = false;
|
||||
public static $inits = array();
|
||||
|
||||
/** Swift Mailer Version number generated during dist release process */
|
||||
const VERSION = '@SWIFT_VERSION_NUMBER@';
|
||||
|
||||
public static $initialized = false;
|
||||
public static $inits = array();
|
||||
|
||||
/**
|
||||
* Registers an initializer callable that will be called the first time
|
||||
* a SwiftMailer class is autoloaded.
|
||||
@@ -48,7 +47,7 @@ abstract class Swift
|
||||
return;
|
||||
}
|
||||
|
||||
$path = dirname(__FILE__).'/'.str_replace('_', '/', $class).'.php';
|
||||
$path = __DIR__.'/'.str_replace('_', '/', $class).'.php';
|
||||
|
||||
if (!file_exists($path)) {
|
||||
return;
|
||||
|
||||
@@ -11,8 +11,6 @@
|
||||
/**
|
||||
* Attachment class for attaching files to a {@link Swift_Mime_Message}.
|
||||
*
|
||||
* @package Swift
|
||||
* @subpackage Mime
|
||||
* @author Chris Corbyn
|
||||
*/
|
||||
class Swift_Attachment extends Swift_Mime_Attachment
|
||||
|
||||
@@ -11,8 +11,6 @@
|
||||
/**
|
||||
* Provides the base functionality for an InputStream supporting filters.
|
||||
*
|
||||
* @package Swift
|
||||
* @subpackage ByteStream
|
||||
* @author Chris Corbyn
|
||||
*/
|
||||
abstract class Swift_ByteStream_AbstractFilterableInputStream implements Swift_InputByteStream, Swift_Filterable
|
||||
@@ -24,6 +22,8 @@ abstract class Swift_ByteStream_AbstractFilterableInputStream implements Swift_I
|
||||
|
||||
/**
|
||||
* StreamFilters.
|
||||
*
|
||||
* @var Swift_StreamFilter[]
|
||||
*/
|
||||
private $_filters = array();
|
||||
|
||||
@@ -77,9 +77,9 @@ abstract class Swift_ByteStream_AbstractFilterableInputStream implements Swift_I
|
||||
*
|
||||
* @param string $bytes
|
||||
*
|
||||
* @return int
|
||||
*
|
||||
* @throws Swift_IoException
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function write($bytes)
|
||||
{
|
||||
@@ -157,8 +157,6 @@ abstract class Swift_ByteStream_AbstractFilterableInputStream implements Swift_I
|
||||
}
|
||||
}
|
||||
|
||||
// -- Private methods
|
||||
|
||||
/** Run $bytes through all filters */
|
||||
private function _filter($bytes)
|
||||
{
|
||||
|
||||
@@ -11,8 +11,6 @@
|
||||
/**
|
||||
* Allows reading and writing of bytes to and from an array.
|
||||
*
|
||||
* @package Swift
|
||||
* @subpackage ByteStream
|
||||
* @author Chris Corbyn
|
||||
*/
|
||||
class Swift_ByteStream_ArrayByteStream implements Swift_InputByteStream, Swift_OutputByteStream
|
||||
@@ -25,7 +23,7 @@ class Swift_ByteStream_ArrayByteStream implements Swift_InputByteStream, Swift_O
|
||||
private $_array = array();
|
||||
|
||||
/**
|
||||
* The size of the stack
|
||||
* The size of the stack.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
@@ -84,9 +82,7 @@ class Swift_ByteStream_ArrayByteStream implements Swift_InputByteStream, Swift_O
|
||||
|
||||
// Don't use array slice
|
||||
$end = $length + $this->_offset;
|
||||
$end = $this->_arraySize<$end
|
||||
?$this->_arraySize
|
||||
:$end;
|
||||
$end = $this->_arraySize < $end ? $this->_arraySize : $end;
|
||||
$ret = '';
|
||||
for (; $this->_offset < $end; ++$this->_offset) {
|
||||
$ret .= $this->_array[$this->_offset];
|
||||
|
||||
@@ -11,8 +11,6 @@
|
||||
/**
|
||||
* Allows reading and writing of bytes to and from a file.
|
||||
*
|
||||
* @package Swift
|
||||
* @subpackage ByteStream
|
||||
* @author Chris Corbyn
|
||||
*/
|
||||
class Swift_ByteStream_FileByteStream extends Swift_ByteStream_AbstractFilterableInputStream implements Swift_FileStream
|
||||
@@ -77,9 +75,9 @@ class Swift_ByteStream_FileByteStream extends Swift_ByteStream_AbstractFilterabl
|
||||
*
|
||||
* @param int $length
|
||||
*
|
||||
* @return string|bool
|
||||
*
|
||||
* @throws Swift_IoException
|
||||
*
|
||||
* @return string|bool
|
||||
*/
|
||||
public function read($length)
|
||||
{
|
||||
@@ -125,8 +123,6 @@ class Swift_ByteStream_FileByteStream extends Swift_ByteStream_AbstractFilterabl
|
||||
$this->_offset = $byteOffset;
|
||||
}
|
||||
|
||||
// -- Private methods
|
||||
|
||||
/** Just write the bytes to the file */
|
||||
protected function _commit($bytes)
|
||||
{
|
||||
@@ -143,12 +139,14 @@ class Swift_ByteStream_FileByteStream extends Swift_ByteStream_AbstractFilterabl
|
||||
private function _getReadHandle()
|
||||
{
|
||||
if (!isset($this->_reader)) {
|
||||
if (!$this->_reader = fopen($this->_path, 'rb')) {
|
||||
$pointer = @fopen($this->_path, 'rb');
|
||||
if (!$pointer) {
|
||||
throw new Swift_IoException(
|
||||
'Unable to open file for reading ['.$this->_path.']'
|
||||
);
|
||||
}
|
||||
if ($this->_offset <> 0) {
|
||||
$this->_reader = $pointer;
|
||||
if ($this->_offset != 0) {
|
||||
$this->_getReadStreamSeekableStatus();
|
||||
$this->_seekReadStreamToPosition($this->_offset);
|
||||
}
|
||||
|
||||
@@ -9,8 +9,6 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* @package Swift
|
||||
* @subpackage ByteStream
|
||||
* @author Romain-Geissler
|
||||
*/
|
||||
class Swift_ByteStream_TemporaryFileByteStream extends Swift_ByteStream_FileByteStream
|
||||
|
||||
@@ -11,8 +11,6 @@
|
||||
/**
|
||||
* Analyzes characters for a specific character set.
|
||||
*
|
||||
* @package Swift
|
||||
* @subpackage Encoder
|
||||
* @author Chris Corbyn
|
||||
* @author Xavier De Cock <xdecock@gmail.com>
|
||||
*/
|
||||
@@ -23,7 +21,7 @@ interface Swift_CharacterReader
|
||||
const MAP_TYPE_POSITIONS = 0x03;
|
||||
|
||||
/**
|
||||
* Returns the complete character map
|
||||
* Returns the complete character map.
|
||||
*
|
||||
* @param string $string
|
||||
* @param int $startOffset
|
||||
@@ -50,7 +48,7 @@ interface Swift_CharacterReader
|
||||
* A value of zero means this is already a valid character.
|
||||
* A value of -1 means this cannot possibly be a valid character.
|
||||
*
|
||||
* @param integer[] $bytes
|
||||
* @param int[] $bytes
|
||||
* @param int $size
|
||||
*
|
||||
* @return int
|
||||
|
||||
@@ -11,8 +11,6 @@
|
||||
/**
|
||||
* Provides fixed-width byte sizes for reading fixed-width character sets.
|
||||
*
|
||||
* @package Swift
|
||||
* @subpackage Encoder
|
||||
* @author Chris Corbyn
|
||||
* @author Xavier De Cock <xdecock@gmail.com>
|
||||
*/
|
||||
@@ -50,7 +48,7 @@ class Swift_CharacterReader_GenericFixedWidthReader implements Swift_CharacterRe
|
||||
$strlen = strlen($string);
|
||||
// % and / are CPU intensive, so, maybe find a better way
|
||||
$ignored = $strlen % $this->_width;
|
||||
$ignoredChars = substr($string, - $ignored);
|
||||
$ignoredChars = $ignored ? substr($string, -$ignored) : '';
|
||||
$currentMap = $this->_width;
|
||||
|
||||
return ($strlen - $ignored) / $this->_width;
|
||||
@@ -84,7 +82,7 @@ class Swift_CharacterReader_GenericFixedWidthReader implements Swift_CharacterRe
|
||||
{
|
||||
$needed = $this->_width - $size;
|
||||
|
||||
return ($needed > -1) ? $needed : -1;
|
||||
return $needed > -1 ? $needed : -1;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -11,8 +11,6 @@
|
||||
/**
|
||||
* Analyzes US-ASCII characters.
|
||||
*
|
||||
* @package Swift
|
||||
* @subpackage Encoder
|
||||
* @author Chris Corbyn
|
||||
*/
|
||||
class Swift_CharacterReader_UsAsciiReader implements Swift_CharacterReader
|
||||
@@ -32,7 +30,8 @@ class Swift_CharacterReader_UsAsciiReader implements Swift_CharacterReader
|
||||
$strlen = strlen($string);
|
||||
$ignoredChars = '';
|
||||
for ($i = 0; $i < $strlen; ++$i) {
|
||||
if ($string[$i]>"\x07F") { // Invalid char
|
||||
if ($string[$i] > "\x07F") {
|
||||
// Invalid char
|
||||
$currentMap[$i + $startOffset] = $string[$i];
|
||||
}
|
||||
}
|
||||
@@ -41,7 +40,7 @@ class Swift_CharacterReader_UsAsciiReader implements Swift_CharacterReader
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns mapType
|
||||
* Returns mapType.
|
||||
*
|
||||
* @return int mapType
|
||||
*/
|
||||
@@ -68,9 +67,9 @@ class Swift_CharacterReader_UsAsciiReader implements Swift_CharacterReader
|
||||
$byte = reset($bytes);
|
||||
if (1 == count($bytes) && $byte >= 0x00 && $byte <= 0x7F) {
|
||||
return 0;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -11,8 +11,6 @@
|
||||
/**
|
||||
* Analyzes UTF-8 characters.
|
||||
*
|
||||
* @package Swift
|
||||
* @subpackage Encoder
|
||||
* @author Chris Corbyn
|
||||
* @author Xavier De Cock <xdecock@gmail.com>
|
||||
*/
|
||||
@@ -36,7 +34,7 @@ class Swift_CharacterReader_Utf8Reader implements Swift_CharacterReader
|
||||
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, // 0xCN
|
||||
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, // 0xDN
|
||||
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // 0xEN
|
||||
4,4,4,4,4,4,4,4,5,5,5,5,6,6,0,0 // 0xFN
|
||||
4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 0, 0, // 0xFN
|
||||
);
|
||||
|
||||
private static $s_length_map = array(
|
||||
@@ -163,10 +161,7 @@ class Swift_CharacterReader_Utf8Reader implements Swift_CharacterReader
|
||||
}
|
||||
$needed = self::$length_map[$bytes[0]] - $size;
|
||||
|
||||
return ($needed > -1)
|
||||
? $needed
|
||||
: -1
|
||||
;
|
||||
return $needed > -1 ? $needed : -1;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -11,8 +11,6 @@
|
||||
/**
|
||||
* A factory for creating CharacterReaders.
|
||||
*
|
||||
* @package Swift
|
||||
* @subpackage Encoder
|
||||
* @author Chris Corbyn
|
||||
*/
|
||||
interface Swift_CharacterReaderFactory
|
||||
|
||||
@@ -11,8 +11,6 @@
|
||||
/**
|
||||
* Standard factory for creating CharacterReaders.
|
||||
*
|
||||
* @package Swift
|
||||
* @subpackage Encoder
|
||||
* @author Chris Corbyn
|
||||
*/
|
||||
class Swift_CharacterReaderFactory_SimpleCharacterReaderFactory implements Swift_CharacterReaderFactory
|
||||
@@ -54,23 +52,23 @@ class Swift_CharacterReaderFactory_SimpleCharacterReaderFactory implements Swift
|
||||
|
||||
$singleByte = array(
|
||||
'class' => $prefix.'GenericFixedWidthReader',
|
||||
'constructor' => array(1)
|
||||
'constructor' => array(1),
|
||||
);
|
||||
|
||||
$doubleByte = array(
|
||||
'class' => $prefix.'GenericFixedWidthReader',
|
||||
'constructor' => array(2)
|
||||
'constructor' => array(2),
|
||||
);
|
||||
|
||||
$fourBytes = array(
|
||||
'class' => $prefix.'GenericFixedWidthReader',
|
||||
'constructor' => array(4)
|
||||
'constructor' => array(4),
|
||||
);
|
||||
|
||||
// Utf-8
|
||||
self::$_map['utf-?8'] = array(
|
||||
'class' => $prefix.'Utf8Reader',
|
||||
'constructor' => array()
|
||||
'constructor' => array(),
|
||||
);
|
||||
|
||||
//7-8 bit charsets
|
||||
|
||||
@@ -15,8 +15,6 @@
|
||||
* Classes implementing this interface may use a subsystem which requires less
|
||||
* memory than working with large strings of data.
|
||||
*
|
||||
* @package Swift
|
||||
* @subpackage CharacterStream
|
||||
* @author Chris Corbyn
|
||||
*/
|
||||
interface Swift_CharacterStream
|
||||
|
||||
@@ -11,8 +11,6 @@
|
||||
/**
|
||||
* A CharacterStream implementation which stores characters in an internal array.
|
||||
*
|
||||
* @package Swift
|
||||
* @subpackage CharacterStream
|
||||
* @author Chris Corbyn
|
||||
*/
|
||||
class Swift_CharacterStream_ArrayCharacterStream implements Swift_CharacterStream
|
||||
@@ -97,8 +95,7 @@ class Swift_CharacterStream_ArrayCharacterStream implements Swift_CharacterStrea
|
||||
$need = $this->_charReader
|
||||
->validateByteSequence($c, $size);
|
||||
if ($need > 0 &&
|
||||
false !== $bytes = $os->read($need))
|
||||
{
|
||||
false !== $bytes = $os->read($need)) {
|
||||
for ($i = 0, $len = strlen($bytes); $i < $len; ++$i) {
|
||||
$c[] = self::$_byteMap[$bytes[$i]];
|
||||
}
|
||||
@@ -158,7 +155,7 @@ class Swift_CharacterStream_ArrayCharacterStream implements Swift_CharacterStrea
|
||||
*
|
||||
* @param int $length
|
||||
*
|
||||
* @return integer[]
|
||||
* @return int[]
|
||||
*/
|
||||
public function readBytes($length)
|
||||
{
|
||||
|
||||
@@ -11,11 +11,8 @@
|
||||
/**
|
||||
* A CharacterStream implementation which stores characters in an internal array.
|
||||
*
|
||||
* @package Swift
|
||||
* @subpackage CharacterStream
|
||||
* @author Xavier De Cock <xdecock@gmail.com>
|
||||
*/
|
||||
|
||||
class Swift_CharacterStream_NgCharacterStream implements Swift_CharacterStream
|
||||
{
|
||||
/**
|
||||
@@ -47,7 +44,7 @@ class Swift_CharacterStream_NgCharacterStream implements Swift_CharacterStream
|
||||
private $_datas = '';
|
||||
|
||||
/**
|
||||
* Number of bytes in the stream
|
||||
* Number of bytes in the stream.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
@@ -139,9 +136,10 @@ class Swift_CharacterStream_NgCharacterStream implements Swift_CharacterStream
|
||||
$this->flushContents();
|
||||
$blocks = 512;
|
||||
$os->setReadPointer(0);
|
||||
while(false!==($read = $os->read($blocks)))
|
||||
while (false !== ($read = $os->read($blocks))) {
|
||||
$this->write($read);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Swift_CharacterStream::importString()
|
||||
@@ -167,9 +165,7 @@ class Swift_CharacterStream_NgCharacterStream implements Swift_CharacterStream
|
||||
return false;
|
||||
}
|
||||
$ret = false;
|
||||
$length = ($this->_currentPos+$length > $this->_charCount)
|
||||
? $this->_charCount - $this->_currentPos
|
||||
: $length;
|
||||
$length = $this->_currentPos + $length > $this->_charCount ? $this->_charCount - $this->_currentPos : $length;
|
||||
switch ($this->_mapType) {
|
||||
case Swift_CharacterReader::MAP_TYPE_FIXED_LEN:
|
||||
$len = $length * $this->_map;
|
||||
@@ -180,10 +176,6 @@ class Swift_CharacterStream_NgCharacterStream implements Swift_CharacterStream
|
||||
break;
|
||||
|
||||
case Swift_CharacterReader::MAP_TYPE_INVALID:
|
||||
$end = $this->_currentPos + $length;
|
||||
$end = $end > $this->_charCount
|
||||
?$this->_charCount
|
||||
:$end;
|
||||
$ret = '';
|
||||
for (; $this->_currentPos < $length; ++$this->_currentPos) {
|
||||
if (isset($this->_map[$this->_currentPos])) {
|
||||
@@ -196,9 +188,7 @@ class Swift_CharacterStream_NgCharacterStream implements Swift_CharacterStream
|
||||
|
||||
case Swift_CharacterReader::MAP_TYPE_POSITIONS:
|
||||
$end = $this->_currentPos + $length;
|
||||
$end = $end > $this->_charCount
|
||||
?$this->_charCount
|
||||
:$end;
|
||||
$end = $end > $this->_charCount ? $this->_charCount : $end;
|
||||
$ret = '';
|
||||
$start = 0;
|
||||
if ($this->_currentPos > 0) {
|
||||
@@ -225,7 +215,7 @@ class Swift_CharacterStream_NgCharacterStream implements Swift_CharacterStream
|
||||
*
|
||||
* @param int $length
|
||||
*
|
||||
* @return integer[]
|
||||
* @return int[]
|
||||
*/
|
||||
public function readBytes($length)
|
||||
{
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
/**
|
||||
* Base class for Spools (implements time and message limits).
|
||||
*
|
||||
* @package Swift
|
||||
* @author Fabien Potencier
|
||||
*/
|
||||
abstract class Swift_ConfigurableSpool implements Swift_Spool
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
/**
|
||||
* Dependency Injection container.
|
||||
*
|
||||
* @package Swift
|
||||
* @author Chris Corbyn
|
||||
*/
|
||||
class Swift_DependencyContainer
|
||||
@@ -42,12 +41,14 @@ class Swift_DependencyContainer
|
||||
*
|
||||
* Use {@link getInstance()} instead.
|
||||
*/
|
||||
public function __construct() { }
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a singleton of the DependencyContainer.
|
||||
*
|
||||
* @return Swift_DependencyContainer
|
||||
* @return self
|
||||
*/
|
||||
public static function getInstance()
|
||||
{
|
||||
@@ -90,9 +91,9 @@ class Swift_DependencyContainer
|
||||
*
|
||||
* @param string $itemName
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws Swift_DependencyException If the dependency is not found
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function lookup($itemName)
|
||||
{
|
||||
@@ -137,11 +138,12 @@ class Swift_DependencyContainer
|
||||
* This method returns the current DependencyContainer instance because it
|
||||
* requires the use of the fluid interface to set the specific details for the
|
||||
* dependency.
|
||||
*
|
||||
* @see asNewInstanceOf(), asSharedInstanceOf(), asValue()
|
||||
*
|
||||
* @param string $itemName
|
||||
*
|
||||
* @return Swift_DependencyContainer
|
||||
* @return $this
|
||||
*/
|
||||
public function register($itemName)
|
||||
{
|
||||
@@ -158,7 +160,7 @@ class Swift_DependencyContainer
|
||||
*
|
||||
* @param mixed $value
|
||||
*
|
||||
* @return Swift_DependencyContainer
|
||||
* @return $this
|
||||
*/
|
||||
public function asValue($value)
|
||||
{
|
||||
@@ -174,7 +176,7 @@ class Swift_DependencyContainer
|
||||
*
|
||||
* @param string $lookup
|
||||
*
|
||||
* @return Swift_DependencyContainer
|
||||
* @return $this
|
||||
*/
|
||||
public function asAliasOf($lookup)
|
||||
{
|
||||
@@ -196,7 +198,7 @@ class Swift_DependencyContainer
|
||||
*
|
||||
* @param string $className
|
||||
*
|
||||
* @return Swift_DependencyContainer
|
||||
* @return $this
|
||||
*/
|
||||
public function asNewInstanceOf($className)
|
||||
{
|
||||
@@ -214,7 +216,7 @@ class Swift_DependencyContainer
|
||||
*
|
||||
* @param string $className
|
||||
*
|
||||
* @return Swift_DependencyContainer
|
||||
* @return $this
|
||||
*/
|
||||
public function asSharedInstanceOf($className)
|
||||
{
|
||||
@@ -234,7 +236,7 @@ class Swift_DependencyContainer
|
||||
*
|
||||
* @param array $lookups
|
||||
*
|
||||
* @return Swift_DependencyContainer
|
||||
* @return $this
|
||||
*/
|
||||
public function withDependencies(array $lookups)
|
||||
{
|
||||
@@ -255,7 +257,7 @@ class Swift_DependencyContainer
|
||||
*
|
||||
* @param mixed $value
|
||||
*
|
||||
* @return Swift_DependencyContainer
|
||||
* @return $this
|
||||
*/
|
||||
public function addConstructorValue($value)
|
||||
{
|
||||
@@ -276,7 +278,7 @@ class Swift_DependencyContainer
|
||||
*
|
||||
* @param string $lookup
|
||||
*
|
||||
* @return Swift_DependencyContainer
|
||||
* @return $this
|
||||
*/
|
||||
public function addConstructorLookup($lookup)
|
||||
{
|
||||
@@ -289,8 +291,6 @@ class Swift_DependencyContainer
|
||||
return $this;
|
||||
}
|
||||
|
||||
// -- Private methods
|
||||
|
||||
/** Get the literal value with $itemName */
|
||||
private function _getValue($itemName)
|
||||
{
|
||||
@@ -311,9 +311,9 @@ class Swift_DependencyContainer
|
||||
return $reflector->newInstanceArgs(
|
||||
$this->createDependenciesFor($itemName)
|
||||
);
|
||||
} else {
|
||||
return $reflector->newInstance();
|
||||
}
|
||||
|
||||
return $reflector->newInstance();
|
||||
}
|
||||
|
||||
/** Create and register a shared instance of $itemName */
|
||||
@@ -366,8 +366,8 @@ class Swift_DependencyContainer
|
||||
}
|
||||
|
||||
return $collection;
|
||||
} else {
|
||||
}
|
||||
|
||||
return $this->lookup($item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
/**
|
||||
* DependencyException gets thrown when a requested dependency is missing.
|
||||
*
|
||||
* @package Swift
|
||||
* @author Chris Corbyn
|
||||
*/
|
||||
class Swift_DependencyException extends Swift_SwiftException
|
||||
|
||||
@@ -11,8 +11,6 @@
|
||||
/**
|
||||
* An embedded file, in a multipart message.
|
||||
*
|
||||
* @package Swift
|
||||
* @subpackage Mime
|
||||
* @author Chris Corbyn
|
||||
*/
|
||||
class Swift_EmbeddedFile extends Swift_Mime_EmbeddedFile
|
||||
|
||||
@@ -10,8 +10,7 @@
|
||||
|
||||
/**
|
||||
* Interface for all Encoder schemes.
|
||||
* @package Swift
|
||||
* @subpackage Encoder
|
||||
*
|
||||
* @author Chris Corbyn
|
||||
*/
|
||||
interface Swift_Encoder extends Swift_Mime_CharsetObserver
|
||||
|
||||
@@ -11,8 +11,6 @@
|
||||
/**
|
||||
* Handles Base 64 Encoding in Swift Mailer.
|
||||
*
|
||||
* @package Swift
|
||||
* @subpackage Encoder
|
||||
* @author Chris Corbyn
|
||||
*/
|
||||
class Swift_Encoder_Base64Encoder implements Swift_Encoder
|
||||
|
||||
@@ -13,8 +13,6 @@
|
||||
*
|
||||
* Possibly the most accurate RFC 2045 QP implementation found in PHP.
|
||||
*
|
||||
* @package Swift
|
||||
* @subpackage Encoder
|
||||
* @author Chris Corbyn
|
||||
*/
|
||||
class Swift_Encoder_QpEncoder implements Swift_Encoder
|
||||
@@ -90,7 +88,7 @@ class Swift_Encoder_QpEncoder implements Swift_Encoder
|
||||
240 => '=F0', 241 => '=F1', 242 => '=F2', 243 => '=F3', 244 => '=F4',
|
||||
245 => '=F5', 246 => '=F6', 247 => '=F7', 248 => '=F8', 249 => '=F9',
|
||||
250 => '=FA', 251 => '=FB', 252 => '=FC', 253 => '=FD', 254 => '=FE',
|
||||
255 => '=FF'
|
||||
255 => '=FF',
|
||||
);
|
||||
|
||||
protected static $_safeMapShare = array();
|
||||
@@ -143,8 +141,7 @@ class Swift_Encoder_QpEncoder implements Swift_Encoder
|
||||
protected function initSafeMap()
|
||||
{
|
||||
foreach (array_merge(
|
||||
array(0x09, 0x20), range(0x21, 0x3C), range(0x3E, 0x7E)) as $byte)
|
||||
{
|
||||
array(0x09, 0x20), range(0x21, 0x3C), range(0x3E, 0x7E)) as $byte) {
|
||||
$this->_safeMap[$byte] = chr($byte);
|
||||
}
|
||||
}
|
||||
@@ -201,14 +198,25 @@ class Swift_Encoder_QpEncoder implements Swift_Encoder
|
||||
}
|
||||
|
||||
$enc = $this->_encodeByteSequence($bytes, $size);
|
||||
if ($currentLine && $lineLen+$size >= $thisLineLength) {
|
||||
|
||||
$i = strpos($enc, '=0D=0A');
|
||||
$newLineLength = $lineLen + ($i === false ? $size : $i);
|
||||
|
||||
if ($currentLine && $newLineLength >= $thisLineLength) {
|
||||
$lines[$lNo] = '';
|
||||
$currentLine = &$lines[$lNo++];
|
||||
$thisLineLength = $maxLineLength;
|
||||
$lineLen = 0;
|
||||
}
|
||||
$lineLen+=$size;
|
||||
|
||||
$currentLine .= $enc;
|
||||
|
||||
if ($i === false) {
|
||||
$lineLen += $size;
|
||||
} else {
|
||||
// 6 is the length of '=0D=0A'.
|
||||
$lineLen = $size - strrpos($enc, '=0D=0A') - 6;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->_standardize(implode("=\r\n", $lines));
|
||||
@@ -224,12 +232,10 @@ class Swift_Encoder_QpEncoder implements Swift_Encoder
|
||||
$this->_charStream->setCharacterSet($charset);
|
||||
}
|
||||
|
||||
// -- Protected methods
|
||||
|
||||
/**
|
||||
* Encode the given byte array into a verbatim QP form.
|
||||
*
|
||||
* @param integer[] $bytes
|
||||
* @param int[] $bytes
|
||||
* @param int $size
|
||||
*
|
||||
* @return string
|
||||
@@ -256,7 +262,7 @@ class Swift_Encoder_QpEncoder implements Swift_Encoder
|
||||
*
|
||||
* @param int $size number of bytes to read
|
||||
*
|
||||
* @return integer[]
|
||||
* @return int[]
|
||||
*/
|
||||
protected function _nextSequence($size = 4)
|
||||
{
|
||||
@@ -272,7 +278,7 @@ class Swift_Encoder_QpEncoder implements Swift_Encoder
|
||||
*/
|
||||
protected function _standardize($string)
|
||||
{
|
||||
$string = str_replace(array("\t=0D=0A", " =0D=0A", "=0D=0A"),
|
||||
$string = str_replace(array("\t=0D=0A", ' =0D=0A', '=0D=0A'),
|
||||
array("=09\r\n", "=20\r\n", "\r\n"), $string
|
||||
);
|
||||
switch ($end = ord(substr($string, -1))) {
|
||||
@@ -283,4 +289,12 @@ class Swift_Encoder_QpEncoder implements Swift_Encoder
|
||||
|
||||
return $string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a deep copy of object.
|
||||
*/
|
||||
public function __clone()
|
||||
{
|
||||
$this->_charStream = clone $this->_charStream;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,8 +11,6 @@
|
||||
/**
|
||||
* Handles RFC 2231 specified Encoding in Swift Mailer.
|
||||
*
|
||||
* @package Swift
|
||||
* @subpackage Encoder
|
||||
* @author Chris Corbyn
|
||||
*/
|
||||
class Swift_Encoder_Rfc2231Encoder implements Swift_Encoder
|
||||
@@ -46,7 +44,8 @@ class Swift_Encoder_Rfc2231Encoder implements Swift_Encoder
|
||||
*/
|
||||
public function encodeString($string, $firstLineOffset = 0, $maxLineLength = 0)
|
||||
{
|
||||
$lines = array(); $lineCount = 0;
|
||||
$lines = array();
|
||||
$lineCount = 0;
|
||||
$lines[] = '';
|
||||
$currentLine = &$lines[$lineCount++];
|
||||
|
||||
@@ -62,8 +61,7 @@ class Swift_Encoder_Rfc2231Encoder implements Swift_Encoder
|
||||
while (false !== $char = $this->_charStream->read(4)) {
|
||||
$encodedChar = rawurlencode($char);
|
||||
if (0 != strlen($currentLine)
|
||||
&& strlen($currentLine . $encodedChar) > $thisLineLength)
|
||||
{
|
||||
&& strlen($currentLine.$encodedChar) > $thisLineLength) {
|
||||
$lines[] = '';
|
||||
$currentLine = &$lines[$lineCount++];
|
||||
$thisLineLength = $maxLineLength;
|
||||
@@ -83,4 +81,12 @@ class Swift_Encoder_Rfc2231Encoder implements Swift_Encoder
|
||||
{
|
||||
$this->_charStream->setCharacterSet($charset);
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a deep copy of object.
|
||||
*/
|
||||
public function __clone()
|
||||
{
|
||||
$this->_charStream = clone $this->_charStream;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,8 +11,6 @@
|
||||
/**
|
||||
* Provides quick access to each encoding type.
|
||||
*
|
||||
* @package Swift
|
||||
* @subpackage Encoder
|
||||
* @author Chris Corbyn
|
||||
*/
|
||||
class Swift_Encoding
|
||||
@@ -57,8 +55,6 @@ class Swift_Encoding
|
||||
return self::_lookup('mime.base64contentencoder');
|
||||
}
|
||||
|
||||
// -- Private Static Methods
|
||||
|
||||
private static function _lookup($key)
|
||||
{
|
||||
return Swift_DependencyContainer::getInstance()->lookup($key);
|
||||
|
||||
@@ -11,8 +11,6 @@
|
||||
/**
|
||||
* Generated when a command is sent over an SMTP connection.
|
||||
*
|
||||
* @package Swift
|
||||
* @subpackage Events
|
||||
* @author Chris Corbyn
|
||||
*/
|
||||
class Swift_Events_CommandEvent extends Swift_Events_EventObject
|
||||
@@ -27,7 +25,7 @@ class Swift_Events_CommandEvent extends Swift_Events_EventObject
|
||||
/**
|
||||
* An array of codes which a successful response will contain.
|
||||
*
|
||||
* @var integer[]
|
||||
* @var int[]
|
||||
*/
|
||||
private $_successCodes = array();
|
||||
|
||||
@@ -58,7 +56,7 @@ class Swift_Events_CommandEvent extends Swift_Events_EventObject
|
||||
/**
|
||||
* Get the numeric response codes which indicate success for this command.
|
||||
*
|
||||
* @return integer[]
|
||||
* @return int[]
|
||||
*/
|
||||
public function getSuccessCodes()
|
||||
{
|
||||
|
||||
@@ -11,8 +11,6 @@
|
||||
/**
|
||||
* Listens for Transports to send commands to the server.
|
||||
*
|
||||
* @package Swift
|
||||
* @subpackage Events
|
||||
* @author Chris Corbyn
|
||||
*/
|
||||
interface Swift_Events_CommandListener extends Swift_Events_EventListener
|
||||
|
||||
@@ -11,8 +11,6 @@
|
||||
/**
|
||||
* The minimum interface for an Event.
|
||||
*
|
||||
* @package Swift
|
||||
* @subpackage Events
|
||||
* @author Chris Corbyn
|
||||
*/
|
||||
interface Swift_Events_Event
|
||||
|
||||
@@ -11,8 +11,6 @@
|
||||
/**
|
||||
* Interface for the EventDispatcher which handles the event dispatching layer.
|
||||
*
|
||||
* @package Swift
|
||||
* @subpackage Events
|
||||
* @author Chris Corbyn
|
||||
*/
|
||||
interface Swift_Events_EventDispatcher
|
||||
|
||||
@@ -11,8 +11,6 @@
|
||||
/**
|
||||
* An identity interface which all EventListeners must extend.
|
||||
*
|
||||
* @package Swift
|
||||
* @subpackage Events
|
||||
* @author Chris Corbyn
|
||||
*/
|
||||
interface Swift_Events_EventListener
|
||||
|
||||
@@ -11,8 +11,6 @@
|
||||
/**
|
||||
* A base Event which all Event classes inherit from.
|
||||
*
|
||||
* @package Swift
|
||||
* @subpackage Events
|
||||
* @author Chris Corbyn
|
||||
*/
|
||||
class Swift_Events_EventObject implements Swift_Events_Event
|
||||
|
||||
@@ -11,8 +11,6 @@
|
||||
/**
|
||||
* Generated when a response is received on a SMTP connection.
|
||||
*
|
||||
* @package Swift
|
||||
* @subpackage Events
|
||||
* @author Chris Corbyn
|
||||
*/
|
||||
class Swift_Events_ResponseEvent extends Swift_Events_EventObject
|
||||
@@ -64,5 +62,4 @@ class Swift_Events_ResponseEvent extends Swift_Events_EventObject
|
||||
{
|
||||
return $this->_valid;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -11,8 +11,6 @@
|
||||
/**
|
||||
* Listens for responses from a remote SMTP server.
|
||||
*
|
||||
* @package Swift
|
||||
* @subpackage Events
|
||||
* @author Chris Corbyn
|
||||
*/
|
||||
interface Swift_Events_ResponseListener extends Swift_Events_EventListener
|
||||
|
||||
@@ -11,8 +11,6 @@
|
||||
/**
|
||||
* Generated when a message is being sent.
|
||||
*
|
||||
* @package Swift
|
||||
* @subpackage Events
|
||||
* @author Chris Corbyn
|
||||
*/
|
||||
class Swift_Events_SendEvent extends Swift_Events_EventObject
|
||||
@@ -20,6 +18,9 @@ class Swift_Events_SendEvent extends Swift_Events_EventObject
|
||||
/** Sending has yet to occur */
|
||||
const RESULT_PENDING = 0x0001;
|
||||
|
||||
/** Email is spooled, ready to be sent */
|
||||
const RESULT_SPOOLED = 0x0011;
|
||||
|
||||
/** Sending was successful */
|
||||
const RESULT_SUCCESS = 0x0010;
|
||||
|
||||
|
||||
@@ -11,8 +11,6 @@
|
||||
/**
|
||||
* Listens for Messages being sent from within the Transport system.
|
||||
*
|
||||
* @package Swift
|
||||
* @subpackage Events
|
||||
* @author Chris Corbyn
|
||||
*/
|
||||
interface Swift_Events_SendListener extends Swift_Events_EventListener
|
||||
|
||||
@@ -11,8 +11,6 @@
|
||||
/**
|
||||
* The EventDispatcher which handles the event dispatching layer.
|
||||
*
|
||||
* @package Swift
|
||||
* @subpackage Events
|
||||
* @author Chris Corbyn
|
||||
*/
|
||||
class Swift_Events_SimpleEventDispatcher implements Swift_Events_EventDispatcher
|
||||
@@ -36,7 +34,7 @@ class Swift_Events_SimpleEventDispatcher implements Swift_Events_EventDispatcher
|
||||
'Swift_Events_ResponseEvent' => 'Swift_Events_ResponseListener',
|
||||
'Swift_Events_SendEvent' => 'Swift_Events_SendListener',
|
||||
'Swift_Events_TransportChangeEvent' => 'Swift_Events_TransportChangeListener',
|
||||
'Swift_Events_TransportExceptionEvent' => 'Swift_Events_TransportExceptionListener'
|
||||
'Swift_Events_TransportExceptionEvent' => 'Swift_Events_TransportExceptionListener',
|
||||
);
|
||||
}
|
||||
|
||||
@@ -134,8 +132,6 @@ class Swift_Events_SimpleEventDispatcher implements Swift_Events_EventDispatcher
|
||||
$this->_bubble($evt, $target);
|
||||
}
|
||||
|
||||
// -- Private methods
|
||||
|
||||
/** Queue listeners on a stack ready for $evt to be bubbled up it */
|
||||
private function _prepareBubbleQueue(Swift_Events_EventObject $evt)
|
||||
{
|
||||
@@ -143,8 +139,7 @@ class Swift_Events_SimpleEventDispatcher implements Swift_Events_EventDispatcher
|
||||
$evtClass = get_class($evt);
|
||||
foreach ($this->_listeners as $listener) {
|
||||
if (array_key_exists($evtClass, $this->_eventMap)
|
||||
&& ($listener instanceof $this->_eventMap[$evtClass]))
|
||||
{
|
||||
&& ($listener instanceof $this->_eventMap[$evtClass])) {
|
||||
$this->_bubbleQueue[] = $listener;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,8 +11,6 @@
|
||||
/**
|
||||
* Generated when the state of a Transport is changed (i.e. stopped/started).
|
||||
*
|
||||
* @package Swift
|
||||
* @subpackage Events
|
||||
* @author Chris Corbyn
|
||||
*/
|
||||
class Swift_Events_TransportChangeEvent extends Swift_Events_EventObject
|
||||
|
||||
@@ -11,8 +11,6 @@
|
||||
/**
|
||||
* Listens for changes within the Transport system.
|
||||
*
|
||||
* @package Swift
|
||||
* @subpackage Events
|
||||
* @author Chris Corbyn
|
||||
*/
|
||||
interface Swift_Events_TransportChangeListener extends Swift_Events_EventListener
|
||||
|
||||
@@ -11,8 +11,6 @@
|
||||
/**
|
||||
* Generated when a TransportException is thrown from the Transport system.
|
||||
*
|
||||
* @package Swift
|
||||
* @subpackage Events
|
||||
* @author Chris Corbyn
|
||||
*/
|
||||
class Swift_Events_TransportExceptionEvent extends Swift_Events_EventObject
|
||||
|
||||
@@ -11,8 +11,6 @@
|
||||
/**
|
||||
* Listens for Exceptions thrown from within the Transport system.
|
||||
*
|
||||
* @package Swift
|
||||
* @subpackage Events
|
||||
* @author Chris Corbyn
|
||||
*/
|
||||
interface Swift_Events_TransportExceptionListener extends Swift_Events_EventListener
|
||||
|
||||
@@ -11,8 +11,6 @@
|
||||
/**
|
||||
* Contains a list of redundant Transports so when one fails, the next is used.
|
||||
*
|
||||
* @package Swift
|
||||
* @subpackage Transport
|
||||
* @author Chris Corbyn
|
||||
*/
|
||||
class Swift_FailoverTransport extends Swift_Transport_FailoverTransport
|
||||
@@ -38,7 +36,7 @@ class Swift_FailoverTransport extends Swift_Transport_FailoverTransport
|
||||
*
|
||||
* @param Swift_Transport[] $transports
|
||||
*
|
||||
* @return Swift_FailoverTransport
|
||||
* @return self
|
||||
*/
|
||||
public static function newInstance($transports = array())
|
||||
{
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
/**
|
||||
* Stores Messages on the filesystem.
|
||||
*
|
||||
* @package Swift
|
||||
* @author Fabien Potencier
|
||||
* @author Xavier De Cock <xdecock@gmail.com>
|
||||
*/
|
||||
@@ -21,7 +20,7 @@ class Swift_FileSpool extends Swift_ConfigurableSpool
|
||||
private $_path;
|
||||
|
||||
/**
|
||||
* File WriteRetry Limit
|
||||
* File WriteRetry Limit.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
@@ -40,7 +39,7 @@ class Swift_FileSpool extends Swift_ConfigurableSpool
|
||||
|
||||
if (!file_exists($this->_path)) {
|
||||
if (!mkdir($this->_path, 0777, true)) {
|
||||
throw new Swift_IoException('Unable to create Path ['.$this->_path.']');
|
||||
throw new Swift_IoException(sprintf('Unable to create path "%s".', $this->_path));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -86,9 +85,9 @@ class Swift_FileSpool extends Swift_ConfigurableSpool
|
||||
*
|
||||
* @param Swift_Mime_Message $message The message to store
|
||||
*
|
||||
* @return bool
|
||||
*
|
||||
* @throws Swift_IoException
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function queueMessage(Swift_Mime_Message $message)
|
||||
{
|
||||
@@ -109,7 +108,7 @@ class Swift_FileSpool extends Swift_ConfigurableSpool
|
||||
}
|
||||
}
|
||||
|
||||
throw new Swift_IoException('Unable to create a file for enqueuing Message');
|
||||
throw new Swift_IoException(sprintf('Unable to create a file for enqueuing Message in "%s".', $this->_path));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -197,7 +196,7 @@ class Swift_FileSpool extends Swift_ConfigurableSpool
|
||||
protected function getRandomString($count)
|
||||
{
|
||||
// This string MUST stay FS safe, avoid special chars
|
||||
$base = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-.";
|
||||
$base = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-';
|
||||
$ret = '';
|
||||
$strlen = strlen($base);
|
||||
for ($i = 0; $i < $count; ++$i) {
|
||||
|
||||
@@ -11,8 +11,6 @@
|
||||
/**
|
||||
* An OutputByteStream which specifically reads from a file.
|
||||
*
|
||||
* @package Swift
|
||||
* @subpackage ByteStream
|
||||
* @author Chris Corbyn
|
||||
*/
|
||||
interface Swift_FileStream extends Swift_OutputByteStream
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
/**
|
||||
* Allows StreamFilters to operate on a stream.
|
||||
*
|
||||
* @package Swift
|
||||
* @author Chris Corbyn
|
||||
*/
|
||||
interface Swift_Filterable
|
||||
|
||||
@@ -11,8 +11,6 @@
|
||||
/**
|
||||
* An image, embedded in a multipart message.
|
||||
*
|
||||
* @package Swift
|
||||
* @subpackage Mime
|
||||
* @author Chris Corbyn
|
||||
*/
|
||||
class Swift_Image extends Swift_EmbeddedFile
|
||||
@@ -38,7 +36,7 @@ class Swift_Image extends Swift_EmbeddedFile
|
||||
* @param string $filename
|
||||
* @param string $contentType
|
||||
*
|
||||
* @return Swift_Image
|
||||
* @return self
|
||||
*/
|
||||
public static function newInstance($data = null, $filename = null, $contentType = null)
|
||||
{
|
||||
@@ -50,14 +48,10 @@ class Swift_Image extends Swift_EmbeddedFile
|
||||
*
|
||||
* @param string $path
|
||||
*
|
||||
* @return Swift_Image
|
||||
* @return self
|
||||
*/
|
||||
public static function fromPath($path)
|
||||
{
|
||||
$image = self::newInstance()->setFile(
|
||||
new Swift_ByteStream_FileByteStream($path)
|
||||
);
|
||||
|
||||
return $image;
|
||||
return self::newInstance()->setFile(new Swift_ByteStream_FileByteStream($path));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,8 +14,6 @@
|
||||
* Classes implementing this interface may use a subsystem which requires less
|
||||
* memory than working with large strings of data.
|
||||
*
|
||||
* @package Swift
|
||||
* @subpackage ByteStream
|
||||
* @author Chris Corbyn
|
||||
*/
|
||||
interface Swift_InputByteStream
|
||||
@@ -32,9 +30,9 @@ interface Swift_InputByteStream
|
||||
*
|
||||
* @param string $bytes
|
||||
*
|
||||
* @return int
|
||||
*
|
||||
* @throws Swift_IoException
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function write($bytes);
|
||||
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
/**
|
||||
* I/O Exception class.
|
||||
*
|
||||
* @package Swift
|
||||
* @author Chris Corbyn
|
||||
*/
|
||||
class Swift_IoException extends Swift_SwiftException
|
||||
@@ -20,9 +19,11 @@ class Swift_IoException extends Swift_SwiftException
|
||||
* Create a new IoException with $message.
|
||||
*
|
||||
* @param string $message
|
||||
* @param int $code
|
||||
* @param Exception $previous
|
||||
*/
|
||||
public function __construct($message)
|
||||
public function __construct($message, $code = 0, Exception $previous = null)
|
||||
{
|
||||
parent::__construct($message);
|
||||
parent::__construct($message, $code, $previous);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,8 +11,6 @@
|
||||
/**
|
||||
* Provides a mechanism for storing data using two keys.
|
||||
*
|
||||
* @package Swift
|
||||
* @subpackage KeyCache
|
||||
* @author Chris Corbyn
|
||||
*/
|
||||
interface Swift_KeyCache
|
||||
|
||||
@@ -11,8 +11,6 @@
|
||||
/**
|
||||
* A basic KeyCache backed by an array.
|
||||
*
|
||||
* @package Swift
|
||||
* @subpackage KeyCache
|
||||
* @author Chris Corbyn
|
||||
*/
|
||||
class Swift_KeyCache_ArrayKeyCache implements Swift_KeyCache
|
||||
@@ -194,8 +192,6 @@ class Swift_KeyCache_ArrayKeyCache implements Swift_KeyCache
|
||||
unset($this->_contents[$nsKey]);
|
||||
}
|
||||
|
||||
// -- Private methods
|
||||
|
||||
/**
|
||||
* Initialize the namespace of $nsKey if needed.
|
||||
*
|
||||
|
||||
@@ -11,8 +11,6 @@
|
||||
/**
|
||||
* A KeyCache which streams to and from disk.
|
||||
*
|
||||
* @package Swift
|
||||
* @subpackage KeyCache
|
||||
* @author Chris Corbyn
|
||||
*/
|
||||
class Swift_KeyCache_DiskKeyCache implements Swift_KeyCache
|
||||
@@ -169,9 +167,9 @@ class Swift_KeyCache_DiskKeyCache implements Swift_KeyCache
|
||||
* @param string $nsKey
|
||||
* @param string $itemKey
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @throws Swift_IoException
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getString($nsKey, $itemKey)
|
||||
{
|
||||
@@ -263,8 +261,6 @@ class Swift_KeyCache_DiskKeyCache implements Swift_KeyCache
|
||||
}
|
||||
}
|
||||
|
||||
// -- Private methods
|
||||
|
||||
/**
|
||||
* Initialize the namespace of $nsKey if needed.
|
||||
*
|
||||
@@ -293,10 +289,7 @@ class Swift_KeyCache_DiskKeyCache implements Swift_KeyCache
|
||||
private function _getHandle($nsKey, $itemKey, $position)
|
||||
{
|
||||
if (!isset($this->_keys[$nsKey][$itemKey])) {
|
||||
$openMode = $this->hasKey($nsKey, $itemKey)
|
||||
? 'r+b'
|
||||
: 'w+b'
|
||||
;
|
||||
$openMode = $this->hasKey($nsKey, $itemKey) ? 'r+b' : 'w+b';
|
||||
$fp = fopen($this->_path.'/'.$nsKey.'/'.$itemKey, $openMode);
|
||||
$this->_keys[$nsKey][$itemKey] = $fp;
|
||||
}
|
||||
|
||||
@@ -11,8 +11,6 @@
|
||||
/**
|
||||
* Writes data to a KeyCache using a stream.
|
||||
*
|
||||
* @package Swift
|
||||
* @subpackage KeyCache
|
||||
* @author Chris Corbyn
|
||||
*/
|
||||
interface Swift_KeyCache_KeyCacheInputStream extends Swift_InputByteStream
|
||||
|
||||
@@ -11,8 +11,6 @@
|
||||
/**
|
||||
* A null KeyCache that does not cache at all.
|
||||
*
|
||||
* @package Swift
|
||||
* @subpackage KeyCache
|
||||
* @author Chris Corbyn
|
||||
*/
|
||||
class Swift_KeyCache_NullKeyCache implements Swift_KeyCache
|
||||
|
||||
@@ -11,8 +11,6 @@
|
||||
/**
|
||||
* Writes data to a KeyCache using a stream.
|
||||
*
|
||||
* @package Swift
|
||||
* @subpackage KeyCache
|
||||
* @author Chris Corbyn
|
||||
*/
|
||||
class Swift_KeyCache_SimpleKeyCacheInputStream implements Swift_KeyCache_KeyCacheInputStream
|
||||
|
||||
@@ -11,8 +11,6 @@
|
||||
/**
|
||||
* Redundantly and rotationally uses several Transport implementations when sending.
|
||||
*
|
||||
* @package Swift
|
||||
* @subpackage Transport
|
||||
* @author Chris Corbyn
|
||||
*/
|
||||
class Swift_LoadBalancedTransport extends Swift_Transport_LoadBalancedTransport
|
||||
@@ -38,7 +36,7 @@ class Swift_LoadBalancedTransport extends Swift_Transport_LoadBalancedTransport
|
||||
*
|
||||
* @param array $transports
|
||||
*
|
||||
* @return Swift_LoadBalancedTransport
|
||||
* @return self
|
||||
*/
|
||||
public static function newInstance($transports = array())
|
||||
{
|
||||
|
||||
@@ -11,9 +11,9 @@
|
||||
/**
|
||||
* Sends Messages using the mail() function.
|
||||
*
|
||||
* @package Swift
|
||||
* @subpackage Transport
|
||||
* @author Chris Corbyn
|
||||
*
|
||||
* @deprecated since 5.4.5 (to be removed in 6.0)
|
||||
*/
|
||||
class Swift_MailTransport extends Swift_Transport_MailTransport
|
||||
{
|
||||
@@ -38,7 +38,7 @@ class Swift_MailTransport extends Swift_Transport_MailTransport
|
||||
*
|
||||
* @param string $extraParams To be passed to mail()
|
||||
*
|
||||
* @return Swift_MailTransport
|
||||
* @return self
|
||||
*/
|
||||
public static function newInstance($extraParams = '-f%s')
|
||||
{
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
/**
|
||||
* Swift Mailer class.
|
||||
*
|
||||
* @package Swift
|
||||
* @author Chris Corbyn
|
||||
*/
|
||||
class Swift_Mailer
|
||||
@@ -34,7 +33,7 @@ class Swift_Mailer
|
||||
*
|
||||
* @param Swift_Transport $transport
|
||||
*
|
||||
* @return Swift_Mailer
|
||||
* @return self
|
||||
*/
|
||||
public static function newInstance(Swift_Transport $transport)
|
||||
{
|
||||
@@ -70,7 +69,7 @@ class Swift_Mailer
|
||||
* @param Swift_Mime_Message $message
|
||||
* @param array $failedRecipients An array of failures by-reference
|
||||
*
|
||||
* @return int
|
||||
* @return int The number of successful recipients. Can be 0 which indicates failure
|
||||
*/
|
||||
public function send(Swift_Mime_Message $message, &$failedRecipients = null)
|
||||
{
|
||||
|
||||
@@ -11,8 +11,6 @@
|
||||
/**
|
||||
* Wraps a standard PHP array in an iterator.
|
||||
*
|
||||
* @package Swift
|
||||
* @subpackage Mailer
|
||||
* @author Chris Corbyn
|
||||
*/
|
||||
class Swift_Mailer_ArrayRecipientIterator implements Swift_Mailer_RecipientIterator
|
||||
@@ -46,7 +44,7 @@ class Swift_Mailer_ArrayRecipientIterator implements Swift_Mailer_RecipientItera
|
||||
|
||||
/**
|
||||
* Returns an array where the keys are the addresses of recipients and the
|
||||
* values are the names. e.g. ('foo@bar' => 'Foo') or ('foo@bar' => NULL)
|
||||
* values are the names. e.g. ('foo@bar' => 'Foo') or ('foo@bar' => NULL).
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
|
||||
@@ -11,8 +11,6 @@
|
||||
/**
|
||||
* Provides an abstract way of specifying recipients for batch sending.
|
||||
*
|
||||
* @package Swift
|
||||
* @subpackage Mailer
|
||||
* @author Chris Corbyn
|
||||
*/
|
||||
interface Swift_Mailer_RecipientIterator
|
||||
@@ -26,7 +24,7 @@ interface Swift_Mailer_RecipientIterator
|
||||
|
||||
/**
|
||||
* Returns an array where the keys are the addresses of recipients and the
|
||||
* values are the names. e.g. ('foo@bar' => 'Foo') or ('foo@bar' => NULL)
|
||||
* values are the names. e.g. ('foo@bar' => 'Foo') or ('foo@bar' => NULL).
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
|
||||
@@ -11,12 +11,12 @@
|
||||
/**
|
||||
* Stores Messages in memory.
|
||||
*
|
||||
* @package Swift
|
||||
* @author Fabien Potencier
|
||||
*/
|
||||
class Swift_MemorySpool implements Swift_Spool
|
||||
{
|
||||
protected $messages = array();
|
||||
private $flushRetries = 3;
|
||||
|
||||
/**
|
||||
* Tests if this Transport mechanism has started.
|
||||
@@ -42,6 +42,14 @@ class Swift_MemorySpool implements Swift_Spool
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $retries
|
||||
*/
|
||||
public function setFlushRetries($retries)
|
||||
{
|
||||
$this->flushRetries = $retries;
|
||||
}
|
||||
|
||||
/**
|
||||
* Stores a message in the queue.
|
||||
*
|
||||
@@ -51,7 +59,8 @@ class Swift_MemorySpool implements Swift_Spool
|
||||
*/
|
||||
public function queueMessage(Swift_Mime_Message $message)
|
||||
{
|
||||
$this->messages[] = $message;
|
||||
//clone the message to make sure it is not changed while in the queue
|
||||
$this->messages[] = clone $message;
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -75,9 +84,26 @@ class Swift_MemorySpool implements Swift_Spool
|
||||
}
|
||||
|
||||
$count = 0;
|
||||
$retries = $this->flushRetries;
|
||||
while ($retries--) {
|
||||
try {
|
||||
while ($message = array_pop($this->messages)) {
|
||||
$count += $transport->send($message, $failedRecipients);
|
||||
}
|
||||
} catch (Swift_TransportException $exception) {
|
||||
if ($retries) {
|
||||
// re-queue the message at the end of the queue to give a chance
|
||||
// to the other messages to be sent, in case the failure was due to
|
||||
// this message and not just the transport failing
|
||||
array_unshift($this->messages, $message);
|
||||
|
||||
// wait half a second before we try again
|
||||
usleep(500000);
|
||||
} else {
|
||||
throw $exception;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $count;
|
||||
}
|
||||
|
||||
@@ -11,8 +11,6 @@
|
||||
/**
|
||||
* The Message class for building emails.
|
||||
*
|
||||
* @package Swift
|
||||
* @subpackage Mime
|
||||
* @author Chris Corbyn
|
||||
*/
|
||||
class Swift_Message extends Swift_Mime_SimpleMessage
|
||||
@@ -70,7 +68,7 @@ class Swift_Message extends Swift_Mime_SimpleMessage
|
||||
* @param string $contentType
|
||||
* @param string $charset
|
||||
*
|
||||
* @return Swift_Message
|
||||
* @return $this
|
||||
*/
|
||||
public static function newInstance($subject = null, $body = null, $contentType = null, $charset = null)
|
||||
{
|
||||
@@ -84,20 +82,19 @@ class Swift_Message extends Swift_Mime_SimpleMessage
|
||||
* @param string $contentType
|
||||
* @param string $charset
|
||||
*
|
||||
* @return Swift_Mime_SimpleMessage
|
||||
* @return $this
|
||||
*/
|
||||
public function addPart($body, $contentType = null, $charset = null)
|
||||
{
|
||||
return $this->attach(Swift_MimePart::newInstance(
|
||||
$body, $contentType, $charset
|
||||
));
|
||||
return $this->attach(Swift_MimePart::newInstance($body, $contentType, $charset)->setEncoder($this->getEncoder()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Attach a new signature handler to the message.
|
||||
* Detach a signature handler from a message.
|
||||
*
|
||||
* @param Swift_Signer $signer
|
||||
* @return Swift_Message
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function attachSigner(Swift_Signer $signer)
|
||||
{
|
||||
@@ -114,7 +111,8 @@ class Swift_Message extends Swift_Mime_SimpleMessage
|
||||
* Attach a new signature handler to the message.
|
||||
*
|
||||
* @param Swift_Signer $signer
|
||||
* @return Swift_Message
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function detachSigner(Swift_Signer $signer)
|
||||
{
|
||||
@@ -122,6 +120,7 @@ class Swift_Message extends Swift_Mime_SimpleMessage
|
||||
foreach ($this->headerSigners as $k => $headerSigner) {
|
||||
if ($headerSigner === $signer) {
|
||||
unset($this->headerSigners[$k]);
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
@@ -129,6 +128,7 @@ class Swift_Message extends Swift_Mime_SimpleMessage
|
||||
foreach ($this->bodySigners as $k => $bodySigner) {
|
||||
if ($bodySigner === $signer) {
|
||||
unset($this->bodySigners[$k]);
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
@@ -168,6 +168,7 @@ class Swift_Message extends Swift_Mime_SimpleMessage
|
||||
{
|
||||
if (empty($this->headerSigners) && empty($this->bodySigners)) {
|
||||
parent::toByteStream($is);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -178,7 +179,6 @@ class Swift_Message extends Swift_Mime_SimpleMessage
|
||||
parent::toByteStream($is);
|
||||
|
||||
$this->restoreMessage();
|
||||
|
||||
}
|
||||
|
||||
public function __wakeup()
|
||||
@@ -186,10 +186,8 @@ class Swift_Message extends Swift_Mime_SimpleMessage
|
||||
Swift_DependencyContainer::getInstance()->createDependenciesFor('mime.message');
|
||||
}
|
||||
|
||||
/* -- Protected Methods -- */
|
||||
|
||||
/**
|
||||
* loops through signers and apply the signatures
|
||||
* loops through signers and apply the signatures.
|
||||
*/
|
||||
protected function doSign()
|
||||
{
|
||||
@@ -215,7 +213,7 @@ class Swift_Message extends Swift_Mime_SimpleMessage
|
||||
}
|
||||
|
||||
/**
|
||||
* save the message before any signature is applied
|
||||
* save the message before any signature is applied.
|
||||
*/
|
||||
protected function saveMessage()
|
||||
{
|
||||
@@ -229,7 +227,8 @@ class Swift_Message extends Swift_Mime_SimpleMessage
|
||||
}
|
||||
|
||||
/**
|
||||
* save the original headers
|
||||
* save the original headers.
|
||||
*
|
||||
* @param array $altered
|
||||
*/
|
||||
protected function saveHeaders(array $altered)
|
||||
@@ -244,7 +243,7 @@ class Swift_Message extends Swift_Mime_SimpleMessage
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove or restore altered headers
|
||||
* Remove or restore altered headers.
|
||||
*/
|
||||
protected function restoreHeaders()
|
||||
{
|
||||
@@ -260,7 +259,7 @@ class Swift_Message extends Swift_Mime_SimpleMessage
|
||||
}
|
||||
|
||||
/**
|
||||
* Restore message body
|
||||
* Restore message body.
|
||||
*/
|
||||
protected function restoreMessage()
|
||||
{
|
||||
@@ -270,4 +269,21 @@ class Swift_Message extends Swift_Mime_SimpleMessage
|
||||
$this->restoreHeaders();
|
||||
$this->savedMessage = array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Clone Message Signers.
|
||||
*
|
||||
* @see Swift_Mime_SimpleMimeEntity::__clone()
|
||||
*/
|
||||
public function __clone()
|
||||
{
|
||||
parent::__clone();
|
||||
foreach ($this->bodySigners as $key => $bodySigner) {
|
||||
$this->bodySigners[$key] = clone $bodySigner;
|
||||
}
|
||||
|
||||
foreach ($this->headerSigners as $key => $headerSigner) {
|
||||
$this->headerSigners[$key] = clone $headerSigner;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,8 +11,6 @@
|
||||
/**
|
||||
* An attachment, in a multipart message.
|
||||
*
|
||||
* @package Swift
|
||||
* @subpackage Mime
|
||||
* @author Chris Corbyn
|
||||
*/
|
||||
class Swift_Mime_Attachment extends Swift_Mime_SimpleMimeEntity
|
||||
@@ -66,14 +64,12 @@ class Swift_Mime_Attachment extends Swift_Mime_SimpleMimeEntity
|
||||
*
|
||||
* @param string $disposition
|
||||
*
|
||||
* @return Swift_Mime_Attachment
|
||||
* @return $this
|
||||
*/
|
||||
public function setDisposition($disposition)
|
||||
{
|
||||
if (!$this->_setHeaderFieldModel('Content-Disposition', $disposition)) {
|
||||
$this->getHeaders()->addParameterizedHeader(
|
||||
'Content-Disposition', $disposition
|
||||
);
|
||||
$this->getHeaders()->addParameterizedHeader('Content-Disposition', $disposition);
|
||||
}
|
||||
|
||||
return $this;
|
||||
@@ -94,7 +90,7 @@ class Swift_Mime_Attachment extends Swift_Mime_SimpleMimeEntity
|
||||
*
|
||||
* @param string $filename
|
||||
*
|
||||
* @return Swift_Mime_Attachment
|
||||
* @return $this
|
||||
*/
|
||||
public function setFilename($filename)
|
||||
{
|
||||
@@ -119,7 +115,7 @@ class Swift_Mime_Attachment extends Swift_Mime_SimpleMimeEntity
|
||||
*
|
||||
* @param int $size
|
||||
*
|
||||
* @return Swift_Mime_Attachment
|
||||
* @return $this
|
||||
*/
|
||||
public function setSize($size)
|
||||
{
|
||||
@@ -134,16 +130,14 @@ class Swift_Mime_Attachment extends Swift_Mime_SimpleMimeEntity
|
||||
* @param Swift_FileStream $file
|
||||
* @param string $contentType optional
|
||||
*
|
||||
* @return Swift_Mime_Attachment
|
||||
* @return $this
|
||||
*/
|
||||
public function setFile(Swift_FileStream $file, $contentType = null)
|
||||
{
|
||||
$this->setFilename(basename($file->getPath()));
|
||||
$this->setBody($file, $contentType);
|
||||
if (!isset($contentType)) {
|
||||
$extension = strtolower(substr(
|
||||
$file->getPath(), strrpos($file->getPath(), '.') + 1
|
||||
));
|
||||
$extension = strtolower(substr($file->getPath(), strrpos($file->getPath(), '.') + 1));
|
||||
|
||||
if (array_key_exists($extension, $this->_mimeTypes)) {
|
||||
$this->setContentType($this->_mimeTypes[$extension]);
|
||||
|
||||
@@ -11,8 +11,6 @@
|
||||
/**
|
||||
* Observes changes in an Mime entity's character set.
|
||||
*
|
||||
* @package Swift
|
||||
* @subpackage Mime
|
||||
* @author Chris Corbyn
|
||||
*/
|
||||
interface Swift_Mime_CharsetObserver
|
||||
|
||||
@@ -11,8 +11,6 @@
|
||||
/**
|
||||
* Interface for all Transfer Encoding schemes.
|
||||
*
|
||||
* @package Swift
|
||||
* @subpackage Mime
|
||||
* @author Chris Corbyn
|
||||
*/
|
||||
interface Swift_Mime_ContentEncoder extends Swift_Encoder
|
||||
|
||||
@@ -11,8 +11,6 @@
|
||||
/**
|
||||
* Handles Base 64 Transfer Encoding in Swift Mailer.
|
||||
*
|
||||
* @package Swift
|
||||
* @subpackage Mime
|
||||
* @author Chris Corbyn
|
||||
*/
|
||||
class Swift_Mime_ContentEncoder_Base64ContentEncoder extends Swift_Encoder_Base64Encoder implements Swift_Mime_ContentEncoder
|
||||
@@ -32,9 +30,42 @@ class Swift_Mime_ContentEncoder_Base64ContentEncoder extends Swift_Encoder_Base6
|
||||
}
|
||||
|
||||
$remainder = 0;
|
||||
$base64ReadBufferRemainderBytes = null;
|
||||
|
||||
while (false !== $bytes = $os->read(8190)) {
|
||||
$encoded = base64_encode($bytes);
|
||||
// To reduce memory usage, the output buffer is streamed to the input buffer like so:
|
||||
// Output Stream => base64encode => wrap line length => Input Stream
|
||||
// HOWEVER it's important to note that base64_encode() should only be passed whole triplets of data (except for the final chunk of data)
|
||||
// otherwise it will assume the input data has *ended* and it will incorrectly pad/terminate the base64 data mid-stream.
|
||||
// We use $base64ReadBufferRemainderBytes to carry over 1-2 "remainder" bytes from the each chunk from OutputStream and pre-pend those onto the
|
||||
// chunk of bytes read in the next iteration.
|
||||
// When the OutputStream is empty, we must flush any remainder bytes.
|
||||
while (true) {
|
||||
$readBytes = $os->read(8192);
|
||||
$atEOF = ($readBytes === false);
|
||||
|
||||
if ($atEOF) {
|
||||
$streamTheseBytes = $base64ReadBufferRemainderBytes;
|
||||
} else {
|
||||
$streamTheseBytes = $base64ReadBufferRemainderBytes.$readBytes;
|
||||
}
|
||||
$base64ReadBufferRemainderBytes = null;
|
||||
$bytesLength = strlen($streamTheseBytes);
|
||||
|
||||
if ($bytesLength === 0) { // no data left to encode
|
||||
break;
|
||||
}
|
||||
|
||||
// if we're not on the last block of the ouput stream, make sure $streamTheseBytes ends with a complete triplet of data
|
||||
// and carry over remainder 1-2 bytes to the next loop iteration
|
||||
if (!$atEOF) {
|
||||
$excessBytes = $bytesLength % 3;
|
||||
if ($excessBytes !== 0) {
|
||||
$base64ReadBufferRemainderBytes = substr($streamTheseBytes, -$excessBytes);
|
||||
$streamTheseBytes = substr($streamTheseBytes, 0, $bytesLength - $excessBytes);
|
||||
}
|
||||
}
|
||||
|
||||
$encoded = base64_encode($streamTheseBytes);
|
||||
$encodedTransformed = '';
|
||||
$thisMaxLineLength = $maxLineLength - $remainder - $firstLineOffset;
|
||||
|
||||
@@ -53,6 +84,10 @@ class Swift_Mime_ContentEncoder_Base64ContentEncoder extends Swift_Encoder_Base6
|
||||
}
|
||||
|
||||
$is->write($encodedTransformed);
|
||||
|
||||
if ($atEOF) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -11,8 +11,6 @@
|
||||
/**
|
||||
* Handles Quoted Printable (QP) Transfer Encoding in Swift Mailer using the PHP core function.
|
||||
*
|
||||
* @package Swift
|
||||
* @subpackage Mime
|
||||
* @author Lars Strojny
|
||||
*/
|
||||
class Swift_Mime_ContentEncoder_NativeQpContentEncoder implements Swift_Mime_ContentEncoder
|
||||
@@ -83,9 +81,9 @@ class Swift_Mime_ContentEncoder_NativeQpContentEncoder implements Swift_Mime_Con
|
||||
* @param int $firstLineOffset if first line needs to be shorter
|
||||
* @param int $maxLineLength 0 indicates the default length for this encoding
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @throws RuntimeException
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function encodeString($string, $firstLineOffset = 0, $maxLineLength = 0)
|
||||
{
|
||||
@@ -109,7 +107,7 @@ class Swift_Mime_ContentEncoder_NativeQpContentEncoder implements Swift_Mime_Con
|
||||
// transform CR or LF to CRLF
|
||||
$string = preg_replace('~=0D(?!=0A)|(?<!=0D)=0A~', '=0D=0A', $string);
|
||||
// transform =0D=0A to CRLF
|
||||
$string = str_replace(array("\t=0D=0A", " =0D=0A", "=0D=0A"), array("=09\r\n", "=20\r\n", "\r\n"), $string);
|
||||
$string = str_replace(array("\t=0D=0A", ' =0D=0A', '=0D=0A'), array("=09\r\n", "=20\r\n", "\r\n"), $string);
|
||||
|
||||
switch ($end = ord(substr($string, -1))) {
|
||||
case 0x09:
|
||||
|
||||
@@ -11,8 +11,6 @@
|
||||
/**
|
||||
* Handles binary/7/8-bit Transfer Encoding in Swift Mailer.
|
||||
*
|
||||
* @package Swift
|
||||
* @subpackage Mime
|
||||
* @author Chris Corbyn
|
||||
*/
|
||||
class Swift_Mime_ContentEncoder_PlainContentEncoder implements Swift_Mime_ContentEncoder
|
||||
@@ -106,8 +104,6 @@ class Swift_Mime_ContentEncoder_PlainContentEncoder implements Swift_Mime_Conten
|
||||
{
|
||||
}
|
||||
|
||||
// -- Private methods
|
||||
|
||||
/**
|
||||
* A safer (but weaker) wordwrap for unicode.
|
||||
*
|
||||
@@ -137,8 +133,7 @@ class Swift_Mime_ContentEncoder_PlainContentEncoder implements Swift_Mime_Conten
|
||||
|
||||
foreach ($chunks as $chunk) {
|
||||
if (0 != strlen($currentLine)
|
||||
&& strlen($currentLine . $chunk) > $length)
|
||||
{
|
||||
&& strlen($currentLine.$chunk) > $length) {
|
||||
$lines[] = '';
|
||||
$currentLine = &$lines[$lineCount++];
|
||||
}
|
||||
|
||||
@@ -11,8 +11,6 @@
|
||||
/**
|
||||
* Handles Quoted Printable (QP) Transfer Encoding in Swift Mailer.
|
||||
*
|
||||
* @package Swift
|
||||
* @subpackage Mime
|
||||
* @author Chris Corbyn
|
||||
*/
|
||||
class Swift_Mime_ContentEncoder_QpContentEncoder extends Swift_Encoder_QpEncoder implements Swift_Mime_ContentEncoder
|
||||
@@ -97,15 +95,26 @@ class Swift_Mime_ContentEncoder_QpContentEncoder extends Swift_Encoder_QpEncoder
|
||||
}
|
||||
|
||||
$enc = $this->_encodeByteSequence($bytes, $size);
|
||||
if ($currentLine && $lineLen+$size >= $thisLineLength) {
|
||||
|
||||
$i = strpos($enc, '=0D=0A');
|
||||
$newLineLength = $lineLen + ($i === false ? $size : $i);
|
||||
|
||||
if ($currentLine && $newLineLength >= $thisLineLength) {
|
||||
$is->write($prepend.$this->_standardize($currentLine));
|
||||
$currentLine = '';
|
||||
$prepend = "=\r\n";
|
||||
$thisLineLength = $maxLineLength;
|
||||
$lineLen = 0;
|
||||
}
|
||||
$lineLen+=$size;
|
||||
|
||||
$currentLine .= $enc;
|
||||
|
||||
if ($i === false) {
|
||||
$lineLen += $size;
|
||||
} else {
|
||||
// 6 is the length of '=0D=0A'.
|
||||
$lineLen = $size - strrpos($enc, '=0D=0A') - 6;
|
||||
}
|
||||
}
|
||||
if (strlen($currentLine)) {
|
||||
$is->write($prepend.$this->_standardize($currentLine));
|
||||
|
||||
@@ -13,8 +13,6 @@
|
||||
*
|
||||
* Switches on the best QP encoder implementation for current charset.
|
||||
*
|
||||
* @package Swift
|
||||
* @subpackage Mime
|
||||
* @author Jean-François Simon <jeanfrancois.simon@sensiolabs.com>
|
||||
*/
|
||||
class Swift_Mime_ContentEncoder_QpContentEncoderProxy implements Swift_Mime_ContentEncoder
|
||||
@@ -48,12 +46,22 @@ class Swift_Mime_ContentEncoder_QpContentEncoderProxy implements Swift_Mime_Cont
|
||||
$this->charset = $charset;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a deep copy of object.
|
||||
*/
|
||||
public function __clone()
|
||||
{
|
||||
$this->safeEncoder = clone $this->safeEncoder;
|
||||
$this->nativeEncoder = clone $this->nativeEncoder;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function charsetChanged($charset)
|
||||
{
|
||||
$this->charset = $charset;
|
||||
$this->safeEncoder->charsetChanged($charset);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -11,8 +11,6 @@
|
||||
/**
|
||||
* Handles raw Transfer Encoding in Swift Mailer.
|
||||
*
|
||||
* @package Swift
|
||||
* @subpackage Mime
|
||||
*
|
||||
* @author Sebastiaan Stok <s.stok@rollerscapes.net>
|
||||
*/
|
||||
@@ -24,6 +22,7 @@ class Swift_Mime_ContentEncoder_RawContentEncoder implements Swift_Mime_ContentE
|
||||
* @param string $string
|
||||
* @param int $firstLineOffset ignored
|
||||
* @param int $maxLineLength ignored
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function encodeString($string, $firstLineOffset = 0, $maxLineLength = 0)
|
||||
|
||||
@@ -11,8 +11,6 @@
|
||||
/**
|
||||
* An embedded file, in a multipart message.
|
||||
*
|
||||
* @package Swift
|
||||
* @subpackage Mime
|
||||
* @author Chris Corbyn
|
||||
*/
|
||||
class Swift_Mime_EmbeddedFile extends Swift_Mime_Attachment
|
||||
|
||||
@@ -11,8 +11,6 @@
|
||||
/**
|
||||
* Observes changes for a Mime entity's ContentEncoder.
|
||||
*
|
||||
* @package Swift
|
||||
* @subpackage Mime
|
||||
* @author Chris Corbyn
|
||||
*/
|
||||
interface Swift_Mime_EncodingObserver
|
||||
|
||||
@@ -11,8 +11,6 @@
|
||||
/**
|
||||
* Defines the grammar to use for validation, implements the RFC 2822 (and friends) ABNF grammar definitions.
|
||||
*
|
||||
* @package Swift
|
||||
* @subpackage Mime
|
||||
* @author Fabien Potencier
|
||||
* @author Chris Corbyn
|
||||
*/
|
||||
@@ -53,7 +51,7 @@ class Swift_Mime_Grammar
|
||||
|
||||
self::$_specials = array(
|
||||
'(', ')', '<', '>', '[', ']',
|
||||
':', ';', '@', ',', '.', '"'
|
||||
':', ';', '@', ',', '.', '"',
|
||||
);
|
||||
|
||||
/*** Refer to RFC 2822 for ABNF grammar ***/
|
||||
@@ -131,12 +129,12 @@ class Swift_Mime_Grammar
|
||||
{
|
||||
if (array_key_exists($name, self::$_grammar)) {
|
||||
return self::$_grammar[$name];
|
||||
} else {
|
||||
}
|
||||
|
||||
throw new Swift_RfcComplianceException(
|
||||
"No such grammar '".$name."' defined."
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the tokens defined in RFC 2822 (and some related RFCs).
|
||||
|
||||
@@ -11,8 +11,6 @@
|
||||
/**
|
||||
* A MIME Header.
|
||||
*
|
||||
* @package Swift
|
||||
* @subpackage Mime
|
||||
* @author Chris Corbyn
|
||||
*/
|
||||
interface Swift_Mime_Header
|
||||
|
||||
@@ -11,8 +11,6 @@
|
||||
/**
|
||||
* Interface for all Header Encoding schemes.
|
||||
*
|
||||
* @package Swift
|
||||
* @subpackage Mime
|
||||
* @author Chris Corbyn
|
||||
*/
|
||||
interface Swift_Mime_HeaderEncoder extends Swift_Encoder
|
||||
|
||||
@@ -11,8 +11,6 @@
|
||||
/**
|
||||
* Handles Base64 (B) Header Encoding in Swift Mailer.
|
||||
*
|
||||
* @package Swift
|
||||
* @subpackage Mime
|
||||
* @author Chris Corbyn
|
||||
*/
|
||||
class Swift_Mime_HeaderEncoder_Base64HeaderEncoder extends Swift_Encoder_Base64Encoder implements Swift_Mime_HeaderEncoder
|
||||
|
||||
@@ -11,8 +11,6 @@
|
||||
/**
|
||||
* Handles Quoted Printable (Q) Header Encoding in Swift Mailer.
|
||||
*
|
||||
* @package Swift
|
||||
* @subpackage Mime
|
||||
* @author Chris Corbyn
|
||||
*/
|
||||
class Swift_Mime_HeaderEncoder_QpHeaderEncoder extends Swift_Encoder_QpEncoder implements Swift_Mime_HeaderEncoder
|
||||
|
||||
@@ -11,8 +11,6 @@
|
||||
/**
|
||||
* Creates MIME headers.
|
||||
*
|
||||
* @package Swift
|
||||
* @subpackage Mime
|
||||
* @author Chris Corbyn
|
||||
*/
|
||||
interface Swift_Mime_HeaderFactory extends Swift_Mime_CharsetObserver
|
||||
|
||||
@@ -11,8 +11,6 @@
|
||||
/**
|
||||
* A collection of MIME headers.
|
||||
*
|
||||
* @package Swift
|
||||
* @subpackage Mime
|
||||
* @author Chris Corbyn
|
||||
*/
|
||||
interface Swift_Mime_HeaderSet extends Swift_Mime_CharsetObserver
|
||||
@@ -114,7 +112,7 @@ interface Swift_Mime_HeaderSet extends Swift_Mime_CharsetObserver
|
||||
public function getAll($name = null);
|
||||
|
||||
/**
|
||||
* Return the name of all Headers
|
||||
* Return the name of all Headers.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
@@ -140,7 +138,7 @@ interface Swift_Mime_HeaderSet extends Swift_Mime_CharsetObserver
|
||||
/**
|
||||
* Create a new instance of this HeaderSet.
|
||||
*
|
||||
* @return Swift_Mime_HeaderSet
|
||||
* @return self
|
||||
*/
|
||||
public function newInstance();
|
||||
|
||||
|
||||
@@ -11,8 +11,6 @@
|
||||
/**
|
||||
* An abstract base MIME Header.
|
||||
*
|
||||
* @package Swift
|
||||
* @subpackage Mime
|
||||
* @author Chris Corbyn
|
||||
*/
|
||||
abstract class Swift_Mime_Headers_AbstractHeader implements Swift_Mime_Header
|
||||
@@ -200,9 +198,9 @@ abstract class Swift_Mime_Headers_AbstractHeader implements Swift_Mime_Header
|
||||
/**
|
||||
* Get this Header rendered as a RFC 2822 compliant string.
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @throws Swift_RfcComplianceException
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function toString()
|
||||
{
|
||||
@@ -221,8 +219,6 @@ abstract class Swift_Mime_Headers_AbstractHeader implements Swift_Mime_Header
|
||||
return $this->toString();
|
||||
}
|
||||
|
||||
// -- Points of extension
|
||||
|
||||
/**
|
||||
* Set the name of this Header field.
|
||||
*
|
||||
@@ -257,7 +253,8 @@ abstract class Swift_Mime_Headers_AbstractHeader implements Swift_Mime_Header
|
||||
$phraseStr, array('"'), $this->getGrammar()->getSpecials()
|
||||
);
|
||||
$phraseStr = '"'.$phraseStr.'"';
|
||||
} else { // ... otherwise it needs encoding
|
||||
} else {
|
||||
// ... otherwise it needs encoding
|
||||
// Determine space remaining on line if first line
|
||||
if ($shorten) {
|
||||
$usedLength = strlen($header->getFieldName().': ');
|
||||
@@ -374,7 +371,8 @@ abstract class Swift_Mime_Headers_AbstractHeader implements Swift_Mime_Header
|
||||
'=?'.$charsetDecl.'?'.$this->_encoder->getName().'??='
|
||||
);
|
||||
|
||||
if ($firstLineOffset >= 75) { //Does this logic need to be here?
|
||||
if ($firstLineOffset >= 75) {
|
||||
//Does this logic need to be here?
|
||||
$firstLineOffset = 0;
|
||||
}
|
||||
|
||||
@@ -384,7 +382,8 @@ abstract class Swift_Mime_Headers_AbstractHeader implements Swift_Mime_Header
|
||||
)
|
||||
);
|
||||
|
||||
if (strtolower($this->_charset) !== 'iso-2022-jp') { // special encoding for iso-2022-jp using mb_encode_mimeheader
|
||||
if (strtolower($this->_charset) !== 'iso-2022-jp') {
|
||||
// special encoding for iso-2022-jp using mb_encode_mimeheader
|
||||
foreach ($encodedTextLines as $lineNum => $line) {
|
||||
$encodedTextLines[$lineNum] = '=?'.$charsetDecl.
|
||||
'?'.$this->_encoder->getName().
|
||||
@@ -439,8 +438,6 @@ abstract class Swift_Mime_Headers_AbstractHeader implements Swift_Mime_Header
|
||||
}
|
||||
}
|
||||
|
||||
// -- Private methods
|
||||
|
||||
/**
|
||||
* Generate a list of all tokens in the final header.
|
||||
*
|
||||
@@ -450,7 +447,7 @@ abstract class Swift_Mime_Headers_AbstractHeader implements Swift_Mime_Header
|
||||
*/
|
||||
protected function toTokens($string = null)
|
||||
{
|
||||
if (is_null($string)) {
|
||||
if (null === $string) {
|
||||
$string = $this->getFieldBody();
|
||||
}
|
||||
|
||||
@@ -463,6 +460,7 @@ abstract class Swift_Mime_Headers_AbstractHeader implements Swift_Mime_Header
|
||||
$tokens[] = $newToken;
|
||||
}
|
||||
}
|
||||
|
||||
return $tokens;
|
||||
}
|
||||
|
||||
@@ -486,8 +484,7 @@ abstract class Swift_Mime_Headers_AbstractHeader implements Swift_Mime_Header
|
||||
// Line longer than specified maximum or token was just a new line
|
||||
if (("\r\n" == $token) ||
|
||||
($i > 0 && strlen($currentLine.$token) > $this->_lineLength)
|
||||
&& 0 < strlen($currentLine))
|
||||
{
|
||||
&& 0 < strlen($currentLine)) {
|
||||
$headerLines[] = '';
|
||||
$currentLine = &$headerLines[$lineCount++];
|
||||
}
|
||||
|
||||
@@ -11,8 +11,6 @@
|
||||
/**
|
||||
* A Date MIME Header for Swift Mailer.
|
||||
*
|
||||
* @package Swift
|
||||
* @subpackage Mime
|
||||
* @author Chris Corbyn
|
||||
*/
|
||||
class Swift_Mime_Headers_DateHeader extends Swift_Mime_Headers_AbstractHeader
|
||||
@@ -97,7 +95,7 @@ class Swift_Mime_Headers_DateHeader extends Swift_Mime_Headers_AbstractHeader
|
||||
*/
|
||||
public function setTimestamp($timestamp)
|
||||
{
|
||||
if (!is_null($timestamp)) {
|
||||
if (null !== $timestamp) {
|
||||
$timestamp = (int) $timestamp;
|
||||
}
|
||||
$this->clearCachedValueIf($this->_timestamp != $timestamp);
|
||||
|
||||
@@ -11,8 +11,6 @@
|
||||
/**
|
||||
* An ID MIME Header for something like Message-ID or Content-ID.
|
||||
*
|
||||
* @package Swift
|
||||
* @subpackage Mime
|
||||
* @author Chris Corbyn
|
||||
*/
|
||||
class Swift_Mime_Headers_IdentificationHeader extends Swift_Mime_Headers_AbstractHeader
|
||||
@@ -141,9 +139,9 @@ class Swift_Mime_Headers_IdentificationHeader extends Swift_Mime_Headers_Abstrac
|
||||
*
|
||||
* @see toString()
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @throws Swift_RfcComplianceException
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getFieldBody()
|
||||
{
|
||||
@@ -173,8 +171,7 @@ class Swift_Mime_Headers_IdentificationHeader extends Swift_Mime_Headers_Abstrac
|
||||
'/^'.$this->getGrammar()->getDefinition('id-left').'@'.
|
||||
$this->getGrammar()->getDefinition('id-right').'$/D',
|
||||
$id
|
||||
))
|
||||
{
|
||||
)) {
|
||||
throw new Swift_RfcComplianceException(
|
||||
'Invalid ID given <'.$id.'>'
|
||||
);
|
||||
|
||||
@@ -11,8 +11,6 @@
|
||||
/**
|
||||
* A Mailbox Address MIME Header for something like From or Sender.
|
||||
*
|
||||
* @package Swift
|
||||
* @subpackage Mime
|
||||
* @author Chris Corbyn
|
||||
*/
|
||||
class Swift_Mime_Headers_MailboxHeader extends Swift_Mime_Headers_AbstractHeader
|
||||
@@ -70,9 +68,9 @@ class Swift_Mime_Headers_MailboxHeader extends Swift_Mime_Headers_AbstractHeader
|
||||
*
|
||||
* This method returns an associative array like {@link getNameAddresses()}
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @throws Swift_RfcComplianceException
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getFieldBodyModel()
|
||||
{
|
||||
@@ -130,9 +128,9 @@ class Swift_Mime_Headers_MailboxHeader extends Swift_Mime_Headers_AbstractHeader
|
||||
* @see getNameAddresses()
|
||||
* @see toString()
|
||||
*
|
||||
* @return string[]
|
||||
*
|
||||
* @throws Swift_RfcComplianceException
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
public function getNameAddressStrings()
|
||||
{
|
||||
@@ -226,22 +224,20 @@ class Swift_Mime_Headers_MailboxHeader extends Swift_Mime_Headers_AbstractHeader
|
||||
*
|
||||
* @see toString()
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @throws Swift_RfcComplianceException
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getFieldBody()
|
||||
{
|
||||
// Compute the string value of the header only if needed
|
||||
if (is_null($this->getCachedValue())) {
|
||||
if (null === $this->getCachedValue()) {
|
||||
$this->setCachedValue($this->createMailboxListString($this->_mailboxes));
|
||||
}
|
||||
|
||||
return $this->getCachedValue();
|
||||
}
|
||||
|
||||
// -- Points of extension
|
||||
|
||||
/**
|
||||
* Normalizes a user-input list of mailboxes into consistent key=>value pairs.
|
||||
*
|
||||
@@ -254,7 +250,8 @@ class Swift_Mime_Headers_MailboxHeader extends Swift_Mime_Headers_AbstractHeader
|
||||
$actualMailboxes = array();
|
||||
|
||||
foreach ($mailboxes as $key => $value) {
|
||||
if (is_string($key)) { //key is email addr
|
||||
if (is_string($key)) {
|
||||
//key is email addr
|
||||
$address = $key;
|
||||
$name = $value;
|
||||
} else {
|
||||
@@ -278,9 +275,7 @@ class Swift_Mime_Headers_MailboxHeader extends Swift_Mime_Headers_AbstractHeader
|
||||
*/
|
||||
protected function createDisplayNameString($displayName, $shorten = false)
|
||||
{
|
||||
return $this->createPhrase($this, $displayName,
|
||||
$this->getCharset(), $this->getEncoder(), $shorten
|
||||
);
|
||||
return $this->createPhrase($this, $displayName, $this->getCharset(), $this->getEncoder(), $shorten);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -288,9 +283,9 @@ class Swift_Mime_Headers_MailboxHeader extends Swift_Mime_Headers_AbstractHeader
|
||||
*
|
||||
* @param string[] $mailboxes
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @throws Swift_RfcComplianceException
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function createMailboxListString(array $mailboxes)
|
||||
{
|
||||
@@ -300,8 +295,9 @@ class Swift_Mime_Headers_MailboxHeader extends Swift_Mime_Headers_AbstractHeader
|
||||
/**
|
||||
* Redefine the encoding requirements for mailboxes.
|
||||
*
|
||||
* Commas and semicolons are used to separate
|
||||
* multiple addresses, and should therefore be encoded
|
||||
* All "specials" must be encoded as the full header value will not be quoted
|
||||
*
|
||||
* @see RFC 2822 3.2.1
|
||||
*
|
||||
* @param string $token
|
||||
*
|
||||
@@ -309,11 +305,9 @@ class Swift_Mime_Headers_MailboxHeader extends Swift_Mime_Headers_AbstractHeader
|
||||
*/
|
||||
protected function tokenNeedsEncoding($token)
|
||||
{
|
||||
return preg_match('/[,;]/', $token) || parent::tokenNeedsEncoding($token);
|
||||
return preg_match('/[()<>\[\]:;@\,."]/', $token) || parent::tokenNeedsEncoding($token);
|
||||
}
|
||||
|
||||
// -- Private methods
|
||||
|
||||
/**
|
||||
* Return an array of strings conforming the the name-addr spec of RFC 2822.
|
||||
*
|
||||
@@ -327,7 +321,7 @@ class Swift_Mime_Headers_MailboxHeader extends Swift_Mime_Headers_AbstractHeader
|
||||
|
||||
foreach ($mailboxes as $email => $name) {
|
||||
$mailboxStr = $email;
|
||||
if (!is_null($name)) {
|
||||
if (null !== $name) {
|
||||
$nameStr = $this->createDisplayNameString($name, empty($strings));
|
||||
$mailboxStr = $nameStr.' <'.$mailboxStr.'>';
|
||||
}
|
||||
@@ -347,8 +341,7 @@ class Swift_Mime_Headers_MailboxHeader extends Swift_Mime_Headers_AbstractHeader
|
||||
private function _assertValidAddress($address)
|
||||
{
|
||||
if (!preg_match('/^'.$this->getGrammar()->getDefinition('addr-spec').'$/D',
|
||||
$address))
|
||||
{
|
||||
$address)) {
|
||||
throw new Swift_RfcComplianceException(
|
||||
'Address in mailbox given ['.$address.
|
||||
'] does not comply with RFC 2822, 3.6.2.'
|
||||
|
||||
@@ -9,10 +9,8 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* An OpenDKIM Specific Header using only raw header datas without encoding
|
||||
* An OpenDKIM Specific Header using only raw header datas without encoding.
|
||||
*
|
||||
* @package Swift
|
||||
* @subpackage Mime
|
||||
* @author De Cock Xavier <xdecock@gmail.com>
|
||||
*/
|
||||
class Swift_Mime_Headers_OpenDKIMHeader implements Swift_Mime_Header
|
||||
@@ -25,17 +23,14 @@ class Swift_Mime_Headers_OpenDKIMHeader implements Swift_Mime_Header
|
||||
private $_value;
|
||||
|
||||
/**
|
||||
* The name of this Header
|
||||
* The name of this Header.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_fieldName;
|
||||
|
||||
/**
|
||||
* Creates a new SimpleHeader with $name.
|
||||
*
|
||||
* @param string $name
|
||||
* @param Swift_Mime_HeaderEncoder $encoder
|
||||
* @param Swift_Mime_Grammar $grammar
|
||||
*/
|
||||
public function __construct($name)
|
||||
{
|
||||
@@ -120,7 +115,8 @@ class Swift_Mime_Headers_OpenDKIMHeader implements Swift_Mime_Header
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the Header FieldName
|
||||
* Set the Header FieldName.
|
||||
*
|
||||
* @see Swift_Mime_Header::getFieldName()
|
||||
*/
|
||||
public function getFieldName()
|
||||
@@ -129,11 +125,9 @@ class Swift_Mime_Headers_OpenDKIMHeader implements Swift_Mime_Header
|
||||
}
|
||||
|
||||
/**
|
||||
* Ignored
|
||||
* Ignored.
|
||||
*/
|
||||
public function setCharset($charset)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -11,8 +11,6 @@
|
||||
/**
|
||||
* An abstract base MIME Header.
|
||||
*
|
||||
* @package Swift
|
||||
* @subpackage Mime
|
||||
* @author Chris Corbyn
|
||||
*/
|
||||
class Swift_Mime_Headers_ParameterizedHeader extends Swift_Mime_Headers_UnstructuredHeader implements Swift_Mime_ParameterizedHeader
|
||||
@@ -100,9 +98,7 @@ class Swift_Mime_Headers_ParameterizedHeader extends Swift_Mime_Headers_Unstruct
|
||||
{
|
||||
$params = $this->getParameters();
|
||||
|
||||
return array_key_exists($parameter, $params)
|
||||
? $params[$parameter]
|
||||
: null;
|
||||
return array_key_exists($parameter, $params) ? $params[$parameter] : null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -135,7 +131,7 @@ class Swift_Mime_Headers_ParameterizedHeader extends Swift_Mime_Headers_Unstruct
|
||||
{
|
||||
$body = parent::getFieldBody();
|
||||
foreach ($this->_params as $name => $value) {
|
||||
if (!is_null($value)) {
|
||||
if (null !== $value) {
|
||||
// Add the parameter
|
||||
$body .= '; '.$this->_createParameter($name, $value);
|
||||
}
|
||||
@@ -144,8 +140,6 @@ class Swift_Mime_Headers_ParameterizedHeader extends Swift_Mime_Headers_Unstruct
|
||||
return $body;
|
||||
}
|
||||
|
||||
// -- Protected methods
|
||||
|
||||
/**
|
||||
* Generate a list of all tokens in the final header.
|
||||
*
|
||||
@@ -162,7 +156,7 @@ class Swift_Mime_Headers_ParameterizedHeader extends Swift_Mime_Headers_Unstruct
|
||||
|
||||
// Try creating any parameters
|
||||
foreach ($this->_params as $name => $value) {
|
||||
if (!is_null($value)) {
|
||||
if (null !== $value) {
|
||||
// Add the semi-colon separator
|
||||
$tokens[count($tokens) - 1] .= ';';
|
||||
$tokens = array_merge($tokens, $this->generateTokenLines(
|
||||
@@ -174,8 +168,6 @@ class Swift_Mime_Headers_ParameterizedHeader extends Swift_Mime_Headers_Unstruct
|
||||
return $tokens;
|
||||
}
|
||||
|
||||
// -- Private methods
|
||||
|
||||
/**
|
||||
* Render a RFC 2047 compliant header parameter from the $name and $value.
|
||||
*
|
||||
@@ -213,7 +205,8 @@ class Swift_Mime_Headers_ParameterizedHeader extends Swift_Mime_Headers_Unstruct
|
||||
$value = $this->_paramEncoder->encodeString(
|
||||
$origValue, $firstLineOffset, $maxValueLength, $this->getCharset()
|
||||
);
|
||||
} else { // We have to go against RFC 2183/2231 in some areas for interoperability
|
||||
} else {
|
||||
// We have to go against RFC 2183/2231 in some areas for interoperability
|
||||
$value = $this->getTokenAsEncodedWord($origValue);
|
||||
$encoded = false;
|
||||
}
|
||||
|
||||
@@ -11,8 +11,6 @@
|
||||
/**
|
||||
* A Path Header in Swift Mailer, such a Return-Path.
|
||||
*
|
||||
* @package Swift
|
||||
* @subpackage Mime
|
||||
* @author Chris Corbyn
|
||||
*/
|
||||
class Swift_Mime_Headers_PathHeader extends Swift_Mime_Headers_AbstractHeader
|
||||
@@ -82,7 +80,7 @@ class Swift_Mime_Headers_PathHeader extends Swift_Mime_Headers_AbstractHeader
|
||||
*/
|
||||
public function setAddress($address)
|
||||
{
|
||||
if (is_null($address)) {
|
||||
if (null === $address) {
|
||||
$this->_address = null;
|
||||
} elseif ('' == $address) {
|
||||
$this->_address = '';
|
||||
@@ -136,8 +134,7 @@ class Swift_Mime_Headers_PathHeader extends Swift_Mime_Headers_AbstractHeader
|
||||
private function _assertValidAddress($address)
|
||||
{
|
||||
if (!preg_match('/^'.$this->getGrammar()->getDefinition('addr-spec').'$/D',
|
||||
$address))
|
||||
{
|
||||
$address)) {
|
||||
throw new Swift_RfcComplianceException(
|
||||
'Address set in PathHeader does not comply with addr-spec of RFC 2822.'
|
||||
);
|
||||
|
||||
@@ -11,8 +11,6 @@
|
||||
/**
|
||||
* A Simple MIME Header.
|
||||
*
|
||||
* @package Swift
|
||||
* @subpackage Mime
|
||||
* @author Chris Corbyn
|
||||
*/
|
||||
class Swift_Mime_Headers_UnstructuredHeader extends Swift_Mime_Headers_AbstractHeader
|
||||
|
||||
@@ -11,8 +11,6 @@
|
||||
/**
|
||||
* A Message (RFC 2822) object.
|
||||
*
|
||||
* @package Swift
|
||||
* @subpackage Mime
|
||||
* @author Chris Corbyn
|
||||
*/
|
||||
interface Swift_Mime_Message extends Swift_Mime_MimeEntity
|
||||
|
||||
@@ -11,8 +11,6 @@
|
||||
/**
|
||||
* A MIME entity, such as an attachment.
|
||||
*
|
||||
* @package Swift
|
||||
* @subpackage Mime
|
||||
* @author Chris Corbyn
|
||||
*/
|
||||
interface Swift_Mime_MimeEntity extends Swift_Mime_CharsetObserver, Swift_Mime_EncodingObserver
|
||||
@@ -33,6 +31,7 @@ interface Swift_Mime_MimeEntity extends Swift_Mime_CharsetObserver, Swift_Mime_E
|
||||
* Get the level at which this entity shall be nested in final document.
|
||||
*
|
||||
* The lower the value, the more outermost the entity will be nested.
|
||||
*
|
||||
* @see LEVEL_TOP, LEVEL_MIXED, LEVEL_RELATED, LEVEL_ALTERNATIVE
|
||||
*
|
||||
* @return int
|
||||
@@ -41,6 +40,7 @@ interface Swift_Mime_MimeEntity extends Swift_Mime_CharsetObserver, Swift_Mime_E
|
||||
|
||||
/**
|
||||
* Get the qualified content-type of this mime entity.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getContentType();
|
||||
@@ -80,7 +80,7 @@ interface Swift_Mime_MimeEntity extends Swift_Mime_CharsetObserver, Swift_Mime_E
|
||||
/**
|
||||
* Get the collection of Headers in this Mime entity.
|
||||
*
|
||||
* @return Swift_Mime_Header[]
|
||||
* @return Swift_Mime_HeaderSet
|
||||
*/
|
||||
public function getHeaders();
|
||||
|
||||
|
||||
@@ -11,8 +11,6 @@
|
||||
/**
|
||||
* A MIME part, in a multipart message.
|
||||
*
|
||||
* @package Swift
|
||||
* @subpackage Mime
|
||||
* @author Chris Corbyn
|
||||
*/
|
||||
class Swift_Mime_MimePart extends Swift_Mime_SimpleMimeEntity
|
||||
@@ -42,7 +40,7 @@ class Swift_Mime_MimePart extends Swift_Mime_SimpleMimeEntity
|
||||
{
|
||||
parent::__construct($headers, $encoder, $cache, $grammar);
|
||||
$this->setContentType('text/plain');
|
||||
if (!is_null($charset)) {
|
||||
if (null !== $charset) {
|
||||
$this->setCharset($charset);
|
||||
}
|
||||
}
|
||||
@@ -55,7 +53,7 @@ class Swift_Mime_MimePart extends Swift_Mime_SimpleMimeEntity
|
||||
* @param string $contentType optional
|
||||
* @param string $charset optional
|
||||
*
|
||||
* @return Swift_Mime_MimePart
|
||||
* @return $this
|
||||
*/
|
||||
public function setBody($body, $contentType = null, $charset = null)
|
||||
{
|
||||
@@ -84,7 +82,7 @@ class Swift_Mime_MimePart extends Swift_Mime_SimpleMimeEntity
|
||||
*
|
||||
* @param string $charset
|
||||
*
|
||||
* @return Swift_Mime_MimePart
|
||||
* @return $this
|
||||
*/
|
||||
public function setCharset($charset)
|
||||
{
|
||||
@@ -113,7 +111,7 @@ class Swift_Mime_MimePart extends Swift_Mime_SimpleMimeEntity
|
||||
*
|
||||
* @param string $format
|
||||
*
|
||||
* @return Swift_Mime_MimePart
|
||||
* @return $this
|
||||
*/
|
||||
public function setFormat($format)
|
||||
{
|
||||
@@ -130,9 +128,7 @@ class Swift_Mime_MimePart extends Swift_Mime_SimpleMimeEntity
|
||||
*/
|
||||
public function getDelSp()
|
||||
{
|
||||
return ($this->_getHeaderParameter('Content-Type', 'delsp') == 'yes')
|
||||
? true
|
||||
: false;
|
||||
return 'yes' == $this->_getHeaderParameter('Content-Type', 'delsp') ? true : false;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -140,7 +136,7 @@ class Swift_Mime_MimePart extends Swift_Mime_SimpleMimeEntity
|
||||
*
|
||||
* @param bool $delsp
|
||||
*
|
||||
* @return Swift_Mime_MimePart
|
||||
* @return $this
|
||||
*/
|
||||
public function setDelSp($delsp = true)
|
||||
{
|
||||
@@ -173,8 +169,6 @@ class Swift_Mime_MimePart extends Swift_Mime_SimpleMimeEntity
|
||||
$this->setCharset($charset);
|
||||
}
|
||||
|
||||
// -- Protected methods
|
||||
|
||||
/** Fix the content-type and encoding of this entity */
|
||||
protected function _fixHeaders()
|
||||
{
|
||||
@@ -200,12 +194,12 @@ class Swift_Mime_MimePart extends Swift_Mime_SimpleMimeEntity
|
||||
protected function _convertString($string)
|
||||
{
|
||||
$charset = strtolower($this->getCharset());
|
||||
if (!in_array($charset, array('utf-8', 'iso-8859-1', ''))) {
|
||||
if (!in_array($charset, array('utf-8', 'iso-8859-1', 'iso-8859-15', ''))) {
|
||||
// mb_convert_encoding must be the first one to check, since iconv cannot convert some words.
|
||||
if (function_exists('mb_convert_encoding')) {
|
||||
$string = mb_convert_encoding($string, 'utf-8', $charset);
|
||||
$string = mb_convert_encoding($string, $charset, 'utf-8');
|
||||
} elseif (function_exists('iconv')) {
|
||||
$string = iconv($charset, 'utf-8//TRANSLIT//IGNORE', $string);
|
||||
$string = iconv('utf-8//TRANSLIT//IGNORE', $charset, $string);
|
||||
} else {
|
||||
throw new Swift_SwiftException('No suitable convert encoding function (use UTF-8 as your charset or install the mbstring or iconv extension).');
|
||||
}
|
||||
|
||||
@@ -11,8 +11,6 @@
|
||||
/**
|
||||
* A MIME Header with parameters.
|
||||
*
|
||||
* @package Swift
|
||||
* @subpackage Mime
|
||||
* @author Chris Corbyn
|
||||
*/
|
||||
interface Swift_Mime_ParameterizedHeader extends Swift_Mime_Header
|
||||
|
||||
@@ -11,8 +11,6 @@
|
||||
/**
|
||||
* Creates MIME headers.
|
||||
*
|
||||
* @package Swift
|
||||
* @subpackage Mime
|
||||
* @author Chris Corbyn
|
||||
*/
|
||||
class Swift_Mime_SimpleHeaderFactory implements Swift_Mime_HeaderFactory
|
||||
@@ -66,6 +64,7 @@ class Swift_Mime_SimpleHeaderFactory implements Swift_Mime_HeaderFactory
|
||||
|
||||
/**
|
||||
* Create a new Date header using $timestamp (UNIX time).
|
||||
*
|
||||
* @param string $name
|
||||
* @param int|null $timestamp
|
||||
*
|
||||
@@ -113,12 +112,7 @@ class Swift_Mime_SimpleHeaderFactory implements Swift_Mime_HeaderFactory
|
||||
public function createParameterizedHeader($name, $value = null,
|
||||
$params = array())
|
||||
{
|
||||
$header = new Swift_Mime_Headers_ParameterizedHeader($name,
|
||||
$this->_encoder, (strtolower($name) == 'content-disposition')
|
||||
? $this->_paramEncoder
|
||||
: null,
|
||||
$this->_grammar
|
||||
);
|
||||
$header = new Swift_Mime_Headers_ParameterizedHeader($name, $this->_encoder, strtolower($name) == 'content-disposition' ? $this->_paramEncoder : null, $this->_grammar);
|
||||
if (isset($value)) {
|
||||
$header->setFieldBodyModel($value);
|
||||
}
|
||||
@@ -180,7 +174,14 @@ class Swift_Mime_SimpleHeaderFactory implements Swift_Mime_HeaderFactory
|
||||
$this->_paramEncoder->charsetChanged($charset);
|
||||
}
|
||||
|
||||
// -- Private methods
|
||||
/**
|
||||
* Make a deep copy of object.
|
||||
*/
|
||||
public function __clone()
|
||||
{
|
||||
$this->_encoder = clone $this->_encoder;
|
||||
$this->_paramEncoder = clone $this->_paramEncoder;
|
||||
}
|
||||
|
||||
/** Apply the charset to the Header */
|
||||
private function _setHeaderCharset(Swift_Mime_Header $header)
|
||||
|
||||
@@ -11,8 +11,6 @@
|
||||
/**
|
||||
* A collection of MIME headers.
|
||||
*
|
||||
* @package Swift
|
||||
* @subpackage Mime
|
||||
* @author Chris Corbyn
|
||||
*/
|
||||
class Swift_Mime_SimpleHeaderSet implements Swift_Mime_HeaderSet
|
||||
@@ -142,7 +140,16 @@ class Swift_Mime_SimpleHeaderSet implements Swift_Mime_HeaderSet
|
||||
{
|
||||
$lowerName = strtolower($name);
|
||||
|
||||
return array_key_exists($lowerName, $this->_headers) && array_key_exists($index, $this->_headers[$lowerName]);
|
||||
if (!array_key_exists($lowerName, $this->_headers)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (func_num_args() < 2) {
|
||||
// index was not specified, so we only need to check that there is at least one header value set
|
||||
return (bool) count($this->_headers[$lowerName]);
|
||||
}
|
||||
|
||||
return array_key_exists($index, $this->_headers[$lowerName]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -175,10 +182,18 @@ class Swift_Mime_SimpleHeaderSet implements Swift_Mime_HeaderSet
|
||||
*/
|
||||
public function get($name, $index = 0)
|
||||
{
|
||||
if ($this->has($name, $index)) {
|
||||
$lowerName = strtolower($name);
|
||||
$name = strtolower($name);
|
||||
|
||||
return $this->_headers[$lowerName][$index];
|
||||
if (func_num_args() < 2) {
|
||||
if ($this->has($name)) {
|
||||
$values = array_values($this->_headers[$name]);
|
||||
|
||||
return array_shift($values);
|
||||
}
|
||||
} else {
|
||||
if ($this->has($name, $index)) {
|
||||
return $this->_headers[$name][$index];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -209,7 +224,7 @@ class Swift_Mime_SimpleHeaderSet implements Swift_Mime_HeaderSet
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the name of all Headers
|
||||
* Return the name of all Headers.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
@@ -251,7 +266,7 @@ class Swift_Mime_SimpleHeaderSet implements Swift_Mime_HeaderSet
|
||||
/**
|
||||
* Create a new instance of this HeaderSet.
|
||||
*
|
||||
* @return Swift_Mime_HeaderSet
|
||||
* @return self
|
||||
*/
|
||||
public function newInstance()
|
||||
{
|
||||
@@ -327,8 +342,6 @@ class Swift_Mime_SimpleHeaderSet implements Swift_Mime_HeaderSet
|
||||
return $this->toString();
|
||||
}
|
||||
|
||||
// -- Private methods
|
||||
|
||||
/** Save a Header to the internal collection */
|
||||
private function _storeHeader($name, Swift_Mime_Header $header, $offset = null)
|
||||
{
|
||||
@@ -353,12 +366,13 @@ class Swift_Mime_SimpleHeaderSet implements Swift_Mime_HeaderSet
|
||||
{
|
||||
$lowerA = strtolower($a);
|
||||
$lowerB = strtolower($b);
|
||||
$aPos = array_key_exists($lowerA, $this->_order)
|
||||
? $this->_order[$lowerA]
|
||||
: -1;
|
||||
$bPos = array_key_exists($lowerB, $this->_order)
|
||||
? $this->_order[$lowerB]
|
||||
: -1;
|
||||
$aPos = array_key_exists($lowerA, $this->_order) ? $this->_order[$lowerA] : -1;
|
||||
$bPos = array_key_exists($lowerB, $this->_order) ? $this->_order[$lowerB] : -1;
|
||||
|
||||
if (-1 === $aPos && -1 === $bPos) {
|
||||
// just be sure to be determinist here
|
||||
return $a > $b ? -1 : 1;
|
||||
}
|
||||
|
||||
if ($aPos == -1) {
|
||||
return 1;
|
||||
@@ -366,7 +380,7 @@ class Swift_Mime_SimpleHeaderSet implements Swift_Mime_HeaderSet
|
||||
return -1;
|
||||
}
|
||||
|
||||
return ($aPos < $bPos) ? -1 : 1;
|
||||
return $aPos < $bPos ? -1 : 1;
|
||||
}
|
||||
|
||||
/** Test if the given Header is always displayed */
|
||||
@@ -384,4 +398,17 @@ class Swift_Mime_SimpleHeaderSet implements Swift_Mime_HeaderSet
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a deep copy of object.
|
||||
*/
|
||||
public function __clone()
|
||||
{
|
||||
$this->_factory = clone $this->_factory;
|
||||
foreach ($this->_headers as $groupKey => $headerGroup) {
|
||||
foreach ($headerGroup as $key => $header) {
|
||||
$this->_headers[$groupKey][$key] = clone $header;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,12 +11,16 @@
|
||||
/**
|
||||
* The default email message class.
|
||||
*
|
||||
* @package Swift
|
||||
* @subpackage Mime
|
||||
* @author Chris Corbyn
|
||||
*/
|
||||
class Swift_Mime_SimpleMessage extends Swift_Mime_MimePart implements Swift_Mime_Message
|
||||
{
|
||||
const PRIORITY_HIGHEST = 1;
|
||||
const PRIORITY_HIGH = 2;
|
||||
const PRIORITY_NORMAL = 3;
|
||||
const PRIORITY_LOW = 4;
|
||||
const PRIORITY_LOWEST = 5;
|
||||
|
||||
/**
|
||||
* Create a new SimpleMessage with $headers, $encoder and $cache.
|
||||
*
|
||||
@@ -45,7 +49,7 @@ class Swift_Mime_SimpleMessage extends Swift_Mime_MimePart implements Swift_Mime
|
||||
'Bcc',
|
||||
'MIME-Version',
|
||||
'Content-Type',
|
||||
'Content-Transfer-Encoding'
|
||||
'Content-Transfer-Encoding',
|
||||
));
|
||||
$this->getHeaders()->setAlwaysDisplayed(array('Date', 'Message-ID', 'From'));
|
||||
$this->getHeaders()->addTextHeader('MIME-Version', '1.0');
|
||||
@@ -69,7 +73,7 @@ class Swift_Mime_SimpleMessage extends Swift_Mime_MimePart implements Swift_Mime
|
||||
*
|
||||
* @param string $subject
|
||||
*
|
||||
* @return Swift_Mime_SimpleMessage
|
||||
* @return $this
|
||||
*/
|
||||
public function setSubject($subject)
|
||||
{
|
||||
@@ -95,7 +99,7 @@ class Swift_Mime_SimpleMessage extends Swift_Mime_MimePart implements Swift_Mime
|
||||
*
|
||||
* @param int $date
|
||||
*
|
||||
* @return Swift_Mime_SimpleMessage
|
||||
* @return $this
|
||||
*/
|
||||
public function setDate($date)
|
||||
{
|
||||
@@ -121,7 +125,7 @@ class Swift_Mime_SimpleMessage extends Swift_Mime_MimePart implements Swift_Mime
|
||||
*
|
||||
* @param string $address
|
||||
*
|
||||
* @return Swift_Mime_SimpleMessage
|
||||
* @return $this
|
||||
*/
|
||||
public function setReturnPath($address)
|
||||
{
|
||||
@@ -150,7 +154,7 @@ class Swift_Mime_SimpleMessage extends Swift_Mime_MimePart implements Swift_Mime
|
||||
* @param string $address
|
||||
* @param string $name optional
|
||||
*
|
||||
* @return Swift_Mime_SimpleMessage
|
||||
* @return $this
|
||||
*/
|
||||
public function setSender($address, $name = null)
|
||||
{
|
||||
@@ -183,7 +187,7 @@ class Swift_Mime_SimpleMessage extends Swift_Mime_MimePart implements Swift_Mime
|
||||
* @param string $address
|
||||
* @param string $name optional
|
||||
*
|
||||
* @return Swift_Mime_SimpleMessage
|
||||
* @return $this
|
||||
*/
|
||||
public function addFrom($address, $name = null)
|
||||
{
|
||||
@@ -201,10 +205,10 @@ class Swift_Mime_SimpleMessage extends Swift_Mime_MimePart implements Swift_Mime
|
||||
* If $name is passed and the first parameter is a string, this name will be
|
||||
* associated with the address.
|
||||
*
|
||||
* @param string $addresses
|
||||
* @param string|array $addresses
|
||||
* @param string $name optional
|
||||
*
|
||||
* @return Swift_Mime_SimpleMessage
|
||||
* @return $this
|
||||
*/
|
||||
public function setFrom($addresses, $name = null)
|
||||
{
|
||||
@@ -222,7 +226,7 @@ class Swift_Mime_SimpleMessage extends Swift_Mime_MimePart implements Swift_Mime
|
||||
/**
|
||||
* Get the from address of this message.
|
||||
*
|
||||
* @return string
|
||||
* @return mixed
|
||||
*/
|
||||
public function getFrom()
|
||||
{
|
||||
@@ -237,7 +241,7 @@ class Swift_Mime_SimpleMessage extends Swift_Mime_MimePart implements Swift_Mime
|
||||
* @param string $address
|
||||
* @param string $name optional
|
||||
*
|
||||
* @return Swift_Mime_SimpleMessage
|
||||
* @return $this
|
||||
*/
|
||||
public function addReplyTo($address, $name = null)
|
||||
{
|
||||
@@ -255,10 +259,10 @@ class Swift_Mime_SimpleMessage extends Swift_Mime_MimePart implements Swift_Mime
|
||||
* If $name is passed and the first parameter is a string, this name will be
|
||||
* associated with the address.
|
||||
*
|
||||
* @param string $addresses
|
||||
* @param mixed $addresses
|
||||
* @param string $name optional
|
||||
*
|
||||
* @return Swift_Mime_SimpleMessage
|
||||
* @return $this
|
||||
*/
|
||||
public function setReplyTo($addresses, $name = null)
|
||||
{
|
||||
@@ -291,7 +295,7 @@ class Swift_Mime_SimpleMessage extends Swift_Mime_MimePart implements Swift_Mime
|
||||
* @param string $address
|
||||
* @param string $name optional
|
||||
*
|
||||
* @return Swift_Mime_SimpleMessage
|
||||
* @return $this
|
||||
*/
|
||||
public function addTo($address, $name = null)
|
||||
{
|
||||
@@ -313,7 +317,7 @@ class Swift_Mime_SimpleMessage extends Swift_Mime_MimePart implements Swift_Mime
|
||||
* @param mixed $addresses
|
||||
* @param string $name optional
|
||||
*
|
||||
* @return Swift_Mime_SimpleMessage
|
||||
* @return $this
|
||||
*/
|
||||
public function setTo($addresses, $name = null)
|
||||
{
|
||||
@@ -346,7 +350,7 @@ class Swift_Mime_SimpleMessage extends Swift_Mime_MimePart implements Swift_Mime
|
||||
* @param string $address
|
||||
* @param string $name optional
|
||||
*
|
||||
* @return Swift_Mime_SimpleMessage
|
||||
* @return $this
|
||||
*/
|
||||
public function addCc($address, $name = null)
|
||||
{
|
||||
@@ -365,7 +369,7 @@ class Swift_Mime_SimpleMessage extends Swift_Mime_MimePart implements Swift_Mime
|
||||
* @param mixed $addresses
|
||||
* @param string $name optional
|
||||
*
|
||||
* @return Swift_Mime_SimpleMessage
|
||||
* @return $this
|
||||
*/
|
||||
public function setCc($addresses, $name = null)
|
||||
{
|
||||
@@ -398,7 +402,7 @@ class Swift_Mime_SimpleMessage extends Swift_Mime_MimePart implements Swift_Mime
|
||||
* @param string $address
|
||||
* @param string $name optional
|
||||
*
|
||||
* @return Swift_Mime_SimpleMessage
|
||||
* @return $this
|
||||
*/
|
||||
public function addBcc($address, $name = null)
|
||||
{
|
||||
@@ -417,7 +421,7 @@ class Swift_Mime_SimpleMessage extends Swift_Mime_MimePart implements Swift_Mime
|
||||
* @param mixed $addresses
|
||||
* @param string $name optional
|
||||
*
|
||||
* @return Swift_Mime_SimpleMessage
|
||||
* @return $this
|
||||
*/
|
||||
public function setBcc($addresses, $name = null)
|
||||
{
|
||||
@@ -449,16 +453,16 @@ class Swift_Mime_SimpleMessage extends Swift_Mime_MimePart implements Swift_Mime
|
||||
*
|
||||
* @param int $priority
|
||||
*
|
||||
* @return Swift_Mime_SimpleMessage
|
||||
* @return $this
|
||||
*/
|
||||
public function setPriority($priority)
|
||||
{
|
||||
$priorityMap = array(
|
||||
1 => 'Highest',
|
||||
2 => 'High',
|
||||
3 => 'Normal',
|
||||
4 => 'Low',
|
||||
5 => 'Lowest'
|
||||
self::PRIORITY_HIGHEST => 'Highest',
|
||||
self::PRIORITY_HIGH => 'High',
|
||||
self::PRIORITY_NORMAL => 'Normal',
|
||||
self::PRIORITY_LOW => 'Low',
|
||||
self::PRIORITY_LOWEST => 'Lowest',
|
||||
);
|
||||
$pMapKeys = array_keys($priorityMap);
|
||||
if ($priority > max($pMapKeys)) {
|
||||
@@ -467,8 +471,7 @@ class Swift_Mime_SimpleMessage extends Swift_Mime_MimePart implements Swift_Mime
|
||||
$priority = min($pMapKeys);
|
||||
}
|
||||
if (!$this->_setHeaderFieldModel('X-Priority',
|
||||
sprintf('%d (%s)', $priority, $priorityMap[$priority])))
|
||||
{
|
||||
sprintf('%d (%s)', $priority, $priorityMap[$priority]))) {
|
||||
$this->getHeaders()->addTextHeader('X-Priority',
|
||||
sprintf('%d (%s)', $priority, $priorityMap[$priority]));
|
||||
}
|
||||
@@ -494,11 +497,11 @@ class Swift_Mime_SimpleMessage extends Swift_Mime_MimePart implements Swift_Mime
|
||||
}
|
||||
|
||||
/**
|
||||
* Ask for a delivery receipt from the recipient to be sent to $addresses
|
||||
* Ask for a delivery receipt from the recipient to be sent to $addresses.
|
||||
*
|
||||
* @param array $addresses
|
||||
*
|
||||
* @return Swift_Mime_SimpleMessage
|
||||
* @return $this
|
||||
*/
|
||||
public function setReadReceiptTo($addresses)
|
||||
{
|
||||
@@ -525,7 +528,7 @@ class Swift_Mime_SimpleMessage extends Swift_Mime_MimePart implements Swift_Mime
|
||||
*
|
||||
* @param Swift_Mime_MimeEntity $entity
|
||||
*
|
||||
* @return Swift_Mime_SimpleMessage
|
||||
* @return $this
|
||||
*/
|
||||
public function attach(Swift_Mime_MimeEntity $entity)
|
||||
{
|
||||
@@ -539,7 +542,7 @@ class Swift_Mime_SimpleMessage extends Swift_Mime_MimePart implements Swift_Mime
|
||||
*
|
||||
* @param Swift_Mime_MimeEntity $entity
|
||||
*
|
||||
* @return Swift_Mime_SimpleMessage
|
||||
* @return $this
|
||||
*/
|
||||
public function detach(Swift_Mime_MimeEntity $entity)
|
||||
{
|
||||
@@ -615,8 +618,6 @@ class Swift_Mime_SimpleMessage extends Swift_Mime_MimePart implements Swift_Mime
|
||||
}
|
||||
}
|
||||
|
||||
// -- Protected methods
|
||||
|
||||
/** @see Swift_Mime_SimpleMimeEntity::_getIdField() */
|
||||
protected function _getIdField()
|
||||
{
|
||||
@@ -638,8 +639,6 @@ class Swift_Mime_SimpleMessage extends Swift_Mime_MimePart implements Swift_Mime
|
||||
return $part;
|
||||
}
|
||||
|
||||
// -- Private methods
|
||||
|
||||
/** Get the highest nesting level nested inside this message */
|
||||
private function _getTopNestingLevel()
|
||||
{
|
||||
|
||||
@@ -11,8 +11,6 @@
|
||||
/**
|
||||
* A MIME entity, in a multipart message.
|
||||
*
|
||||
* @package Swift
|
||||
* @subpackage Mime
|
||||
* @author Chris Corbyn
|
||||
*/
|
||||
class Swift_Mime_SimpleMimeEntity implements Swift_Mime_MimeEntity
|
||||
@@ -36,7 +34,7 @@ class Swift_Mime_SimpleMimeEntity implements Swift_Mime_MimeEntity
|
||||
private $_compositeRanges = array(
|
||||
'multipart/mixed' => array(self::LEVEL_TOP, self::LEVEL_MIXED),
|
||||
'multipart/alternative' => array(self::LEVEL_MIXED, self::LEVEL_ALTERNATIVE),
|
||||
'multipart/related' => array(self::LEVEL_ALTERNATIVE, self::LEVEL_RELATED)
|
||||
'multipart/related' => array(self::LEVEL_ALTERNATIVE, self::LEVEL_RELATED),
|
||||
);
|
||||
|
||||
/** A set of filter rules to define what level an entity should be nested at */
|
||||
@@ -61,7 +59,7 @@ class Swift_Mime_SimpleMimeEntity implements Swift_Mime_MimeEntity
|
||||
private $_alternativePartOrder = array(
|
||||
'text/plain' => 1,
|
||||
'text/html' => 2,
|
||||
'multipart/related' => 3
|
||||
'multipart/related' => 3,
|
||||
);
|
||||
|
||||
/** The CID of this entity */
|
||||
@@ -106,9 +104,9 @@ class Swift_Mime_SimpleMimeEntity implements Swift_Mime_MimeEntity
|
||||
(self::LEVEL_ALTERNATIVE + self::LEVEL_RELATED) => array(
|
||||
self::LEVEL_ALTERNATIVE => array(
|
||||
'text/plain' => self::LEVEL_ALTERNATIVE,
|
||||
'text/html' => self::LEVEL_RELATED
|
||||
)
|
||||
)
|
||||
'text/html' => self::LEVEL_RELATED,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
$this->_id = $this->getRandomId();
|
||||
@@ -163,7 +161,7 @@ class Swift_Mime_SimpleMimeEntity implements Swift_Mime_MimeEntity
|
||||
*
|
||||
* @param string $type
|
||||
*
|
||||
* @return Swift_Mime_SimpleMimeEntity
|
||||
* @return $this
|
||||
*/
|
||||
public function setContentType($type)
|
||||
{
|
||||
@@ -194,7 +192,7 @@ class Swift_Mime_SimpleMimeEntity implements Swift_Mime_MimeEntity
|
||||
*
|
||||
* @param string $id
|
||||
*
|
||||
* @return Swift_Mime_SimpleMimeEntity
|
||||
* @return $this
|
||||
*/
|
||||
public function setId($id)
|
||||
{
|
||||
@@ -225,7 +223,7 @@ class Swift_Mime_SimpleMimeEntity implements Swift_Mime_MimeEntity
|
||||
*
|
||||
* @param string $description
|
||||
*
|
||||
* @return Swift_Mime_SimpleMimeEntity
|
||||
* @return $this
|
||||
*/
|
||||
public function setDescription($description)
|
||||
{
|
||||
@@ -253,7 +251,7 @@ class Swift_Mime_SimpleMimeEntity implements Swift_Mime_MimeEntity
|
||||
*
|
||||
* @param int $length
|
||||
*
|
||||
* @return Swift_Mime_SimpleMimeEntity
|
||||
* @return $this
|
||||
*/
|
||||
public function setMaxLineLength($length)
|
||||
{
|
||||
@@ -265,7 +263,7 @@ class Swift_Mime_SimpleMimeEntity implements Swift_Mime_MimeEntity
|
||||
/**
|
||||
* Get all children added to this entity.
|
||||
*
|
||||
* @return array of Swift_Mime_Entity
|
||||
* @return Swift_Mime_MimeEntity[]
|
||||
*/
|
||||
public function getChildren()
|
||||
{
|
||||
@@ -275,27 +273,24 @@ class Swift_Mime_SimpleMimeEntity implements Swift_Mime_MimeEntity
|
||||
/**
|
||||
* Set all children of this entity.
|
||||
*
|
||||
* @param array $children Swift_Mime_Entity instances
|
||||
* @param Swift_Mime_MimeEntity[] $children
|
||||
* @param int $compoundLevel For internal use only
|
||||
*
|
||||
* @return Swift_Mime_SimpleMimeEntity
|
||||
* @return $this
|
||||
*/
|
||||
public function setChildren(array $children, $compoundLevel = null)
|
||||
{
|
||||
// TODO: Try to refactor this logic
|
||||
|
||||
$compoundLevel = isset($compoundLevel)
|
||||
? $compoundLevel
|
||||
: $this->_getCompoundLevel($children)
|
||||
;
|
||||
|
||||
$compoundLevel = isset($compoundLevel) ? $compoundLevel : $this->_getCompoundLevel($children);
|
||||
$immediateChildren = array();
|
||||
$grandchildren = array();
|
||||
$newContentType = $this->_userContentType;
|
||||
|
||||
foreach ($children as $child) {
|
||||
$level = $this->_getNeededChildLevel($child, $compoundLevel);
|
||||
if (empty($immediateChildren)) { //first iteration
|
||||
if (empty($immediateChildren)) {
|
||||
//first iteration
|
||||
$immediateChildren = array($child);
|
||||
} else {
|
||||
$nextLevel = $this->_getNeededChildLevel($immediateChildren[0], $compoundLevel);
|
||||
@@ -312,16 +307,15 @@ class Swift_Mime_SimpleMimeEntity implements Swift_Mime_MimeEntity
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($immediateChildren)) {
|
||||
if ($immediateChildren) {
|
||||
$lowestLevel = $this->_getNeededChildLevel($immediateChildren[0], $compoundLevel);
|
||||
|
||||
// Determine which composite media type is needed to accommodate the
|
||||
// immediate children
|
||||
foreach ($this->_compositeRanges as $mediaType => $range) {
|
||||
if ($lowestLevel > $range[0]
|
||||
&& $lowestLevel <= $range[1])
|
||||
{
|
||||
if ($lowestLevel > $range[0] && $lowestLevel <= $range[1]) {
|
||||
$newContentType = $mediaType;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -351,9 +345,7 @@ class Swift_Mime_SimpleMimeEntity implements Swift_Mime_MimeEntity
|
||||
*/
|
||||
public function getBody()
|
||||
{
|
||||
return ($this->_body instanceof Swift_OutputByteStream)
|
||||
? $this->_readStream($this->_body)
|
||||
: $this->_body;
|
||||
return $this->_body instanceof Swift_OutputByteStream ? $this->_readStream($this->_body) : $this->_body;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -363,7 +355,7 @@ class Swift_Mime_SimpleMimeEntity implements Swift_Mime_MimeEntity
|
||||
* @param mixed $body
|
||||
* @param string $contentType optional
|
||||
*
|
||||
* @return Swift_Mime_SimpleMimeEntity
|
||||
* @return $this
|
||||
*/
|
||||
public function setBody($body, $contentType = null)
|
||||
{
|
||||
@@ -394,7 +386,7 @@ class Swift_Mime_SimpleMimeEntity implements Swift_Mime_MimeEntity
|
||||
*
|
||||
* @param Swift_Mime_ContentEncoder $encoder
|
||||
*
|
||||
* @return Swift_Mime_SimpleMimeEntity
|
||||
* @return $this
|
||||
*/
|
||||
public function setEncoder(Swift_Mime_ContentEncoder $encoder)
|
||||
{
|
||||
@@ -428,9 +420,9 @@ class Swift_Mime_SimpleMimeEntity implements Swift_Mime_MimeEntity
|
||||
*
|
||||
* @param string $boundary
|
||||
*
|
||||
* @return Swift_Mime_SimpleMimeEntity
|
||||
*
|
||||
* @throws Swift_RfcComplianceException
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setBoundary($boundary)
|
||||
{
|
||||
@@ -488,12 +480,8 @@ class Swift_Mime_SimpleMimeEntity implements Swift_Mime_MimeEntity
|
||||
if ($this->_cache->hasKey($this->_cacheKey, 'body')) {
|
||||
$body = $this->_cache->getString($this->_cacheKey, 'body');
|
||||
} else {
|
||||
$body = "\r\n" . $this->_encoder->encodeString($this->getBody(), 0,
|
||||
$this->getMaxLineLength()
|
||||
);
|
||||
$this->_cache->setString($this->_cacheKey, 'body', $body,
|
||||
Swift_KeyCache::MODE_WRITE
|
||||
);
|
||||
$body = "\r\n".$this->_encoder->encodeString($this->getBody(), 0, $this->getMaxLineLength());
|
||||
$this->_cache->setString($this->_cacheKey, 'body', $body, Swift_KeyCache::MODE_WRITE);
|
||||
}
|
||||
$string .= $body;
|
||||
}
|
||||
@@ -577,10 +565,8 @@ class Swift_Mime_SimpleMimeEntity implements Swift_Mime_MimeEntity
|
||||
}
|
||||
}
|
||||
|
||||
// -- Protected methods
|
||||
|
||||
/**
|
||||
* Get the name of the header that provides the ID of this entity
|
||||
* Get the name of the header that provides the ID of this entity.
|
||||
*/
|
||||
protected function _getIdField()
|
||||
{
|
||||
@@ -595,7 +581,6 @@ class Swift_Mime_SimpleMimeEntity implements Swift_Mime_MimeEntity
|
||||
if ($this->_headers->has($field)) {
|
||||
return $this->_headers->get($field)->getFieldBodyModel();
|
||||
}
|
||||
return null; // Returning null is equivalent to no return, but is easier to read!!
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -607,9 +592,9 @@ class Swift_Mime_SimpleMimeEntity implements Swift_Mime_MimeEntity
|
||||
$this->_headers->get($field)->setFieldBodyModel($model);
|
||||
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -631,9 +616,9 @@ class Swift_Mime_SimpleMimeEntity implements Swift_Mime_MimeEntity
|
||||
$this->_headers->get($field)->setParameter($parameter, $value);
|
||||
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -700,8 +685,6 @@ class Swift_Mime_SimpleMimeEntity implements Swift_Mime_MimeEntity
|
||||
return $id;
|
||||
}
|
||||
|
||||
// -- Private methods
|
||||
|
||||
private function _readStream(Swift_OutputByteStream $os)
|
||||
{
|
||||
$string = '';
|
||||
@@ -709,6 +692,8 @@ class Swift_Mime_SimpleMimeEntity implements Swift_Mime_MimeEntity
|
||||
$string .= $bytes;
|
||||
}
|
||||
|
||||
$os->setReadPointer(0);
|
||||
|
||||
return $string;
|
||||
}
|
||||
|
||||
@@ -721,10 +706,7 @@ class Swift_Mime_SimpleMimeEntity implements Swift_Mime_MimeEntity
|
||||
|
||||
private function _assertValidBoundary($boundary)
|
||||
{
|
||||
if (!preg_match(
|
||||
'/^[a-z0-9\'\(\)\+_\-,\.\/:=\?\ ]{0,69}[a-z0-9\'\(\)\+_\-,\.\/:=\?]$/Di',
|
||||
$boundary))
|
||||
{
|
||||
if (!preg_match('/^[a-z0-9\'\(\)\+_\-,\.\/:=\?\ ]{0,69}[a-z0-9\'\(\)\+_\-,\.\/:=\?]$/Di', $boundary)) {
|
||||
throw new Swift_RfcComplianceException('Mime boundary set is not RFC 2046 compliant.');
|
||||
}
|
||||
}
|
||||
@@ -763,19 +745,16 @@ class Swift_Mime_SimpleMimeEntity implements Swift_Mime_MimeEntity
|
||||
$realLevel = $child->getNestingLevel();
|
||||
$lowercaseType = strtolower($child->getContentType());
|
||||
|
||||
if (isset($filter[$realLevel])
|
||||
&& isset($filter[$realLevel][$lowercaseType]))
|
||||
{
|
||||
if (isset($filter[$realLevel]) && isset($filter[$realLevel][$lowercaseType])) {
|
||||
return $filter[$realLevel][$lowercaseType];
|
||||
} else {
|
||||
return $realLevel;
|
||||
}
|
||||
|
||||
return $realLevel;
|
||||
}
|
||||
|
||||
private function _createChild()
|
||||
{
|
||||
return new self($this->_headers->newInstance(),
|
||||
$this->_encoder, $this->_cache, $this->_grammar);
|
||||
return new self($this->_headers->newInstance(), $this->_encoder, $this->_cache, $this->_grammar);
|
||||
}
|
||||
|
||||
private function _notifyEncoderChanged(Swift_Mime_ContentEncoder $encoder)
|
||||
@@ -807,35 +786,34 @@ class Swift_Mime_SimpleMimeEntity implements Swift_Mime_MimeEntity
|
||||
|
||||
// Sort in order of preference, if there is one
|
||||
if ($shouldSort) {
|
||||
usort($this->_immediateChildren, array($this, '_childSortAlgorithm'));
|
||||
}
|
||||
// Group the messages by order of preference
|
||||
$sorted = array();
|
||||
foreach ($this->_immediateChildren as $child) {
|
||||
$type = $child->getContentType();
|
||||
$level = array_key_exists($type, $this->_alternativePartOrder) ? $this->_alternativePartOrder[$type] : max($this->_alternativePartOrder) + 1;
|
||||
|
||||
if (empty($sorted[$level])) {
|
||||
$sorted[$level] = array();
|
||||
}
|
||||
|
||||
private function _childSortAlgorithm($a, $b)
|
||||
{
|
||||
$typePrefs = array();
|
||||
$types = array(
|
||||
strtolower($a->getContentType()),
|
||||
strtolower($b->getContentType())
|
||||
);
|
||||
foreach ($types as $type) {
|
||||
$typePrefs[] = (array_key_exists($type, $this->_alternativePartOrder))
|
||||
? $this->_alternativePartOrder[$type]
|
||||
: (max($this->_alternativePartOrder) + 1);
|
||||
$sorted[$level][] = $child;
|
||||
}
|
||||
|
||||
return ($typePrefs[0] >= $typePrefs[1]) ? 1 : -1;
|
||||
}
|
||||
ksort($sorted);
|
||||
|
||||
// -- Destructor
|
||||
$this->_immediateChildren = array_reduce($sorted, 'array_merge', array());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Empties it's own contents from the cache.
|
||||
*/
|
||||
public function __destruct()
|
||||
{
|
||||
if ($this->_cache instanceof Swift_KeyCache) {
|
||||
$this->_cache->clearAll($this->_cacheKey);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Throws an Exception if the id passed does not comply with RFC 2822.
|
||||
@@ -846,15 +824,23 @@ class Swift_Mime_SimpleMimeEntity implements Swift_Mime_MimeEntity
|
||||
*/
|
||||
private function _assertValidId($id)
|
||||
{
|
||||
if (!preg_match(
|
||||
'/^' . $this->_grammar->getDefinition('id-left') . '@' .
|
||||
$this->_grammar->getDefinition('id-right') . '$/D',
|
||||
$id
|
||||
))
|
||||
if (!preg_match('/^'.$this->_grammar->getDefinition('id-left').'@'.$this->_grammar->getDefinition('id-right').'$/D', $id)) {
|
||||
throw new Swift_RfcComplianceException('Invalid ID given <'.$id.'>');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a deep copy of object.
|
||||
*/
|
||||
public function __clone()
|
||||
{
|
||||
throw new Swift_RfcComplianceException(
|
||||
'Invalid ID given <' . $id . '>'
|
||||
);
|
||||
}
|
||||
$this->_headers = clone $this->_headers;
|
||||
$this->_encoder = clone $this->_encoder;
|
||||
$this->_cacheKey = md5(uniqid(getmypid().mt_rand(), true));
|
||||
$children = array();
|
||||
foreach ($this->_children as $pos => $child) {
|
||||
$children[$pos] = clone $child;
|
||||
}
|
||||
$this->setChildren($children);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,8 +11,6 @@
|
||||
/**
|
||||
* A MIME part, in a multipart message.
|
||||
*
|
||||
* @package Swift
|
||||
* @subpackage Mime
|
||||
* @author Chris Corbyn
|
||||
*/
|
||||
class Swift_MimePart extends Swift_Mime_MimePart
|
||||
@@ -52,7 +50,7 @@ class Swift_MimePart extends Swift_Mime_MimePart
|
||||
* @param string $contentType
|
||||
* @param string $charset
|
||||
*
|
||||
* @return Swift_Mime_MimePart
|
||||
* @return self
|
||||
*/
|
||||
public static function newInstance($body = null, $contentType = null, $charset = null)
|
||||
{
|
||||
|
||||
@@ -11,14 +11,10 @@
|
||||
/**
|
||||
* Pretends messages have been sent, but just ignores them.
|
||||
*
|
||||
* @package Swift
|
||||
* @author Fabien Potencier
|
||||
*/
|
||||
class Swift_NullTransport extends Swift_Transport_NullTransport
|
||||
{
|
||||
/**
|
||||
* Create a new NullTransport.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
call_user_func_array(
|
||||
@@ -31,7 +27,7 @@ class Swift_NullTransport extends Swift_Transport_NullTransport
|
||||
/**
|
||||
* Create a new NullTransport instance.
|
||||
*
|
||||
* @return Swift_NullTransport
|
||||
* @return self
|
||||
*/
|
||||
public static function newInstance()
|
||||
{
|
||||
|
||||
@@ -14,8 +14,6 @@
|
||||
* Classes implementing this interface may use a subsystem which requires less
|
||||
* memory than working with large strings of data.
|
||||
*
|
||||
* @package Swift
|
||||
* @subpackage ByteStream
|
||||
* @author Chris Corbyn
|
||||
*/
|
||||
interface Swift_OutputByteStream
|
||||
@@ -29,9 +27,9 @@ interface Swift_OutputByteStream
|
||||
*
|
||||
* @param int $length
|
||||
*
|
||||
* @return string|bool
|
||||
*
|
||||
* @throws Swift_IoException
|
||||
*
|
||||
* @return string|bool
|
||||
*/
|
||||
public function read($length);
|
||||
|
||||
@@ -40,9 +38,9 @@ interface Swift_OutputByteStream
|
||||
*
|
||||
* @param int $byteOffset
|
||||
*
|
||||
* @return bool
|
||||
*
|
||||
* @throws Swift_IoException
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function setReadPointer($byteOffset);
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user