diff --git a/composer.lock b/composer.lock index 20169e897..d6918f9f4 100644 --- a/composer.lock +++ b/composer.lock @@ -2482,28 +2482,29 @@ }, { "name": "swiftmailer/swiftmailer", - "version": "v5.3.1", + "version": "v5.4.5", "source": { "type": "git", "url": "https://github.com/swiftmailer/swiftmailer.git", - "reference": "c5f963e7f9d6f6438fda4f22d5cc2db296ec621a" + "reference": "cd142238a339459b10da3d8234220963f392540c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/swiftmailer/swiftmailer/zipball/c5f963e7f9d6f6438fda4f22d5cc2db296ec621a", - "reference": "c5f963e7f9d6f6438fda4f22d5cc2db296ec621a", + "url": "https://api.github.com/repos/swiftmailer/swiftmailer/zipball/cd142238a339459b10da3d8234220963f392540c", + "reference": "cd142238a339459b10da3d8234220963f392540c", "shasum": "" }, "require": { "php": ">=5.3.3" }, "require-dev": { - "mockery/mockery": "~0.9.1" + "mockery/mockery": "~0.9.1", + "symfony/phpunit-bridge": "~3.2" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "5.3-dev" + "dev-master": "5.4-dev" } }, "autoload": { @@ -2527,10 +2528,11 @@ "description": "Swiftmailer, free feature-rich PHP mailer", "homepage": "http://swiftmailer.org", "keywords": [ + "email", "mail", "mailer" ], - "time": "2014-12-05 14:17:14" + "time": "2016-12-29 10:02:40" }, { "name": "symfony/console", diff --git a/composer/autoload_files.php b/composer/autoload_files.php index fcf30f71f..dd1cda08a 100644 --- a/composer/autoload_files.php +++ b/composer/autoload_files.php @@ -17,7 +17,7 @@ 'fe1bcd0336136e435eaf197895daf81a' => $vendorDir . '/nikic/php-parser/lib/bootstrap.php', 'ebdb698ed4152ae445614b69b5e4bb6a' => $vendorDir . '/sabre/http/lib/functions.php', '5255c38a0faeba867671b61dfda6d864' => $vendorDir . '/paragonie/random_compat/lib/random.php', - '2c102faa651ef8ea5874edb585946bce' => $vendorDir . '/swiftmailer/swiftmailer/lib/swift_required.php', '023d27dca8066ef29e6739335ea73bad' => $vendorDir . '/symfony/polyfill-php70/bootstrap.php', 'decc78cc4436b1292c6c0d151b19445c' => $vendorDir . '/phpseclib/phpseclib/phpseclib/bootstrap.php', + '2c102faa651ef8ea5874edb585946bce' => $vendorDir . '/swiftmailer/swiftmailer/lib/swift_required.php', ); diff --git a/composer/autoload_static.php b/composer/autoload_static.php index c1a9939f0..1818333a5 100644 --- a/composer/autoload_static.php +++ b/composer/autoload_static.php @@ -18,9 +18,9 @@ class ComposerStaticInit2f23f73bc0cc116b4b1eee1521aa8652 'fe1bcd0336136e435eaf197895daf81a' => __DIR__ . '/..' . '/nikic/php-parser/lib/bootstrap.php', 'ebdb698ed4152ae445614b69b5e4bb6a' => __DIR__ . '/..' . '/sabre/http/lib/functions.php', '5255c38a0faeba867671b61dfda6d864' => __DIR__ . '/..' . '/paragonie/random_compat/lib/random.php', - '2c102faa651ef8ea5874edb585946bce' => __DIR__ . '/..' . '/swiftmailer/swiftmailer/lib/swift_required.php', '023d27dca8066ef29e6739335ea73bad' => __DIR__ . '/..' . '/symfony/polyfill-php70/bootstrap.php', 'decc78cc4436b1292c6c0d151b19445c' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/bootstrap.php', + '2c102faa651ef8ea5874edb585946bce' => __DIR__ . '/..' . '/swiftmailer/swiftmailer/lib/swift_required.php', ); public static $prefixLengthsPsr4 = array ( diff --git a/composer/installed.json b/composer/installed.json index 1c6c57483..d14f99d96 100644 --- a/composer/installed.json +++ b/composer/installed.json @@ -344,60 +344,6 @@ "minify" ] }, - { - "name": "swiftmailer/swiftmailer", - "version": "v5.3.1", - "version_normalized": "5.3.1.0", - "source": { - "type": "git", - "url": "https://github.com/swiftmailer/swiftmailer.git", - "reference": "c5f963e7f9d6f6438fda4f22d5cc2db296ec621a" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/swiftmailer/swiftmailer/zipball/c5f963e7f9d6f6438fda4f22d5cc2db296ec621a", - "reference": "c5f963e7f9d6f6438fda4f22d5cc2db296ec621a", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "require-dev": { - "mockery/mockery": "~0.9.1" - }, - "time": "2014-12-05 14:17:14", - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "5.3-dev" - } - }, - "installation-source": "dist", - "autoload": { - "files": [ - "lib/swift_required.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Chris Corbyn" - }, - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - } - ], - "description": "Swiftmailer, free feature-rich PHP mailer", - "homepage": "http://swiftmailer.org", - "keywords": [ - "mail", - "mailer" - ] - }, { "name": "guzzlehttp/streams", "version": "3.0.0", @@ -2987,5 +2933,61 @@ "uri", "url" ] + }, + { + "name": "swiftmailer/swiftmailer", + "version": "v5.4.5", + "version_normalized": "5.4.5.0", + "source": { + "type": "git", + "url": "https://github.com/swiftmailer/swiftmailer.git", + "reference": "cd142238a339459b10da3d8234220963f392540c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/swiftmailer/swiftmailer/zipball/cd142238a339459b10da3d8234220963f392540c", + "reference": "cd142238a339459b10da3d8234220963f392540c", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "mockery/mockery": "~0.9.1", + "symfony/phpunit-bridge": "~3.2" + }, + "time": "2016-12-29 10:02:40", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "5.4-dev" + } + }, + "installation-source": "dist", + "autoload": { + "files": [ + "lib/swift_required.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Chris Corbyn" + }, + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + } + ], + "description": "Swiftmailer, free feature-rich PHP mailer", + "homepage": "http://swiftmailer.org", + "keywords": [ + "email", + "mail", + "mailer" + ] } ] diff --git a/swiftmailer/swiftmailer/lib/classes/Swift.php b/swiftmailer/swiftmailer/lib/classes/Swift.php index 729b9bb2f..82c381b73 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift.php @@ -18,7 +18,7 @@ abstract class Swift { /** Swift Mailer Version number generated during dist release process */ const VERSION = '@SWIFT_VERSION_NUMBER@'; - + public static $initialized = false; public static $inits = array(); @@ -47,7 +47,7 @@ public static function autoload($class) return; } - $path = dirname(__FILE__).'/'.str_replace('_', '/', $class).'.php'; + $path = __DIR__.'/'.str_replace('_', '/', $class).'.php'; if (!file_exists($path)) { return; diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Attachment.php b/swiftmailer/swiftmailer/lib/classes/Swift/Attachment.php index 32759e0d8..a95bccfdf 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Attachment.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Attachment.php @@ -11,7 +11,7 @@ /** * Attachment class for attaching files to a {@link Swift_Mime_Message}. * - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_Attachment extends Swift_Mime_Attachment { diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/ByteStream/AbstractFilterableInputStream.php b/swiftmailer/swiftmailer/lib/classes/Swift/ByteStream/AbstractFilterableInputStream.php index 3e597d17c..a7b0e3a62 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/ByteStream/AbstractFilterableInputStream.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/ByteStream/AbstractFilterableInputStream.php @@ -11,7 +11,7 @@ /** * Provides the base functionality for an InputStream supporting filters. * - * @author Chris Corbyn + * @author Chris Corbyn */ abstract class Swift_ByteStream_AbstractFilterableInputStream implements Swift_InputByteStream, Swift_Filterable { @@ -22,6 +22,8 @@ abstract class Swift_ByteStream_AbstractFilterableInputStream implements Swift_I /** * StreamFilters. + * + * @var Swift_StreamFilter[] */ private $_filters = array(); @@ -75,9 +77,9 @@ public function removeFilter($key) * * @param string $bytes * - * @return int - * * @throws Swift_IoException + * + * @return int */ public function write($bytes) { diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/ByteStream/ArrayByteStream.php b/swiftmailer/swiftmailer/lib/classes/Swift/ByteStream/ArrayByteStream.php index 186a7c287..ef05a6d5e 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/ByteStream/ArrayByteStream.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/ByteStream/ArrayByteStream.php @@ -11,7 +11,7 @@ /** * Allows reading and writing of bytes to and from an array. * - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_ByteStream_ArrayByteStream implements Swift_InputByteStream, Swift_OutputByteStream { @@ -23,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 */ @@ -70,7 +70,7 @@ public function __construct($stack = null) * remaining bytes are given instead. If no bytes are remaining at all, boolean * false is returned. * - * @param int $length + * @param int $length * * @return string */ @@ -82,9 +82,7 @@ public function read($length) // 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]; @@ -152,7 +150,7 @@ public function unbind(Swift_InputByteStream $is) /** * Move the internal read pointer to $byteOffset in the stream. * - * @param int $byteOffset + * @param int $byteOffset * * @return bool */ diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/ByteStream/FileByteStream.php b/swiftmailer/swiftmailer/lib/classes/Swift/ByteStream/FileByteStream.php index 6c1446232..9ed852310 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/ByteStream/FileByteStream.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/ByteStream/FileByteStream.php @@ -11,7 +11,7 @@ /** * Allows reading and writing of bytes to and from a file. * - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_ByteStream_FileByteStream extends Swift_ByteStream_AbstractFilterableInputStream implements Swift_FileStream { @@ -39,8 +39,8 @@ class Swift_ByteStream_FileByteStream extends Swift_ByteStream_AbstractFilterabl /** * Create a new FileByteStream for $path. * - * @param string $path - * @param bool $writable if true + * @param string $path + * @param bool $writable if true */ public function __construct($path, $writable = false) { @@ -73,11 +73,11 @@ public function getPath() * remaining bytes are given instead. If no bytes are remaining at all, boolean * false is returned. * - * @param int $length - * - * @return string|bool + * @param int $length * * @throws Swift_IoException + * + * @return string|bool */ public function read($length) { @@ -111,7 +111,7 @@ public function read($length) /** * Move the internal read pointer to $byteOffset in the stream. * - * @param int $byteOffset + * @param int $byteOffset * * @return bool */ @@ -139,11 +139,13 @@ protected function _flush() 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.']' ); } + $this->_reader = $pointer; if ($this->_offset != 0) { $this->_getReadStreamSeekableStatus(); $this->_seekReadStreamToPosition($this->_offset); @@ -191,8 +193,8 @@ private function _seekReadStreamToPosition($offset) } if ($this->_seekable === false) { $currentPos = ftell($this->_reader); - if ($currentPos<$offset) { - $toDiscard = $offset-$currentPos; + if ($currentPos < $offset) { + $toDiscard = $offset - $currentPos; fread($this->_reader, $toDiscard); return; diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/ByteStream/TemporaryFileByteStream.php b/swiftmailer/swiftmailer/lib/classes/Swift/ByteStream/TemporaryFileByteStream.php index eb33151bb..1c9a80c03 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/ByteStream/TemporaryFileByteStream.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/ByteStream/TemporaryFileByteStream.php @@ -9,7 +9,7 @@ */ /** - * @author Romain-Geissler + * @author Romain-Geissler */ class Swift_ByteStream_TemporaryFileByteStream extends Swift_ByteStream_FileByteStream { diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/CharacterReader.php b/swiftmailer/swiftmailer/lib/classes/Swift/CharacterReader.php index febd77eb5..3d5e854a8 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/CharacterReader.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/CharacterReader.php @@ -11,8 +11,8 @@ /** * Analyzes characters for a specific character set. * - * @author Chris Corbyn - * @author Xavier De Cock + * @author Chris Corbyn + * @author Xavier De Cock */ interface Swift_CharacterReader { @@ -21,12 +21,12 @@ interface Swift_CharacterReader const MAP_TYPE_POSITIONS = 0x03; /** - * Returns the complete character map + * Returns the complete character map. * - * @param string $string - * @param int $startOffset - * @param array $currentMap - * @param mixed $ignoredChars + * @param string $string + * @param int $startOffset + * @param array $currentMap + * @param mixed $ignoredChars * * @return int */ diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/CharacterReader/GenericFixedWidthReader.php b/swiftmailer/swiftmailer/lib/classes/Swift/CharacterReader/GenericFixedWidthReader.php index d0c8698df..6a18e1dd1 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/CharacterReader/GenericFixedWidthReader.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/CharacterReader/GenericFixedWidthReader.php @@ -11,8 +11,8 @@ /** * Provides fixed-width byte sizes for reading fixed-width character sets. * - * @author Chris Corbyn - * @author Xavier De Cock + * @author Chris Corbyn + * @author Xavier De Cock */ class Swift_CharacterReader_GenericFixedWidthReader implements Swift_CharacterReader { @@ -26,7 +26,7 @@ class Swift_CharacterReader_GenericFixedWidthReader implements Swift_CharacterRe /** * Creates a new GenericFixedWidthReader using $width bytes per character. * - * @param int $width + * @param int $width */ public function __construct($width) { @@ -36,10 +36,10 @@ public function __construct($width) /** * Returns the complete character map. * - * @param string $string - * @param int $startOffset - * @param array $currentMap - * @param mixed $ignoredChars + * @param string $string + * @param int $startOffset + * @param array $currentMap + * @param mixed $ignoredChars * * @return int */ @@ -48,7 +48,7 @@ public function getCharPositions($string, $startOffset, &$currentMap, &$ignoredC $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; @@ -73,8 +73,8 @@ public function getMapType() * A value of zero means this is already a valid character. * A value of -1 means this cannot possibly be a valid character. * - * @param string $bytes - * @param int $size + * @param string $bytes + * @param int $size * * @return int */ @@ -82,7 +82,7 @@ public function validateByteSequence($bytes, $size) { $needed = $this->_width - $size; - return ($needed > -1) ? $needed : -1; + return $needed > -1 ? $needed : -1; } /** diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/CharacterReader/UsAsciiReader.php b/swiftmailer/swiftmailer/lib/classes/Swift/CharacterReader/UsAsciiReader.php index 229c567f6..67da48f6c 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/CharacterReader/UsAsciiReader.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/CharacterReader/UsAsciiReader.php @@ -11,17 +11,17 @@ /** * Analyzes US-ASCII characters. * - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_CharacterReader_UsAsciiReader implements Swift_CharacterReader { /** * Returns the complete character map. * - * @param string $string - * @param int $startOffset - * @param array $currentMap - * @param string $ignoredChars + * @param string $string + * @param int $startOffset + * @param array $currentMap + * @param string $ignoredChars * * @return int */ @@ -30,9 +30,9 @@ public function getCharPositions($string, $startOffset, &$currentMap, &$ignoredC $strlen = strlen($string); $ignoredChars = ''; for ($i = 0; $i < $strlen; ++$i) { - if ($string[$i]>"\x07F") { + if ($string[$i] > "\x07F") { // Invalid char - $currentMap[$i+$startOffset] = $string[$i]; + $currentMap[$i + $startOffset] = $string[$i]; } } @@ -40,9 +40,9 @@ public function getCharPositions($string, $startOffset, &$currentMap, &$ignoredC } /** - * Returns mapType + * Returns mapType. * - * @return int mapType + * @return int mapType */ public function getMapType() { @@ -57,8 +57,8 @@ public function getMapType() * A value of zero means this is already a valid character. * A value of -1 means this cannot possibly be a valid character. * - * @param string $bytes - * @param int $size + * @param string $bytes + * @param int $size * * @return int */ @@ -67,9 +67,9 @@ public function validateByteSequence($bytes, $size) $byte = reset($bytes); if (1 == count($bytes) && $byte >= 0x00 && $byte <= 0x7F) { return 0; - } else { - return -1; } + + return -1; } /** diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/CharacterReader/Utf8Reader.php b/swiftmailer/swiftmailer/lib/classes/Swift/CharacterReader/Utf8Reader.php index aebbecf66..7379bda25 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/CharacterReader/Utf8Reader.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/CharacterReader/Utf8Reader.php @@ -11,8 +11,8 @@ /** * Analyzes UTF-8 characters. * - * @author Chris Corbyn - * @author Xavier De Cock + * @author Chris Corbyn + * @author Xavier De Cock */ class Swift_CharacterReader_Utf8Reader implements Swift_CharacterReader { @@ -75,16 +75,16 @@ class Swift_CharacterReader_Utf8Reader implements Swift_CharacterReader /** * Returns the complete character map. * - * @param string $string - * @param int $startOffset - * @param array $currentMap - * @param mixed $ignoredChars + * @param string $string + * @param int $startOffset + * @param array $currentMap + * @param mixed $ignoredChars * * @return int */ public function getCharPositions($string, $startOffset, &$currentMap, &$ignoredChars) { - if (!isset($currentMap['i']) || ! isset($currentMap['p'])) { + if (!isset($currentMap['i']) || !isset($currentMap['p'])) { $currentMap['p'] = $currentMap['i'] = array(); } @@ -134,7 +134,7 @@ public function getCharPositions($string, $startOffset, &$currentMap, &$ignoredC /** * Returns mapType. * - * @return int mapType + * @return int mapType */ public function getMapType() { @@ -149,22 +149,19 @@ public function getMapType() * A value of zero means this is already a valid character. * A value of -1 means this cannot possibly be a valid character. * - * @param string $bytes - * @param int $size + * @param string $bytes + * @param int $size * * @return int */ public function validateByteSequence($bytes, $size) { - if ($size<1) { + if ($size < 1) { return -1; } $needed = self::$length_map[$bytes[0]] - $size; - return ($needed > -1) - ? $needed - : -1 - ; + return $needed > -1 ? $needed : -1; } /** diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/CharacterReaderFactory.php b/swiftmailer/swiftmailer/lib/classes/Swift/CharacterReaderFactory.php index 5bf38b8bf..15b6c6920 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/CharacterReaderFactory.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/CharacterReaderFactory.php @@ -11,7 +11,7 @@ /** * A factory for creating CharacterReaders. * - * @author Chris Corbyn + * @author Chris Corbyn */ interface Swift_CharacterReaderFactory { diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/CharacterReaderFactory/SimpleCharacterReaderFactory.php b/swiftmailer/swiftmailer/lib/classes/Swift/CharacterReaderFactory/SimpleCharacterReaderFactory.php index e08445eae..9171a0bac 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/CharacterReaderFactory/SimpleCharacterReaderFactory.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/CharacterReaderFactory/SimpleCharacterReaderFactory.php @@ -11,7 +11,7 @@ /** * Standard factory for creating CharacterReaders. * - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_CharacterReaderFactory_SimpleCharacterReaderFactory implements Swift_CharacterReaderFactory { diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/CharacterStream.php b/swiftmailer/swiftmailer/lib/classes/Swift/CharacterStream.php index aa46779e7..717924f5d 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/CharacterStream.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/CharacterStream.php @@ -15,7 +15,7 @@ * Classes implementing this interface may use a subsystem which requires less * memory than working with large strings of data. * - * @author Chris Corbyn + * @author Chris Corbyn */ interface Swift_CharacterStream { @@ -52,7 +52,7 @@ public function importString($string); * Read $length characters from the stream and move the internal pointer * $length further into the stream. * - * @param int $length + * @param int $length * * @return string */ @@ -62,7 +62,7 @@ public function read($length); * Read $length characters from the stream and return a 1-dimensional array * containing there octet values. * - * @param int $length + * @param int $length * * @return int[] */ @@ -78,7 +78,7 @@ public function write($chars); /** * Move the internal pointer to $charOffset in the stream. * - * @param int $charOffset + * @param int $charOffset */ public function setPointer($charOffset); diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/CharacterStream/ArrayCharacterStream.php b/swiftmailer/swiftmailer/lib/classes/Swift/CharacterStream/ArrayCharacterStream.php index 0cfadd49a..d695a6e17 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/CharacterStream/ArrayCharacterStream.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/CharacterStream/ArrayCharacterStream.php @@ -11,7 +11,7 @@ /** * A CharacterStream implementation which stores characters in an internal array. * - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_CharacterStream_ArrayCharacterStream implements Swift_CharacterStream { @@ -121,7 +121,7 @@ public function importString($string) * Read $length characters from the stream and move the internal pointer * $length further into the stream. * - * @param int $length + * @param int $length * * @return string */ @@ -153,7 +153,7 @@ public function read($length) * Read $length characters from the stream and return a 1-dimensional array * containing there octet values. * - * @param int $length + * @param int $length * * @return integer[] */ @@ -244,7 +244,7 @@ public function write($chars) /** * Move the internal pointer to $charOffset in the stream. * - * @param int $charOffset + * @param int $charOffset */ public function setPointer($charOffset) { diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/CharacterStream/NgCharacterStream.php b/swiftmailer/swiftmailer/lib/classes/Swift/CharacterStream/NgCharacterStream.php index b962e403c..58bd140fd 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/CharacterStream/NgCharacterStream.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/CharacterStream/NgCharacterStream.php @@ -11,9 +11,8 @@ /** * A CharacterStream implementation which stores characters in an internal array. * - * @author Xavier De Cock + * @author Xavier De Cock */ - class Swift_CharacterStream_NgCharacterStream implements Swift_CharacterStream { /** @@ -45,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 */ @@ -156,7 +155,7 @@ public function importString($string) /** * @see Swift_CharacterStream::read() * - * @param int $length + * @param int $length * * @return string */ @@ -166,12 +165,10 @@ public function read($length) 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; + $len = $length * $this->_map; $ret = substr($this->_datas, $this->_currentPos * $this->_map, $len); @@ -179,13 +176,9 @@ public function read($length) 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])) { + if (isset($this->_map[$this->_currentPos])) { $ret .= '?'; } else { $ret .= $this->_datas[$this->_currentPos]; @@ -195,13 +188,11 @@ public function read($length) 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) { - $start = $this->_map['p'][$this->_currentPos-1]; + if ($this->_currentPos > 0) { + $start = $this->_map['p'][$this->_currentPos - 1]; } $to = $start; for (; $this->_currentPos < $end; ++$this->_currentPos) { @@ -222,9 +213,9 @@ public function read($length) /** * @see Swift_CharacterStream::readBytes() * - * @param int $length + * @param int $length * - * @return integer[] + * @return int[] */ public function readBytes($length) { @@ -241,11 +232,11 @@ public function readBytes($length) /** * @see Swift_CharacterStream::setPointer() * - * @param int $charOffset + * @param int $charOffset */ public function setPointer($charOffset) { - if ($this->_charCount<$charOffset) { + if ($this->_charCount < $charOffset) { $charOffset = $this->_charCount; } $this->_currentPos = $charOffset; @@ -268,7 +259,7 @@ public function write($chars) $this->_datas .= $chars; $this->_charCount += $this->_charReader->getCharPositions(substr($this->_datas, $this->_datasSize), $this->_datasSize, $this->_map, $ignored); if ($ignored !== false) { - $this->_datasSize = strlen($this->_datas)-strlen($ignored); + $this->_datasSize = strlen($this->_datas) - strlen($ignored); } else { $this->_datasSize = strlen($this->_datas); } diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/ConfigurableSpool.php b/swiftmailer/swiftmailer/lib/classes/Swift/ConfigurableSpool.php index df87527f6..4ae5bacfc 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/ConfigurableSpool.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/ConfigurableSpool.php @@ -11,7 +11,7 @@ /** * Base class for Spools (implements time and message limits). * - * @author Fabien Potencier + * @author Fabien Potencier */ abstract class Swift_ConfigurableSpool implements Swift_Spool { @@ -24,7 +24,7 @@ abstract class Swift_ConfigurableSpool implements Swift_Spool /** * Sets the maximum number of messages to send per flush. * - * @param int $limit + * @param int $limit */ public function setMessageLimit($limit) { @@ -34,7 +34,7 @@ public function setMessageLimit($limit) /** * Gets the maximum number of messages to send per flush. * - * @return int The limit + * @return int The limit */ public function getMessageLimit() { @@ -44,7 +44,7 @@ public function getMessageLimit() /** * Sets the time limit (in seconds) per flush. * - * @param int $limit The limit + * @param int $limit The limit */ public function setTimeLimit($limit) { @@ -54,7 +54,7 @@ public function setTimeLimit($limit) /** * Gets the time limit (in seconds) per flush. * - * @return int The limit + * @return int The limit */ public function getTimeLimit() { diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/DependencyContainer.php b/swiftmailer/swiftmailer/lib/classes/Swift/DependencyContainer.php index 1d8cb3a39..8c1074a3a 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/DependencyContainer.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/DependencyContainer.php @@ -11,7 +11,7 @@ /** * Dependency Injection container. * - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_DependencyContainer { @@ -91,9 +91,9 @@ public function has($itemName) * * @param string $itemName * - * @return mixed - * * @throws Swift_DependencyException If the dependency is not found + * + * @return mixed */ public function lookup($itemName) { @@ -138,6 +138,7 @@ public function createDependenciesFor($itemName) * 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 @@ -147,7 +148,7 @@ public function createDependenciesFor($itemName) public function register($itemName) { $this->_store[$itemName] = array(); - $this->_endPoint = & $this->_store[$itemName]; + $this->_endPoint = &$this->_store[$itemName]; return $this; } @@ -163,7 +164,7 @@ public function register($itemName) */ public function asValue($value) { - $endPoint = & $this->_getEndPoint(); + $endPoint = &$this->_getEndPoint(); $endPoint['lookupType'] = self::TYPE_VALUE; $endPoint['value'] = $value; @@ -179,7 +180,7 @@ public function asValue($value) */ public function asAliasOf($lookup) { - $endPoint = & $this->_getEndPoint(); + $endPoint = &$this->_getEndPoint(); $endPoint['lookupType'] = self::TYPE_ALIAS; $endPoint['ref'] = $lookup; @@ -201,7 +202,7 @@ public function asAliasOf($lookup) */ public function asNewInstanceOf($className) { - $endPoint = & $this->_getEndPoint(); + $endPoint = &$this->_getEndPoint(); $endPoint['lookupType'] = self::TYPE_INSTANCE; $endPoint['className'] = $className; @@ -219,7 +220,7 @@ public function asNewInstanceOf($className) */ public function asSharedInstanceOf($className) { - $endPoint = & $this->_getEndPoint(); + $endPoint = &$this->_getEndPoint(); $endPoint['lookupType'] = self::TYPE_SHARED; $endPoint['className'] = $className; @@ -239,7 +240,7 @@ public function asSharedInstanceOf($className) */ public function withDependencies(array $lookups) { - $endPoint = & $this->_getEndPoint(); + $endPoint = &$this->_getEndPoint(); $endPoint['args'] = array(); foreach ($lookups as $lookup) { $this->addConstructorLookup($lookup); @@ -260,7 +261,7 @@ public function withDependencies(array $lookups) */ public function addConstructorValue($value) { - $endPoint = & $this->_getEndPoint(); + $endPoint = &$this->_getEndPoint(); if (!isset($endPoint['args'])) { $endPoint['args'] = array(); } @@ -281,7 +282,7 @@ public function addConstructorValue($value) */ public function addConstructorLookup($lookup) { - $endPoint = & $this->_getEndPoint(); + $endPoint = &$this->_getEndPoint(); if (!isset($this->_endPoint['args'])) { $endPoint['args'] = array(); } @@ -310,9 +311,9 @@ private function _createNewInstance($itemName) return $reflector->newInstanceArgs( $this->createDependenciesFor($itemName) ); - } else { - return $reflector->newInstance(); } + + return $reflector->newInstance(); } /** Create and register a shared instance of $itemName */ @@ -365,8 +366,8 @@ private function _lookupRecursive($item) } return $collection; - } else { - return $this->lookup($item); } + + return $this->lookup($item); } } diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/DependencyException.php b/swiftmailer/swiftmailer/lib/classes/Swift/DependencyException.php index 0a96232e9..799d38d83 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/DependencyException.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/DependencyException.php @@ -11,7 +11,7 @@ /** * DependencyException gets thrown when a requested dependency is missing. * - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_DependencyException extends Swift_SwiftException { diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/EmbeddedFile.php b/swiftmailer/swiftmailer/lib/classes/Swift/EmbeddedFile.php index 486ad6083..d8c72ad4d 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/EmbeddedFile.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/EmbeddedFile.php @@ -11,7 +11,7 @@ /** * An embedded file, in a multipart message. * - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_EmbeddedFile extends Swift_Mime_EmbeddedFile { diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Encoder.php b/swiftmailer/swiftmailer/lib/classes/Swift/Encoder.php index 7c6564245..2073abca1 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Encoder.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Encoder.php @@ -10,6 +10,7 @@ /** * Interface for all Encoder schemes. + * * @author Chris Corbyn */ interface Swift_Encoder extends Swift_Mime_CharsetObserver @@ -17,9 +18,9 @@ interface Swift_Encoder extends Swift_Mime_CharsetObserver /** * Encode a given string to produce an encoded string. * - * @param string $string - * @param int $firstLineOffset if first line needs to be shorter - * @param int $maxLineLength - 0 indicates the default length for this encoding + * @param string $string + * @param int $firstLineOffset if first line needs to be shorter + * @param int $maxLineLength - 0 indicates the default length for this encoding * * @return string */ diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Encoder/Base64Encoder.php b/swiftmailer/swiftmailer/lib/classes/Swift/Encoder/Base64Encoder.php index 99cfb0252..0e7b2a1b0 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Encoder/Base64Encoder.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Encoder/Base64Encoder.php @@ -11,7 +11,7 @@ /** * Handles Base 64 Encoding in Swift Mailer. * - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_Encoder_Base64Encoder implements Swift_Encoder { @@ -22,9 +22,9 @@ class Swift_Encoder_Base64Encoder implements Swift_Encoder * If the first line needs to be shorter, indicate the difference with * $firstLineOffset. * - * @param string $string to encode - * @param int $firstLineOffset - * @param int $maxLineLength optional, 0 indicates the default of 76 bytes + * @param string $string to encode + * @param int $firstLineOffset + * @param int $maxLineLength optional, 0 indicates the default of 76 bytes * * @return string */ diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Encoder/QpEncoder.php b/swiftmailer/swiftmailer/lib/classes/Swift/Encoder/QpEncoder.php index 81836f77b..8a81fe397 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Encoder/QpEncoder.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Encoder/QpEncoder.php @@ -13,7 +13,7 @@ * * Possibly the most accurate RFC 2045 QP implementation found in PHP. * - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_Encoder_QpEncoder implements Swift_Encoder { @@ -37,26 +37,26 @@ class Swift_Encoder_QpEncoder implements Swift_Encoder * @var string[] */ protected static $_qpMap = array( - 0 => '=00', 1 => '=01', 2 => '=02', 3 => '=03', 4 => '=04', - 5 => '=05', 6 => '=06', 7 => '=07', 8 => '=08', 9 => '=09', - 10 => '=0A', 11 => '=0B', 12 => '=0C', 13 => '=0D', 14 => '=0E', - 15 => '=0F', 16 => '=10', 17 => '=11', 18 => '=12', 19 => '=13', - 20 => '=14', 21 => '=15', 22 => '=16', 23 => '=17', 24 => '=18', - 25 => '=19', 26 => '=1A', 27 => '=1B', 28 => '=1C', 29 => '=1D', - 30 => '=1E', 31 => '=1F', 32 => '=20', 33 => '=21', 34 => '=22', - 35 => '=23', 36 => '=24', 37 => '=25', 38 => '=26', 39 => '=27', - 40 => '=28', 41 => '=29', 42 => '=2A', 43 => '=2B', 44 => '=2C', - 45 => '=2D', 46 => '=2E', 47 => '=2F', 48 => '=30', 49 => '=31', - 50 => '=32', 51 => '=33', 52 => '=34', 53 => '=35', 54 => '=36', - 55 => '=37', 56 => '=38', 57 => '=39', 58 => '=3A', 59 => '=3B', - 60 => '=3C', 61 => '=3D', 62 => '=3E', 63 => '=3F', 64 => '=40', - 65 => '=41', 66 => '=42', 67 => '=43', 68 => '=44', 69 => '=45', - 70 => '=46', 71 => '=47', 72 => '=48', 73 => '=49', 74 => '=4A', - 75 => '=4B', 76 => '=4C', 77 => '=4D', 78 => '=4E', 79 => '=4F', - 80 => '=50', 81 => '=51', 82 => '=52', 83 => '=53', 84 => '=54', - 85 => '=55', 86 => '=56', 87 => '=57', 88 => '=58', 89 => '=59', - 90 => '=5A', 91 => '=5B', 92 => '=5C', 93 => '=5D', 94 => '=5E', - 95 => '=5F', 96 => '=60', 97 => '=61', 98 => '=62', 99 => '=63', + 0 => '=00', 1 => '=01', 2 => '=02', 3 => '=03', 4 => '=04', + 5 => '=05', 6 => '=06', 7 => '=07', 8 => '=08', 9 => '=09', + 10 => '=0A', 11 => '=0B', 12 => '=0C', 13 => '=0D', 14 => '=0E', + 15 => '=0F', 16 => '=10', 17 => '=11', 18 => '=12', 19 => '=13', + 20 => '=14', 21 => '=15', 22 => '=16', 23 => '=17', 24 => '=18', + 25 => '=19', 26 => '=1A', 27 => '=1B', 28 => '=1C', 29 => '=1D', + 30 => '=1E', 31 => '=1F', 32 => '=20', 33 => '=21', 34 => '=22', + 35 => '=23', 36 => '=24', 37 => '=25', 38 => '=26', 39 => '=27', + 40 => '=28', 41 => '=29', 42 => '=2A', 43 => '=2B', 44 => '=2C', + 45 => '=2D', 46 => '=2E', 47 => '=2F', 48 => '=30', 49 => '=31', + 50 => '=32', 51 => '=33', 52 => '=34', 53 => '=35', 54 => '=36', + 55 => '=37', 56 => '=38', 57 => '=39', 58 => '=3A', 59 => '=3B', + 60 => '=3C', 61 => '=3D', 62 => '=3E', 63 => '=3F', 64 => '=40', + 65 => '=41', 66 => '=42', 67 => '=43', 68 => '=44', 69 => '=45', + 70 => '=46', 71 => '=47', 72 => '=48', 73 => '=49', 74 => '=4A', + 75 => '=4B', 76 => '=4C', 77 => '=4D', 78 => '=4E', 79 => '=4F', + 80 => '=50', 81 => '=51', 82 => '=52', 83 => '=53', 84 => '=54', + 85 => '=55', 86 => '=56', 87 => '=57', 88 => '=58', 89 => '=59', + 90 => '=5A', 91 => '=5B', 92 => '=5C', 93 => '=5D', 94 => '=5E', + 95 => '=5F', 96 => '=60', 97 => '=61', 98 => '=62', 99 => '=63', 100 => '=64', 101 => '=65', 102 => '=66', 103 => '=67', 104 => '=68', 105 => '=69', 106 => '=6A', 107 => '=6B', 108 => '=6C', 109 => '=6D', 110 => '=6E', 111 => '=6F', 112 => '=70', 113 => '=71', 114 => '=72', @@ -153,9 +153,9 @@ protected function initSafeMap() * If the first line needs to be shorter, indicate the difference with * $firstLineOffset. * - * @param string $string to encode - * @param int $firstLineOffset, optional - * @param int $maxLineLength, optional 0 indicates the default of 76 chars + * @param string $string to encode + * @param int $firstLineOffset, optional + * @param int $maxLineLength, optional 0 indicates the default of 76 chars * * @return string */ @@ -170,7 +170,7 @@ public function encodeString($string, $firstLineOffset = 0, $maxLineLength = 0) $lines = array(); $lNo = 0; $lines[$lNo] = ''; - $currentLine = & $lines[$lNo++]; + $currentLine = &$lines[$lNo++]; $size = $lineLen = 0; $this->_charStream->flushContents(); @@ -198,14 +198,25 @@ public function encodeString($string, $firstLineOffset = 0, $maxLineLength = 0) } $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++]; + $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)); @@ -249,7 +260,7 @@ protected function _encodeByteSequence(array $bytes, &$size) /** * Get the next sequence of bytes to read from the char stream. * - * @param int $size number of bytes to read + * @param int $size number of bytes to read * * @return integer[] */ @@ -267,7 +278,7 @@ protected function _nextSequence($size = 4) */ 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))) { @@ -280,8 +291,8 @@ protected function _standardize($string) } /** - * Make a deep copy of object - */ + * Make a deep copy of object. + */ public function __clone() { $this->_charStream = clone $this->_charStream; diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Encoder/Rfc2231Encoder.php b/swiftmailer/swiftmailer/lib/classes/Swift/Encoder/Rfc2231Encoder.php index 1a7e21eb1..b0215e883 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Encoder/Rfc2231Encoder.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Encoder/Rfc2231Encoder.php @@ -11,7 +11,7 @@ /** * Handles RFC 2231 specified Encoding in Swift Mailer. * - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_Encoder_Rfc2231Encoder implements Swift_Encoder { @@ -36,9 +36,9 @@ public function __construct(Swift_CharacterStream $charStream) * Takes an unencoded string and produces a string encoded according to * RFC 2231 from it. * - * @param string $string - * @param int $firstLineOffset - * @param int $maxLineLength optional, 0 indicates the default of 75 bytes + * @param string $string + * @param int $firstLineOffset + * @param int $maxLineLength optional, 0 indicates the default of 75 bytes * * @return string */ @@ -47,7 +47,7 @@ public function encodeString($string, $firstLineOffset = 0, $maxLineLength = 0) $lines = array(); $lineCount = 0; $lines[] = ''; - $currentLine = & $lines[$lineCount++]; + $currentLine = &$lines[$lineCount++]; if (0 >= $maxLineLength) { $maxLineLength = 75; @@ -63,7 +63,7 @@ public function encodeString($string, $firstLineOffset = 0, $maxLineLength = 0) if (0 != strlen($currentLine) && strlen($currentLine.$encodedChar) > $thisLineLength) { $lines[] = ''; - $currentLine = & $lines[$lineCount++]; + $currentLine = &$lines[$lineCount++]; $thisLineLength = $maxLineLength; } $currentLine .= $encodedChar; @@ -83,8 +83,8 @@ public function charsetChanged($charset) } /** - * Make a deep copy of object - */ + * Make a deep copy of object. + */ public function __clone() { $this->_charStream = clone $this->_charStream; diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Encoding.php b/swiftmailer/swiftmailer/lib/classes/Swift/Encoding.php index 5cbb20fcd..253977b60 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Encoding.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Encoding.php @@ -11,7 +11,7 @@ /** * Provides quick access to each encoding type. * - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_Encoding { diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Events/CommandEvent.php b/swiftmailer/swiftmailer/lib/classes/Swift/Events/CommandEvent.php index 670f4d3d8..7dc381d98 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Events/CommandEvent.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Events/CommandEvent.php @@ -11,7 +11,7 @@ /** * Generated when a command is sent over an SMTP connection. * - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_Events_CommandEvent extends Swift_Events_EventObject { diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Events/CommandListener.php b/swiftmailer/swiftmailer/lib/classes/Swift/Events/CommandListener.php index 3465c8d68..7545404e7 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Events/CommandListener.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Events/CommandListener.php @@ -11,7 +11,7 @@ /** * Listens for Transports to send commands to the server. * - * @author Chris Corbyn + * @author Chris Corbyn */ interface Swift_Events_CommandListener extends Swift_Events_EventListener { diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Events/Event.php b/swiftmailer/swiftmailer/lib/classes/Swift/Events/Event.php index ffd9bed1b..720b15637 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Events/Event.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Events/Event.php @@ -11,7 +11,7 @@ /** * The minimum interface for an Event. * - * @author Chris Corbyn + * @author Chris Corbyn */ interface Swift_Events_Event { @@ -25,7 +25,7 @@ public function getSource(); /** * Prevent this Event from bubbling any further up the stack. * - * @param bool $cancel, optional + * @param bool $cancel, optional */ public function cancelBubble($cancel = true); diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Events/EventDispatcher.php b/swiftmailer/swiftmailer/lib/classes/Swift/Events/EventDispatcher.php index c62c5e429..aac36aaa7 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Events/EventDispatcher.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Events/EventDispatcher.php @@ -11,7 +11,7 @@ /** * Interface for the EventDispatcher which handles the event dispatching layer. * - * @author Chris Corbyn + * @author Chris Corbyn */ interface Swift_Events_EventDispatcher { diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Events/EventListener.php b/swiftmailer/swiftmailer/lib/classes/Swift/Events/EventListener.php index 751ec678c..512909541 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Events/EventListener.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Events/EventListener.php @@ -11,7 +11,7 @@ /** * An identity interface which all EventListeners must extend. * - * @author Chris Corbyn + * @author Chris Corbyn */ interface Swift_Events_EventListener { diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Events/EventObject.php b/swiftmailer/swiftmailer/lib/classes/Swift/Events/EventObject.php index 50b6be6a8..90694a9a6 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Events/EventObject.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Events/EventObject.php @@ -11,7 +11,7 @@ /** * A base Event which all Event classes inherit from. * - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_Events_EventObject implements Swift_Events_Event { @@ -44,7 +44,7 @@ public function getSource() /** * Prevent this Event from bubbling any further up the stack. * - * @param bool $cancel, optional + * @param bool $cancel, optional */ public function cancelBubble($cancel = true) { diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Events/ResponseEvent.php b/swiftmailer/swiftmailer/lib/classes/Swift/Events/ResponseEvent.php index b0ac1a8f5..2e92ba940 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Events/ResponseEvent.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Events/ResponseEvent.php @@ -11,7 +11,7 @@ /** * Generated when a response is received on a SMTP connection. * - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_Events_ResponseEvent extends Swift_Events_EventObject { diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Events/ResponseListener.php b/swiftmailer/swiftmailer/lib/classes/Swift/Events/ResponseListener.php index 9629f1e5b..c40919d21 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Events/ResponseListener.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Events/ResponseListener.php @@ -11,7 +11,7 @@ /** * Listens for responses from a remote SMTP server. * - * @author Chris Corbyn + * @author Chris Corbyn */ interface Swift_Events_ResponseListener extends Swift_Events_EventListener { diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Events/SendEvent.php b/swiftmailer/swiftmailer/lib/classes/Swift/Events/SendEvent.php index 0d3b4141b..10da8080f 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Events/SendEvent.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Events/SendEvent.php @@ -11,13 +11,16 @@ /** * Generated when a message is being sent. * - * @author Chris Corbyn + * @author Chris Corbyn */ 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; @@ -104,7 +107,7 @@ public function getFailedRecipients() /** * Set the result of sending. * - * @param int $result + * @param int $result */ public function setResult($result) { diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Events/SendListener.php b/swiftmailer/swiftmailer/lib/classes/Swift/Events/SendListener.php index 7d35f18e0..d922e1bfa 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Events/SendListener.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Events/SendListener.php @@ -11,7 +11,7 @@ /** * Listens for Messages being sent from within the Transport system. * - * @author Chris Corbyn + * @author Chris Corbyn */ interface Swift_Events_SendListener extends Swift_Events_EventListener { diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Events/SimpleEventDispatcher.php b/swiftmailer/swiftmailer/lib/classes/Swift/Events/SimpleEventDispatcher.php index a38f7aae8..e8aca752f 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Events/SimpleEventDispatcher.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Events/SimpleEventDispatcher.php @@ -11,7 +11,7 @@ /** * The EventDispatcher which handles the event dispatching layer. * - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_Events_SimpleEventDispatcher implements Swift_Events_EventDispatcher { diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Events/TransportChangeEvent.php b/swiftmailer/swiftmailer/lib/classes/Swift/Events/TransportChangeEvent.php index 23c829702..a8972fda9 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Events/TransportChangeEvent.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Events/TransportChangeEvent.php @@ -11,7 +11,7 @@ /** * Generated when the state of a Transport is changed (i.e. stopped/started). * - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_Events_TransportChangeEvent extends Swift_Events_EventObject { diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Events/TransportChangeListener.php b/swiftmailer/swiftmailer/lib/classes/Swift/Events/TransportChangeListener.php index 0edfe377b..253165de8 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Events/TransportChangeListener.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Events/TransportChangeListener.php @@ -11,7 +11,7 @@ /** * Listens for changes within the Transport system. * - * @author Chris Corbyn + * @author Chris Corbyn */ interface Swift_Events_TransportChangeListener extends Swift_Events_EventListener { diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Events/TransportExceptionEvent.php b/swiftmailer/swiftmailer/lib/classes/Swift/Events/TransportExceptionEvent.php index b2c72ca18..f87154fb9 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Events/TransportExceptionEvent.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Events/TransportExceptionEvent.php @@ -11,7 +11,7 @@ /** * Generated when a TransportException is thrown from the Transport system. * - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_Events_TransportExceptionEvent extends Swift_Events_EventObject { diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Events/TransportExceptionListener.php b/swiftmailer/swiftmailer/lib/classes/Swift/Events/TransportExceptionListener.php index f153742cf..cc3c09937 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Events/TransportExceptionListener.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Events/TransportExceptionListener.php @@ -11,7 +11,7 @@ /** * Listens for Exceptions thrown from within the Transport system. * - * @author Chris Corbyn + * @author Chris Corbyn */ interface Swift_Events_TransportExceptionListener extends Swift_Events_EventListener { diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/FailoverTransport.php b/swiftmailer/swiftmailer/lib/classes/Swift/FailoverTransport.php index 6fa5fc70f..53f277da0 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/FailoverTransport.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/FailoverTransport.php @@ -11,7 +11,7 @@ /** * Contains a list of redundant Transports so when one fails, the next is used. * - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_FailoverTransport extends Swift_Transport_FailoverTransport { diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/FileSpool.php b/swiftmailer/swiftmailer/lib/classes/Swift/FileSpool.php index b30f9f85a..c82c5dbf1 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/FileSpool.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/FileSpool.php @@ -11,8 +11,8 @@ /** * Stores Messages on the filesystem. * - * @author Fabien Potencier - * @author Xavier De Cock + * @author Fabien Potencier + * @author Xavier De Cock */ class Swift_FileSpool extends Swift_ConfigurableSpool { @@ -20,7 +20,7 @@ class Swift_FileSpool extends Swift_ConfigurableSpool private $_path; /** - * File WriteRetry Limit + * File WriteRetry Limit. * * @var int */ @@ -39,7 +39,7 @@ public function __construct($path) 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)); } } } @@ -73,7 +73,7 @@ public function stop() * * Default, is ten and allows over 64^20 different fileNames * - * @param int $limit + * @param int $limit */ public function setRetryLimit($limit) { @@ -85,9 +85,9 @@ public function setRetryLimit($limit) * * @param Swift_Mime_Message $message The message to store * - * @return bool - * * @throws Swift_IoException + * + * @return bool */ public function queueMessage(Swift_Mime_Message $message) { @@ -108,23 +108,23 @@ public function queueMessage(Swift_Mime_Message $message) } } - 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)); } /** * Execute a recovery if for any reason a process is sending for too long. * - * @param int $timeout in second Defaults is for very slow smtp responses + * @param int $timeout in second Defaults is for very slow smtp responses */ public function recover($timeout = 900) { foreach (new DirectoryIterator($this->_path) as $file) { $file = $file->getRealPath(); - if (substr($file, - 16) == '.message.sending') { + if (substr($file, -16) == '.message.sending') { $lockedtime = filectime($file); if ((time() - $lockedtime) > $timeout) { - rename($file, substr($file, 0, - 8)); + rename($file, substr($file, 0, -8)); } } } @@ -136,7 +136,7 @@ public function recover($timeout = 900) * @param Swift_Transport $transport A transport instance * @param string[] $failedRecipients An array of failures by-reference * - * @return int The number of sent e-mail's + * @return int The number of sent e-mail's */ public function flushQueue(Swift_Transport $transport, &$failedRecipients = null) { @@ -189,14 +189,14 @@ public function flushQueue(Swift_Transport $transport, &$failedRecipients = null /** * Returns a random string needed to generate a fileName for the queue. * - * @param int $count + * @param int $count * * @return string */ 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) { diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/FileStream.php b/swiftmailer/swiftmailer/lib/classes/Swift/FileStream.php index 802cb4305..0b24db1ce 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/FileStream.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/FileStream.php @@ -11,7 +11,7 @@ /** * An OutputByteStream which specifically reads from a file. * - * @author Chris Corbyn + * @author Chris Corbyn */ interface Swift_FileStream extends Swift_OutputByteStream { diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Filterable.php b/swiftmailer/swiftmailer/lib/classes/Swift/Filterable.php index 1f664de8f..6b75b5274 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Filterable.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Filterable.php @@ -11,7 +11,7 @@ /** * Allows StreamFilters to operate on a stream. * - * @author Chris Corbyn + * @author Chris Corbyn */ interface Swift_Filterable { diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Image.php b/swiftmailer/swiftmailer/lib/classes/Swift/Image.php index 966bee72f..25f5f1b61 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Image.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Image.php @@ -11,7 +11,7 @@ /** * An image, embedded in a multipart message. * - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_Image extends Swift_EmbeddedFile { diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/InputByteStream.php b/swiftmailer/swiftmailer/lib/classes/Swift/InputByteStream.php index fd45ab93b..56efc7593 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/InputByteStream.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/InputByteStream.php @@ -14,7 +14,7 @@ * Classes implementing this interface may use a subsystem which requires less * memory than working with large strings of data. * - * @author Chris Corbyn + * @author Chris Corbyn */ interface Swift_InputByteStream { @@ -30,9 +30,9 @@ interface Swift_InputByteStream * * @param string $bytes * - * @return int - * * @throws Swift_IoException + * + * @return int */ public function write($bytes); diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/IoException.php b/swiftmailer/swiftmailer/lib/classes/Swift/IoException.php index 75698f9a2..c405f352b 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/IoException.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/IoException.php @@ -11,17 +11,19 @@ /** * I/O Exception class. * - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_IoException extends Swift_SwiftException { /** * Create a new IoException with $message. * - * @param string $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); } } diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/KeyCache.php b/swiftmailer/swiftmailer/lib/classes/Swift/KeyCache.php index a16a90bd6..cd6f786df 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/KeyCache.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/KeyCache.php @@ -11,7 +11,7 @@ /** * Provides a mechanism for storing data using two keys. * - * @author Chris Corbyn + * @author Chris Corbyn */ interface Swift_KeyCache { @@ -26,10 +26,10 @@ interface Swift_KeyCache * * @see MODE_WRITE, MODE_APPEND * - * @param string $nsKey - * @param string $itemKey - * @param string $string - * @param int $mode + * @param string $nsKey + * @param string $itemKey + * @param string $string + * @param int $mode */ public function setString($nsKey, $itemKey, $string, $mode); diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/KeyCache/ArrayKeyCache.php b/swiftmailer/swiftmailer/lib/classes/Swift/KeyCache/ArrayKeyCache.php index 71a32819b..b37f07f74 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/KeyCache/ArrayKeyCache.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/KeyCache/ArrayKeyCache.php @@ -11,7 +11,7 @@ /** * A basic KeyCache backed by an array. * - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_KeyCache_ArrayKeyCache implements Swift_KeyCache { @@ -45,10 +45,10 @@ public function __construct(Swift_KeyCache_KeyCacheInputStream $stream) * * @see MODE_WRITE, MODE_APPEND * - * @param string $nsKey - * @param string $itemKey - * @param string $string - * @param int $mode + * @param string $nsKey + * @param string $itemKey + * @param string $string + * @param int $mode */ public function setString($nsKey, $itemKey, $string, $mode) { diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/KeyCache/DiskKeyCache.php b/swiftmailer/swiftmailer/lib/classes/Swift/KeyCache/DiskKeyCache.php index 5a7096255..453f50a15 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/KeyCache/DiskKeyCache.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/KeyCache/DiskKeyCache.php @@ -11,7 +11,7 @@ /** * A KeyCache which streams to and from disk. * - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_KeyCache_DiskKeyCache implements Swift_KeyCache { @@ -74,10 +74,10 @@ public function __construct(Swift_KeyCache_KeyCacheInputStream $stream, $path) * * @see MODE_WRITE, MODE_APPEND * - * @param string $nsKey - * @param string $itemKey - * @param string $string - * @param int $mode + * @param string $nsKey + * @param string $itemKey + * @param string $string + * @param int $mode * * @throws Swift_IoException */ @@ -167,9 +167,9 @@ public function getInputByteStream($nsKey, $itemKey, Swift_InputByteStream $writ * @param string $nsKey * @param string $itemKey * - * @return string - * * @throws Swift_IoException + * + * @return string */ public function getString($nsKey, $itemKey) { @@ -280,19 +280,16 @@ private function _prepareCache($nsKey) /** * Get a file handle on the cache item. * - * @param string $nsKey - * @param string $itemKey - * @param int $position + * @param string $nsKey + * @param string $itemKey + * @param int $position * * @return resource */ 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; } diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/KeyCache/KeyCacheInputStream.php b/swiftmailer/swiftmailer/lib/classes/Swift/KeyCache/KeyCacheInputStream.php index 76039d8a1..af80bdca6 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/KeyCache/KeyCacheInputStream.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/KeyCache/KeyCacheInputStream.php @@ -11,7 +11,7 @@ /** * Writes data to a KeyCache using a stream. * - * @author Chris Corbyn + * @author Chris Corbyn */ interface Swift_KeyCache_KeyCacheInputStream extends Swift_InputByteStream { diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/KeyCache/NullKeyCache.php b/swiftmailer/swiftmailer/lib/classes/Swift/KeyCache/NullKeyCache.php index 79ab89fc6..4efe78564 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/KeyCache/NullKeyCache.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/KeyCache/NullKeyCache.php @@ -11,7 +11,7 @@ /** * A null KeyCache that does not cache at all. * - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_KeyCache_NullKeyCache implements Swift_KeyCache { @@ -20,10 +20,10 @@ class Swift_KeyCache_NullKeyCache implements Swift_KeyCache * * @see MODE_WRITE, MODE_APPEND * - * @param string $nsKey - * @param string $itemKey - * @param string $string - * @param int $mode + * @param string $nsKey + * @param string $itemKey + * @param string $string + * @param int $mode */ public function setString($nsKey, $itemKey, $string, $mode) { diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/KeyCache/SimpleKeyCacheInputStream.php b/swiftmailer/swiftmailer/lib/classes/Swift/KeyCache/SimpleKeyCacheInputStream.php index e829c8fdb..b00d458a6 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/KeyCache/SimpleKeyCacheInputStream.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/KeyCache/SimpleKeyCacheInputStream.php @@ -11,7 +11,7 @@ /** * Writes data to a KeyCache using a stream. * - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_KeyCache_SimpleKeyCacheInputStream implements Swift_KeyCache_KeyCacheInputStream { diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/LoadBalancedTransport.php b/swiftmailer/swiftmailer/lib/classes/Swift/LoadBalancedTransport.php index 6e1080b9f..fdba9df50 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/LoadBalancedTransport.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/LoadBalancedTransport.php @@ -11,7 +11,7 @@ /** * Redundantly and rotationally uses several Transport implementations when sending. * - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_LoadBalancedTransport extends Swift_Transport_LoadBalancedTransport { diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/MailTransport.php b/swiftmailer/swiftmailer/lib/classes/Swift/MailTransport.php index a6d3340d8..994df3ec2 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/MailTransport.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/MailTransport.php @@ -11,7 +11,9 @@ /** * Sends Messages using the mail() function. * - * @author Chris Corbyn + * @author Chris Corbyn + * + * @deprecated since 5.4.5 (to be removed in 6.0) */ class Swift_MailTransport extends Swift_Transport_MailTransport { diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Mailer.php b/swiftmailer/swiftmailer/lib/classes/Swift/Mailer.php index 5677fcb4f..641154627 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Mailer.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Mailer.php @@ -11,7 +11,7 @@ /** * Swift Mailer class. * - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_Mailer { @@ -69,7 +69,7 @@ public function createMessage($service = 'message') * @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) { diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Mailer/ArrayRecipientIterator.php b/swiftmailer/swiftmailer/lib/classes/Swift/Mailer/ArrayRecipientIterator.php index d02e1846b..e3e6cad05 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Mailer/ArrayRecipientIterator.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Mailer/ArrayRecipientIterator.php @@ -11,7 +11,7 @@ /** * Wraps a standard PHP array in an iterator. * - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_Mailer_ArrayRecipientIterator implements Swift_Mailer_RecipientIterator { @@ -44,7 +44,7 @@ public function hasNext() /** * 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 */ diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Mailer/RecipientIterator.php b/swiftmailer/swiftmailer/lib/classes/Swift/Mailer/RecipientIterator.php index a935c563f..650f3ec3d 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Mailer/RecipientIterator.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Mailer/RecipientIterator.php @@ -11,7 +11,7 @@ /** * Provides an abstract way of specifying recipients for batch sending. * - * @author Chris Corbyn + * @author Chris Corbyn */ interface Swift_Mailer_RecipientIterator { @@ -24,7 +24,7 @@ public function hasNext(); /** * 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 */ diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/MemorySpool.php b/swiftmailer/swiftmailer/lib/classes/Swift/MemorySpool.php index 590fc4881..2cafb6751 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/MemorySpool.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/MemorySpool.php @@ -11,11 +11,12 @@ /** * Stores Messages in memory. * - * @author Fabien Potencier + * @author Fabien Potencier */ class Swift_MemorySpool implements Swift_Spool { protected $messages = array(); + private $flushRetries = 3; /** * Tests if this Transport mechanism has started. @@ -41,12 +42,20 @@ public function stop() { } + /** + * @param int $retries + */ + public function setFlushRetries($retries) + { + $this->flushRetries = $retries; + } + /** * Stores a message in the queue. * * @param Swift_Mime_Message $message The message to store * - * @return bool Whether the operation has succeeded + * @return bool Whether the operation has succeeded */ public function queueMessage(Swift_Mime_Message $message) { @@ -62,7 +71,7 @@ public function queueMessage(Swift_Mime_Message $message) * @param Swift_Transport $transport A transport instance * @param string[] $failedRecipients An array of failures by-reference * - * @return int The number of sent emails + * @return int The number of sent emails */ public function flushQueue(Swift_Transport $transport, &$failedRecipients = null) { @@ -75,8 +84,25 @@ public function flushQueue(Swift_Transport $transport, &$failedRecipients = null } $count = 0; - while ($message = array_pop($this->messages)) { - $count += $transport->send($message, $failedRecipients); + $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; diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Message.php b/swiftmailer/swiftmailer/lib/classes/Swift/Message.php index 6887a0751..a6bb65930 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Message.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Message.php @@ -11,7 +11,7 @@ /** * The Message class for building emails. * - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_Message extends Swift_Mime_SimpleMessage { @@ -68,7 +68,7 @@ public function __construct($subject = null, $body = null, $contentType = null, * @param string $contentType * @param string $charset * - * @return Swift_Message + * @return $this */ public static function newInstance($subject = null, $body = null, $contentType = null, $charset = null) { @@ -82,7 +82,7 @@ public static function newInstance($subject = null, $body = null, $contentType = * @param string $contentType * @param string $charset * - * @return Swift_Mime_SimpleMessage + * @return $this */ public function addPart($body, $contentType = null, $charset = null) { @@ -92,10 +92,11 @@ public function addPart($body, $contentType = null, $charset = null) } /** - * 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) { @@ -112,7 +113,8 @@ public function attachSigner(Swift_Signer $signer) * Attach a new signature handler to the message. * * @param Swift_Signer $signer - * @return Swift_Message + * + * @return $this */ public function detachSigner(Swift_Signer $signer) { @@ -187,7 +189,7 @@ public function __wakeup() } /** - * loops through signers and apply the signatures + * loops through signers and apply the signatures. */ protected function doSign() { @@ -213,7 +215,7 @@ protected function doSign() } /** - * save the message before any signature is applied + * save the message before any signature is applied. */ protected function saveMessage() { @@ -227,7 +229,8 @@ protected function saveMessage() } /** - * save the original headers + * save the original headers. + * * @param array $altered */ protected function saveHeaders(array $altered) @@ -242,7 +245,7 @@ protected function saveHeaders(array $altered) } /** - * Remove or restore altered headers + * Remove or restore altered headers. */ protected function restoreHeaders() { @@ -258,7 +261,7 @@ protected function restoreHeaders() } /** - * Restore message body + * Restore message body. */ protected function restoreMessage() { @@ -270,18 +273,19 @@ protected function restoreMessage() } /** - * Clone Message Signers + * Clone Message Signers. + * * @see Swift_Mime_SimpleMimeEntity::__clone() */ public function __clone() { parent::__clone(); foreach ($this->bodySigners as $key => $bodySigner) { - $this->bodySigners[$key] = clone($bodySigner); + $this->bodySigners[$key] = clone $bodySigner; } foreach ($this->headerSigners as $key => $headerSigner) { - $this->headerSigners[$key] = clone($headerSigner); + $this->headerSigners[$key] = clone $headerSigner; } } } diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Attachment.php b/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Attachment.php index d9d965297..46a5e8da9 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Attachment.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Attachment.php @@ -11,7 +11,7 @@ /** * An attachment, in a multipart message. * - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_Mime_Attachment extends Swift_Mime_SimpleMimeEntity { @@ -69,9 +69,7 @@ public function getDisposition() public function setDisposition($disposition) { if (!$this->_setHeaderFieldModel('Content-Disposition', $disposition)) { - $this->getHeaders()->addParameterizedHeader( - 'Content-Disposition', $disposition - ); + $this->getHeaders()->addParameterizedHeader('Content-Disposition', $disposition); } return $this; @@ -115,7 +113,7 @@ public function getSize() /** * Set the file size of this attachment. * - * @param int $size + * @param int $size * * @return Swift_Mime_Attachment */ @@ -139,9 +137,7 @@ 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]); diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Mime/CharsetObserver.php b/swiftmailer/swiftmailer/lib/classes/Swift/Mime/CharsetObserver.php index 57d8bc465..b49c3a873 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Mime/CharsetObserver.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Mime/CharsetObserver.php @@ -11,7 +11,7 @@ /** * Observes changes in an Mime entity's character set. * - * @author Chris Corbyn + * @author Chris Corbyn */ interface Swift_Mime_CharsetObserver { diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Mime/ContentEncoder.php b/swiftmailer/swiftmailer/lib/classes/Swift/Mime/ContentEncoder.php index 3338b629f..d43ea9f40 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Mime/ContentEncoder.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Mime/ContentEncoder.php @@ -11,7 +11,7 @@ /** * Interface for all Transfer Encoding schemes. * - * @author Chris Corbyn + * @author Chris Corbyn */ interface Swift_Mime_ContentEncoder extends Swift_Encoder { diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/Base64ContentEncoder.php b/swiftmailer/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/Base64ContentEncoder.php index fffbf0487..8f76d70f3 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/Base64ContentEncoder.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/Base64ContentEncoder.php @@ -11,7 +11,7 @@ /** * Handles Base 64 Transfer Encoding in Swift Mailer. * - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_Mime_ContentEncoder_Base64ContentEncoder extends Swift_Encoder_Base64Encoder implements Swift_Mime_ContentEncoder { @@ -30,9 +30,42 @@ public function encodeByteStream(Swift_OutputByteStream $os, Swift_InputByteStre } $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; @@ -51,6 +84,10 @@ public function encodeByteStream(Swift_OutputByteStream $os, Swift_InputByteStre } $is->write($encodedTransformed); + + if ($atEOF) { + break; + } } } diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/NativeQpContentEncoder.php b/swiftmailer/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/NativeQpContentEncoder.php index e97195a58..710b5ac9e 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/NativeQpContentEncoder.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/NativeQpContentEncoder.php @@ -11,7 +11,7 @@ /** * Handles Quoted Printable (QP) Transfer Encoding in Swift Mailer using the PHP core function. * - * @author Lars Strojny + * @author Lars Strojny */ class Swift_Mime_ContentEncoder_NativeQpContentEncoder implements Swift_Mime_ContentEncoder { @@ -77,13 +77,13 @@ public function getName() /** * Encode a given string to produce an encoded string. * - * @param string $string - * @param int $firstLineOffset if first line needs to be shorter - * @param int $maxLineLength 0 indicates the default length for this encoding - * - * @return string + * @param string $string + * @param int $firstLineOffset if first line needs to be shorter + * @param int $maxLineLength 0 indicates the default length for this encoding * * @throws RuntimeException + * + * @return string */ public function encodeString($string, $firstLineOffset = 0, $maxLineLength = 0) { @@ -107,7 +107,7 @@ protected function _standardize($string) // transform CR or LF to CRLF $string = preg_replace('~=0D(?!=0A)|(? $length) { $lines[] = ''; - $currentLine = & $lines[$lineCount++]; + $currentLine = &$lines[$lineCount++]; } $currentLine .= $chunk; } diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/QpContentEncoder.php b/swiftmailer/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/QpContentEncoder.php index 58f05a10d..5cc907b8e 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/QpContentEncoder.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/QpContentEncoder.php @@ -11,7 +11,7 @@ /** * Handles Quoted Printable (QP) Transfer Encoding in Swift Mailer. * - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_Mime_ContentEncoder_QpContentEncoder extends Swift_Encoder_QpEncoder implements Swift_Mime_ContentEncoder { @@ -95,15 +95,26 @@ public function encodeByteStream(Swift_OutputByteStream $os, Swift_InputByteStre } $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)); diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/QpContentEncoderProxy.php b/swiftmailer/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/QpContentEncoderProxy.php index d6e8d7c32..3214e1cf3 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/QpContentEncoderProxy.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/QpContentEncoderProxy.php @@ -13,7 +13,7 @@ * * Switches on the best QP encoder implementation for current charset. * - * @author Jean-François Simon + * @author Jean-François Simon */ class Swift_Mime_ContentEncoder_QpContentEncoderProxy implements Swift_Mime_ContentEncoder { @@ -47,7 +47,7 @@ public function __construct(Swift_Mime_ContentEncoder_QpContentEncoder $safeEnco } /** - * Make a deep copy of object + * Make a deep copy of object. */ public function __clone() { @@ -61,6 +61,7 @@ public function __clone() public function charsetChanged($charset) { $this->charset = $charset; + $this->safeEncoder->charsetChanged($charset); } /** diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/RawContentEncoder.php b/swiftmailer/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/RawContentEncoder.php index f717dc789..0b8526e38 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/RawContentEncoder.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/RawContentEncoder.php @@ -12,16 +12,17 @@ * Handles raw Transfer Encoding in Swift Mailer. * * - * @author Sebastiaan Stok + * @author Sebastiaan Stok */ class Swift_Mime_ContentEncoder_RawContentEncoder implements Swift_Mime_ContentEncoder { /** * Encode a given string to produce an encoded string. * - * @param string $string - * @param int $firstLineOffset ignored - * @param int $maxLineLength ignored + * @param string $string + * @param int $firstLineOffset ignored + * @param int $maxLineLength ignored + * * @return string */ public function encodeString($string, $firstLineOffset = 0, $maxLineLength = 0) diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Mime/EmbeddedFile.php b/swiftmailer/swiftmailer/lib/classes/Swift/Mime/EmbeddedFile.php index ec1ef535f..6af757124 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Mime/EmbeddedFile.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Mime/EmbeddedFile.php @@ -11,7 +11,7 @@ /** * An embedded file, in a multipart message. * - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_Mime_EmbeddedFile extends Swift_Mime_Attachment { diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Mime/EncodingObserver.php b/swiftmailer/swiftmailer/lib/classes/Swift/Mime/EncodingObserver.php index e262974bb..cc44a6efb 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Mime/EncodingObserver.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Mime/EncodingObserver.php @@ -11,7 +11,7 @@ /** * Observes changes for a Mime entity's ContentEncoder. * - * @author Chris Corbyn + * @author Chris Corbyn */ interface Swift_Mime_EncodingObserver { diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Grammar.php b/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Grammar.php index 6bd280160..a09f33831 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Grammar.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Grammar.php @@ -129,11 +129,11 @@ public function getDefinition($name) { if (array_key_exists($name, self::$_grammar)) { return self::$_grammar[$name]; - } else { - throw new Swift_RfcComplianceException( - "No such grammar '".$name."' defined." - ); } + + throw new Swift_RfcComplianceException( + "No such grammar '".$name."' defined." + ); } /** diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Header.php b/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Header.php index 7074c4f6a..a8ddd2721 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Header.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Header.php @@ -11,7 +11,7 @@ /** * A MIME Header. * - * @author Chris Corbyn + * @author Chris Corbyn */ interface Swift_Mime_Header { diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Mime/HeaderEncoder.php b/swiftmailer/swiftmailer/lib/classes/Swift/Mime/HeaderEncoder.php index 6e014a1d3..08fd453d6 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Mime/HeaderEncoder.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Mime/HeaderEncoder.php @@ -11,7 +11,7 @@ /** * Interface for all Header Encoding schemes. * - * @author Chris Corbyn + * @author Chris Corbyn */ interface Swift_Mime_HeaderEncoder extends Swift_Encoder { diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Mime/HeaderEncoder/Base64HeaderEncoder.php b/swiftmailer/swiftmailer/lib/classes/Swift/Mime/HeaderEncoder/Base64HeaderEncoder.php index 6dbc6edcd..83a4f2f3b 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Mime/HeaderEncoder/Base64HeaderEncoder.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Mime/HeaderEncoder/Base64HeaderEncoder.php @@ -11,7 +11,7 @@ /** * Handles Base64 (B) Header Encoding in Swift Mailer. * - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_Mime_HeaderEncoder_Base64HeaderEncoder extends Swift_Encoder_Base64Encoder implements Swift_Mime_HeaderEncoder { @@ -32,10 +32,10 @@ public function getName() * If the charset is iso-2022-jp, it uses mb_encode_mimeheader instead of * default encodeString, otherwise pass to the parent method. * - * @param string $string string to encode - * @param int $firstLineOffset - * @param int $maxLineLength optional, 0 indicates the default of 76 bytes - * @param string $charset + * @param string $string string to encode + * @param int $firstLineOffset + * @param int $maxLineLength optional, 0 indicates the default of 76 bytes + * @param string $charset * * @return string */ diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Mime/HeaderEncoder/QpHeaderEncoder.php b/swiftmailer/swiftmailer/lib/classes/Swift/Mime/HeaderEncoder/QpHeaderEncoder.php index dd8ff382c..510dd6637 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Mime/HeaderEncoder/QpHeaderEncoder.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Mime/HeaderEncoder/QpHeaderEncoder.php @@ -11,7 +11,7 @@ /** * Handles Quoted Printable (Q) Header Encoding in Swift Mailer. * - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_Mime_HeaderEncoder_QpHeaderEncoder extends Swift_Encoder_QpEncoder implements Swift_Mime_HeaderEncoder { @@ -50,9 +50,9 @@ public function getName() /** * Takes an unencoded string and produces a QP encoded string from it. * - * @param string $string string to encode - * @param int $firstLineOffset optional - * @param int $maxLineLength optional, 0 indicates the default of 76 chars + * @param string $string string to encode + * @param int $firstLineOffset optional + * @param int $maxLineLength optional, 0 indicates the default of 76 chars * * @return string */ diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Mime/HeaderFactory.php b/swiftmailer/swiftmailer/lib/classes/Swift/Mime/HeaderFactory.php index 423cebcf4..c65f26d72 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Mime/HeaderFactory.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Mime/HeaderFactory.php @@ -11,7 +11,7 @@ /** * Creates MIME headers. * - * @author Chris Corbyn + * @author Chris Corbyn */ interface Swift_Mime_HeaderFactory extends Swift_Mime_CharsetObserver { @@ -28,8 +28,8 @@ public function createMailboxHeader($name, $addresses = null); /** * Create a new Date header using $timestamp (UNIX time). * - * @param string $name - * @param int $timestamp + * @param string $name + * @param int $timestamp * * @return Swift_Mime_Header */ diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Mime/HeaderSet.php b/swiftmailer/swiftmailer/lib/classes/Swift/Mime/HeaderSet.php index b91406629..7390d2c8a 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Mime/HeaderSet.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Mime/HeaderSet.php @@ -11,7 +11,7 @@ /** * A collection of MIME headers. * - * @author Chris Corbyn + * @author Chris Corbyn */ interface Swift_Mime_HeaderSet extends Swift_Mime_CharsetObserver { @@ -26,8 +26,8 @@ public function addMailboxHeader($name, $addresses = null); /** * Add a new Date header using $timestamp (UNIX time). * - * @param string $name - * @param int $timestamp + * @param string $name + * @param int $timestamp */ public function addDateHeader($name, $timestamp = null); @@ -69,8 +69,8 @@ public function addPathHeader($name, $path = null); * * If multiple headers match, the actual one may be specified by $index. * - * @param string $name - * @param int $index + * @param string $name + * @param int $index * * @return bool */ @@ -95,8 +95,8 @@ public function set(Swift_Mime_Header $header, $index = 0); * If multiple headers match, the actual one may be specified by $index. * Returns NULL if none present. * - * @param string $name - * @param int $index + * @param string $name + * @param int $index * * @return Swift_Mime_Header */ @@ -112,19 +112,19 @@ public function get($name, $index = 0); public function getAll($name = null); /** - * Return the name of all Headers + * Return the name of all Headers. * * @return array */ public function listAll(); - /** + /** * Remove the header with the given $name if it's set. * * If multiple headers match, the actual one may be specified by $index. * - * @param string $name - * @param int $index + * @param string $name + * @param int $index */ public function remove($name, $index = 0); diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Headers/AbstractHeader.php b/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Headers/AbstractHeader.php index 0ccf27bb9..fbd9258a3 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Headers/AbstractHeader.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Headers/AbstractHeader.php @@ -11,7 +11,7 @@ /** * An abstract base MIME Header. * - * @author Chris Corbyn + * @author Chris Corbyn */ abstract class Swift_Mime_Headers_AbstractHeader implements Swift_Mime_Header { @@ -177,7 +177,7 @@ public function getFieldName() /** * Set the maximum length of lines in the header (excluding EOL). * - * @param int $lineLength + * @param int $lineLength */ public function setMaxLineLength($lineLength) { @@ -198,9 +198,9 @@ public function getMaxLineLength() /** * Get this Header rendered as a RFC 2822 compliant string. * - * @return string - * * @throws Swift_RfcComplianceException + * + * @return string */ public function toString() { @@ -357,8 +357,8 @@ protected function getEncodableWordTokens($string) /** * Get a token as an encoded word for safe insertion into headers. * - * @param string $token token to encode - * @param int $firstLineOffset optional + * @param string $token token to encode + * @param int $firstLineOffset optional * * @return string */ @@ -431,7 +431,7 @@ protected function getCachedValue() /** * Clear the cached value if $condition is met. * - * @param bool $condition + * @param bool $condition */ protected function clearCachedValueIf($condition) { @@ -479,7 +479,7 @@ private function _tokensToString(array $tokens) $lineCount = 0; $headerLines = array(); $headerLines[] = $this->_name.': '; - $currentLine = & $headerLines[$lineCount++]; + $currentLine = &$headerLines[$lineCount++]; // Build all tokens back into compliant header foreach ($tokens as $i => $token) { @@ -488,7 +488,7 @@ private function _tokensToString(array $tokens) ($i > 0 && strlen($currentLine.$token) > $this->_lineLength) && 0 < strlen($currentLine)) { $headerLines[] = ''; - $currentLine = & $headerLines[$lineCount++]; + $currentLine = &$headerLines[$lineCount++]; } // Append token to the line diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Headers/DateHeader.php b/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Headers/DateHeader.php index a1093fb08..4fd667429 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Headers/DateHeader.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Headers/DateHeader.php @@ -11,7 +11,7 @@ /** * A Date MIME Header for Swift Mailer. * - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_Mime_Headers_DateHeader extends Swift_Mime_Headers_AbstractHeader { @@ -59,7 +59,7 @@ public function getFieldType() * * This method takes a UNIX timestamp. * - * @param int $model + * @param int $model */ public function setFieldBodyModel($model) { @@ -91,7 +91,7 @@ public function getTimestamp() /** * Set the UNIX timestamp of the Date in this Header. * - * @param int $timestamp + * @param int $timestamp */ public function setTimestamp($timestamp) { diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Headers/IdentificationHeader.php b/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Headers/IdentificationHeader.php index 1a5a3dd92..b114506b4 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Headers/IdentificationHeader.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Headers/IdentificationHeader.php @@ -11,7 +11,7 @@ /** * An ID MIME Header for something like Message-ID or Content-ID. * - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_Mime_Headers_IdentificationHeader extends Swift_Mime_Headers_AbstractHeader { @@ -139,9 +139,9 @@ public function getIds() * * @see toString() * - * @return string - * * @throws Swift_RfcComplianceException + * + * @return string */ public function getFieldBody() { diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Headers/MailboxHeader.php b/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Headers/MailboxHeader.php index 165b86195..e54b1c662 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Headers/MailboxHeader.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Headers/MailboxHeader.php @@ -11,7 +11,7 @@ /** * A Mailbox Address MIME Header for something like From or Sender. * - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_Mime_Headers_MailboxHeader extends Swift_Mime_Headers_AbstractHeader { @@ -68,9 +68,9 @@ public function setFieldBodyModel($model) * * This method returns an associative array like {@link getNameAddresses()} * - * @return array - * * @throws Swift_RfcComplianceException + * + * @return array */ public function getFieldBodyModel() { @@ -128,9 +128,9 @@ public function setNameAddresses($mailboxes) * @see getNameAddresses() * @see toString() * - * @return string[] - * * @throws Swift_RfcComplianceException + * + * @return string[] */ public function getNameAddressStrings() { @@ -224,9 +224,9 @@ public function removeAddresses($addresses) * * @see toString() * - * @return string - * * @throws Swift_RfcComplianceException + * + * @return string */ public function getFieldBody() { @@ -270,16 +270,14 @@ protected function normalizeMailboxes(array $mailboxes) /** * Produces a compliant, formatted display-name based on the string given. * - * @param string $displayName as displayed - * @param bool $shorten the first line to make remove for header name + * @param string $displayName as displayed + * @param bool $shorten the first line to make remove for header name * * @return string */ 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); } /** @@ -287,9 +285,9 @@ protected function createDisplayNameString($displayName, $shorten = false) * * @param string[] $mailboxes * - * @return string - * * @throws Swift_RfcComplianceException + * + * @return string */ protected function createMailboxListString(array $mailboxes) { @@ -299,8 +297,9 @@ protected function createMailboxListString(array $mailboxes) /** * 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 * @@ -308,7 +307,7 @@ protected function createMailboxListString(array $mailboxes) */ protected function tokenNeedsEncoding($token) { - return preg_match('/[,;]/', $token) || parent::tokenNeedsEncoding($token); + return preg_match('/[()<>\[\]:;@\,."]/', $token) || parent::tokenNeedsEncoding($token); } /** diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Headers/OpenDKIMHeader.php b/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Headers/OpenDKIMHeader.php index b55d46096..d74955007 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Headers/OpenDKIMHeader.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Headers/OpenDKIMHeader.php @@ -9,9 +9,9 @@ */ /** - * An OpenDKIM Specific Header using only raw header datas without encoding + * An OpenDKIM Specific Header using only raw header datas without encoding. * - * @author De Cock Xavier + * @author De Cock Xavier */ class Swift_Mime_Headers_OpenDKIMHeader implements Swift_Mime_Header { @@ -23,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 + * @param string $name */ public function __construct($name) { @@ -118,16 +115,17 @@ public function toString() } /** - * Set the Header FieldName - * @see Swift_Mime_Header::getFieldName() - */ + * Set the Header FieldName. + * + * @see Swift_Mime_Header::getFieldName() + */ public function getFieldName() { return $this->_fieldName; } /** - * Ignored + * Ignored. */ public function setCharset($charset) { diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Headers/ParameterizedHeader.php b/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Headers/ParameterizedHeader.php index 994fc940b..c506daec1 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Headers/ParameterizedHeader.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Headers/ParameterizedHeader.php @@ -11,7 +11,7 @@ /** * An abstract base MIME Header. * - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_Mime_Headers_ParameterizedHeader extends Swift_Mime_Headers_UnstructuredHeader implements Swift_Mime_ParameterizedHeader { @@ -98,9 +98,7 @@ public function getParameter($parameter) { $params = $this->getParameters(); - return array_key_exists($parameter, $params) - ? $params[$parameter] - : null; + return array_key_exists($parameter, $params) ? $params[$parameter] : null; } /** @@ -160,7 +158,7 @@ protected function toTokens($string = null) foreach ($this->_params as $name => $value) { if (!is_null($value)) { // Add the semi-colon separator - $tokens[count($tokens)-1] .= ';'; + $tokens[count($tokens) - 1] .= ';'; $tokens = array_merge($tokens, $this->generateTokenLines( ' '.$this->_createParameter($name, $value) )); @@ -235,9 +233,9 @@ private function _createParameter($name, $value) /** * Returns the parameter value from the "=" and beyond. * - * @param string $value to append - * @param bool $encoded - * @param bool $firstLine + * @param string $value to append + * @param bool $encoded + * @param bool $firstLine * * @return string */ diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Headers/PathHeader.php b/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Headers/PathHeader.php index eea9a9eed..2fffc7b4a 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Headers/PathHeader.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Headers/PathHeader.php @@ -11,7 +11,7 @@ /** * A Path Header in Swift Mailer, such a Return-Path. * - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_Mime_Headers_PathHeader extends Swift_Mime_Headers_AbstractHeader { diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Headers/UnstructuredHeader.php b/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Headers/UnstructuredHeader.php index 41d4e63d7..86177f14a 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Headers/UnstructuredHeader.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Headers/UnstructuredHeader.php @@ -11,7 +11,7 @@ /** * A Simple MIME Header. * - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_Mime_Headers_UnstructuredHeader extends Swift_Mime_Headers_AbstractHeader { diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Message.php b/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Message.php index 29bc4b337..9b36d2162 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Message.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Message.php @@ -11,7 +11,7 @@ /** * A Message (RFC 2822) object. * - * @author Chris Corbyn + * @author Chris Corbyn */ interface Swift_Mime_Message extends Swift_Mime_MimeEntity { @@ -39,7 +39,7 @@ public function getSubject(); /** * Set the origination date of the message as a UNIX timestamp. * - * @param int $date + * @param int $date */ public function setDate($date); diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Mime/MimeEntity.php b/swiftmailer/swiftmailer/lib/classes/Swift/Mime/MimeEntity.php index cd8b8a2b8..30f460cdc 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Mime/MimeEntity.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Mime/MimeEntity.php @@ -11,7 +11,7 @@ /** * A MIME entity, such as an attachment. * - * @author Chris Corbyn + * @author Chris Corbyn */ interface Swift_Mime_MimeEntity extends Swift_Mime_CharsetObserver, Swift_Mime_EncodingObserver { @@ -31,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 @@ -39,6 +40,7 @@ public function getNestingLevel(); /** * Get the qualified content-type of this mime entity. + * * @return string */ public function getContentType(); diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Mime/MimePart.php b/swiftmailer/swiftmailer/lib/classes/Swift/Mime/MimePart.php index b13e44823..50fadfb7a 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Mime/MimePart.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Mime/MimePart.php @@ -11,7 +11,7 @@ /** * A MIME part, in a multipart message. * - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_Mime_MimePart extends Swift_Mime_SimpleMimeEntity { @@ -128,15 +128,13 @@ public function setFormat($format) */ public function getDelSp() { - return ($this->_getHeaderParameter('Content-Type', 'delsp') == 'yes') - ? true - : false; + return 'yes' == $this->_getHeaderParameter('Content-Type', 'delsp') ? true : false; } /** * Turn delsp on or off for this entity. * - * @param bool $delsp + * @param bool $delsp * * @return Swift_Mime_MimePart */ @@ -196,7 +194,7 @@ protected function _setNestingLevel($level) 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, $charset, 'utf-8'); diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Mime/ParameterizedHeader.php b/swiftmailer/swiftmailer/lib/classes/Swift/Mime/ParameterizedHeader.php index ea793201e..e15c6ef95 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Mime/ParameterizedHeader.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Mime/ParameterizedHeader.php @@ -11,7 +11,7 @@ /** * A MIME Header with parameters. * - * @author Chris Corbyn + * @author Chris Corbyn */ interface Swift_Mime_ParameterizedHeader extends Swift_Mime_Header { diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Mime/SimpleHeaderFactory.php b/swiftmailer/swiftmailer/lib/classes/Swift/Mime/SimpleHeaderFactory.php index b50d4d54e..1ca504e75 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Mime/SimpleHeaderFactory.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Mime/SimpleHeaderFactory.php @@ -11,7 +11,7 @@ /** * Creates MIME headers. * - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_Mime_SimpleHeaderFactory implements Swift_Mime_HeaderFactory { @@ -64,8 +64,9 @@ public function createMailboxHeader($name, $addresses = null) /** * Create a new Date header using $timestamp (UNIX time). - * @param string $name - * @param int|null $timestamp + * + * @param string $name + * @param int|null $timestamp * * @return Swift_Mime_Header */ @@ -111,12 +112,7 @@ public function createTextHeader($name, $value = null) 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); } @@ -179,8 +175,8 @@ public function charsetChanged($charset) } /** - * Make a deep copy of object - */ + * Make a deep copy of object. + */ public function __clone() { $this->_encoder = clone $this->_encoder; diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Mime/SimpleHeaderSet.php b/swiftmailer/swiftmailer/lib/classes/Swift/Mime/SimpleHeaderSet.php index b44a02ca1..e2d0e8746 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Mime/SimpleHeaderSet.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Mime/SimpleHeaderSet.php @@ -11,7 +11,7 @@ /** * A collection of MIME headers. * - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_Mime_SimpleHeaderSet implements Swift_Mime_HeaderSet { @@ -71,8 +71,8 @@ public function addMailboxHeader($name, $addresses = null) /** * Add a new Date header using $timestamp (UNIX time). * - * @param string $name - * @param int $timestamp + * @param string $name + * @param int $timestamp */ public function addDateHeader($name, $timestamp = null) { @@ -131,8 +131,8 @@ public function addPathHeader($name, $path = null) * * If multiple headers match, the actual one may be specified by $index. * - * @param string $name - * @param int $index + * @param string $name + * @param int $index * * @return bool */ @@ -140,7 +140,16 @@ public function has($name, $index = 0) { $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]); } /** @@ -166,17 +175,25 @@ public function set(Swift_Mime_Header $header, $index = 0) * If multiple headers match, the actual one may be specified by $index. * Returns NULL if none present. * - * @param string $name - * @param int $index + * @param string $name + * @param int $index * * @return Swift_Mime_Header */ public function get($name, $index = 0) { - if ($this->has($name, $index)) { - $lowerName = strtolower($name); + $name = strtolower($name); + + if (func_num_args() < 2) { + if ($this->has($name)) { + $values = array_values($this->_headers[$name]); - return $this->_headers[$lowerName][$index]; + return array_shift($values); + } + } else { + if ($this->has($name, $index)) { + return $this->_headers[$name][$index]; + } } } @@ -207,7 +224,7 @@ public function getAll($name = null) } /** - * Return the name of all Headers + * Return the name of all Headers. * * @return array */ @@ -221,13 +238,13 @@ public function listAll() return array_keys($headers); } - /** + /** * Remove the header with the given $name if it's set. * * If multiple headers match, the actual one may be specified by $index. * - * @param string $name - * @param int $index + * @param string $name + * @param int $index */ public function remove($name, $index = 0) { @@ -349,12 +366,13 @@ private function _sortHeaders($a, $b) { $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; @@ -362,7 +380,7 @@ private function _sortHeaders($a, $b) return -1; } - return ($aPos < $bPos) ? -1 : 1; + return $aPos < $bPos ? -1 : 1; } /** Test if the given Header is always displayed */ @@ -382,8 +400,8 @@ private function _notifyHeadersOfCharset($charset) } /** - * Make a deep copy of object - */ + * Make a deep copy of object. + */ public function __clone() { $this->_factory = clone $this->_factory; diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Mime/SimpleMessage.php b/swiftmailer/swiftmailer/lib/classes/Swift/Mime/SimpleMessage.php index 16d8d091c..72d40cee0 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Mime/SimpleMessage.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Mime/SimpleMessage.php @@ -11,10 +11,16 @@ /** * The default email message class. * - * @author Chris Corbyn + * @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. * @@ -67,7 +73,7 @@ public function getNestingLevel() * * @param string $subject * - * @return Swift_Mime_SimpleMessage + * @return $this */ public function setSubject($subject) { @@ -91,9 +97,9 @@ public function getSubject() /** * Set the date at which this message was created. * - * @param int $date + * @param int $date * - * @return Swift_Mime_SimpleMessage + * @return $this */ public function setDate($date) { @@ -119,7 +125,7 @@ public function getDate() * * @param string $address * - * @return Swift_Mime_SimpleMessage + * @return $this */ public function setReturnPath($address) { @@ -148,7 +154,7 @@ public function getReturnPath() * @param string $address * @param string $name optional * - * @return Swift_Mime_SimpleMessage + * @return $this */ public function setSender($address, $name = null) { @@ -181,7 +187,7 @@ public function getSender() * @param string $address * @param string $name optional * - * @return Swift_Mime_SimpleMessage + * @return $this */ public function addFrom($address, $name = null) { @@ -199,10 +205,10 @@ public function addFrom($address, $name = null) * If $name is passed and the first parameter is a string, this name will be * associated with the address. * - * @param string $addresses - * @param string $name optional + * @param string|array $addresses + * @param string $name optional * - * @return Swift_Mime_SimpleMessage + * @return $this */ public function setFrom($addresses, $name = null) { @@ -235,7 +241,7 @@ public function getFrom() * @param string $address * @param string $name optional * - * @return Swift_Mime_SimpleMessage + * @return $this */ public function addReplyTo($address, $name = null) { @@ -253,10 +259,10 @@ public function addReplyTo($address, $name = null) * 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) { @@ -289,7 +295,7 @@ public function getReplyTo() * @param string $address * @param string $name optional * - * @return Swift_Mime_SimpleMessage + * @return $this */ public function addTo($address, $name = null) { @@ -311,7 +317,7 @@ public function addTo($address, $name = null) * @param mixed $addresses * @param string $name optional * - * @return Swift_Mime_SimpleMessage + * @return $this */ public function setTo($addresses, $name = null) { @@ -344,7 +350,7 @@ public function getTo() * @param string $address * @param string $name optional * - * @return Swift_Mime_SimpleMessage + * @return $this */ public function addCc($address, $name = null) { @@ -363,7 +369,7 @@ public function addCc($address, $name = null) * @param mixed $addresses * @param string $name optional * - * @return Swift_Mime_SimpleMessage + * @return $this */ public function setCc($addresses, $name = null) { @@ -396,7 +402,7 @@ public function getCc() * @param string $address * @param string $name optional * - * @return Swift_Mime_SimpleMessage + * @return $this */ public function addBcc($address, $name = null) { @@ -415,7 +421,7 @@ public function addBcc($address, $name = null) * @param mixed $addresses * @param string $name optional * - * @return Swift_Mime_SimpleMessage + * @return $this */ public function setBcc($addresses, $name = null) { @@ -445,18 +451,18 @@ public function getBcc() * * The value is an integer where 1 is the highest priority and 5 is the lowest. * - * @param int $priority + * @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)) { @@ -491,11 +497,11 @@ public function getPriority() } /** - * 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) { @@ -522,7 +528,7 @@ public function getReadReceiptTo() * * @param Swift_Mime_MimeEntity $entity * - * @return Swift_Mime_SimpleMessage + * @return $this */ public function attach(Swift_Mime_MimeEntity $entity) { @@ -536,7 +542,7 @@ public function attach(Swift_Mime_MimeEntity $entity) * * @param Swift_Mime_MimeEntity $entity * - * @return Swift_Mime_SimpleMessage + * @return $this */ public function detach(Swift_Mime_MimeEntity $entity) { diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Mime/SimpleMimeEntity.php b/swiftmailer/swiftmailer/lib/classes/Swift/Mime/SimpleMimeEntity.php index 5aaf29711..f169584d3 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Mime/SimpleMimeEntity.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Mime/SimpleMimeEntity.php @@ -11,7 +11,7 @@ /** * A MIME entity, in a multipart message. * - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_Mime_SimpleMimeEntity implements Swift_Mime_MimeEntity { @@ -161,7 +161,7 @@ public function getContentType() * * @param string $type * - * @return Swift_Mime_SimpleMimeEntity + * @return $this */ public function setContentType($type) { @@ -192,7 +192,7 @@ public function getId() * * @param string $id * - * @return Swift_Mime_SimpleMimeEntity + * @return $this */ public function setId($id) { @@ -223,7 +223,7 @@ public function getDescription() * * @param string $description * - * @return Swift_Mime_SimpleMimeEntity + * @return $this */ public function setDescription($description) { @@ -249,9 +249,9 @@ public function getMaxLineLength() * * Though not enforced by the library, lines should not exceed 1000 chars. * - * @param int $length + * @param int $length * - * @return Swift_Mime_SimpleMimeEntity + * @return $this */ public function setMaxLineLength($length) { @@ -276,17 +276,13 @@ public function getChildren() * @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; @@ -311,15 +307,15 @@ public function setChildren(array $children, $compoundLevel = null) } } - 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; } } @@ -349,9 +345,7 @@ public function setChildren(array $children, $compoundLevel = null) */ 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; } /** @@ -361,7 +355,7 @@ public function getBody() * @param mixed $body * @param string $contentType optional * - * @return Swift_Mime_SimpleMimeEntity + * @return $this */ public function setBody($body, $contentType = null) { @@ -392,7 +386,7 @@ public function getEncoder() * * @param Swift_Mime_ContentEncoder $encoder * - * @return Swift_Mime_SimpleMimeEntity + * @return $this */ public function setEncoder(Swift_Mime_ContentEncoder $encoder) { @@ -426,9 +420,9 @@ public function getBoundary() * * @param string $boundary * - * @return Swift_Mime_SimpleMimeEntity - * * @throws Swift_RfcComplianceException + * + * @return $this */ public function setBoundary($boundary) { @@ -486,12 +480,8 @@ protected function _bodyToString() 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; } @@ -576,7 +566,7 @@ protected function _bodyToByteStream(Swift_InputByteStream $is) } /** - * 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() { @@ -602,9 +592,9 @@ protected function _setHeaderFieldModel($field, $model) $this->_headers->get($field)->setFieldBodyModel($model); return true; - } else { - return false; } + + return false; } /** @@ -626,9 +616,9 @@ protected function _setHeaderParameter($field, $parameter, $value) $this->_headers->get($field)->setParameter($parameter, $value); return true; - } else { - return false; } + + return false; } /** @@ -702,6 +692,8 @@ private function _readStream(Swift_OutputByteStream $os) $string .= $bytes; } + $os->setReadPointer(0); + return $string; } @@ -714,9 +706,7 @@ private function _setEncoding($encoding) 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.'); } } @@ -755,18 +745,16 @@ private function _getNeededChildLevel($child, $compoundLevel) $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) @@ -805,17 +793,13 @@ private function _sortChildren() private function _childSortAlgorithm($a, $b) { $typePrefs = array(); - $types = array( - strtolower($a->getContentType()), - strtolower($b->getContentType()), - ); + $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); + $typePrefs[] = array_key_exists($type, $this->_alternativePartOrder) ? $this->_alternativePartOrder[$type] : max($this->_alternativePartOrder) + 1; } - return ($typePrefs[0] >= $typePrefs[1]) ? 1 : -1; + return $typePrefs[0] >= $typePrefs[1] ? 1 : -1; } // -- Destructor @@ -837,25 +821,19 @@ public function __destruct() */ private function _assertValidId($id) { - if (!preg_match( - '/^'.$this->_grammar->getDefinition('id-left').'@'. - $this->_grammar->getDefinition('id-right').'$/D', - $id - )) { - throw new Swift_RfcComplianceException( - 'Invalid ID given <'.$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 + * Make a deep copy of object. */ public function __clone() { $this->_headers = clone $this->_headers; $this->_encoder = clone $this->_encoder; - $this->_cacheKey = uniqid(); + $this->_cacheKey = md5(uniqid(getmypid().mt_rand(), true)); $children = array(); foreach ($this->_children as $pos => $child) { $children[$pos] = clone $child; diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/MimePart.php b/swiftmailer/swiftmailer/lib/classes/Swift/MimePart.php index 5702d1c14..215f8db34 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/MimePart.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/MimePart.php @@ -11,7 +11,7 @@ /** * A MIME part, in a multipart message. * - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_MimePart extends Swift_Mime_MimePart { diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/NullTransport.php b/swiftmailer/swiftmailer/lib/classes/Swift/NullTransport.php index 726d83ca1..b38e1cf76 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/NullTransport.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/NullTransport.php @@ -11,7 +11,7 @@ /** * Pretends messages have been sent, but just ignores them. * - * @author Fabien Potencier + * @author Fabien Potencier */ class Swift_NullTransport extends Swift_Transport_NullTransport { diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/OutputByteStream.php b/swiftmailer/swiftmailer/lib/classes/Swift/OutputByteStream.php index 0c2783f0f..1f26f9be5 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/OutputByteStream.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/OutputByteStream.php @@ -14,7 +14,7 @@ * Classes implementing this interface may use a subsystem which requires less * memory than working with large strings of data. * - * @author Chris Corbyn + * @author Chris Corbyn */ interface Swift_OutputByteStream { @@ -25,22 +25,22 @@ interface Swift_OutputByteStream * If less bytes exist than are requested the remaining bytes are given instead. * If no bytes are remaining at all, boolean false is returned. * - * @param int $length - * - * @return string|bool + * @param int $length * * @throws Swift_IoException + * + * @return string|bool */ public function read($length); /** * Move the internal read pointer to $byteOffset in the stream. * - * @param int $byteOffset - * - * @return bool + * @param int $byteOffset * * @throws Swift_IoException + * + * @return bool */ public function setReadPointer($byteOffset); } diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/AntiFloodPlugin.php b/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/AntiFloodPlugin.php index 28f3a817b..a2ec2abcd 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/AntiFloodPlugin.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/AntiFloodPlugin.php @@ -11,7 +11,7 @@ /** * Reduces network flooding when sending large amounts of mail. * - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_Plugins_AntiFloodPlugin implements Swift_Events_SendListener, Swift_Plugins_Sleeper { @@ -60,7 +60,7 @@ public function __construct($threshold = 99, $sleep = 0, Swift_Plugins_Sleeper $ /** * Set the number of emails to send before restarting. * - * @param int $threshold + * @param int $threshold */ public function setThreshold($threshold) { @@ -80,7 +80,7 @@ public function getThreshold() /** * Set the number of seconds to sleep for during a restart. * - * @param int $sleep time + * @param int $sleep time */ public function setSleepTime($sleep) { @@ -128,7 +128,7 @@ public function sendPerformed(Swift_Events_SendEvent $evt) /** * Sleep for $seconds. * - * @param int $seconds + * @param int $seconds */ public function sleep($seconds) { diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/BandwidthMonitorPlugin.php b/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/BandwidthMonitorPlugin.php index af1701a06..f7e18d0eb 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/BandwidthMonitorPlugin.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/BandwidthMonitorPlugin.php @@ -11,7 +11,7 @@ /** * Reduces network flooding when sending large amounts of mail. * - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_Plugins_BandwidthMonitorPlugin implements Swift_Events_SendListener, Swift_Events_CommandListener, Swift_Events_ResponseListener, Swift_InputByteStream { diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/Decorator/Replacements.php b/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/Decorator/Replacements.php index 861843398..9f9f08b56 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/Decorator/Replacements.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/Decorator/Replacements.php @@ -11,7 +11,7 @@ /** * Allows customization of Messages on-the-fly. * - * @author Chris Corbyn + * @author Chris Corbyn */ interface Swift_Plugins_Decorator_Replacements { diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/DecoratorPlugin.php b/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/DecoratorPlugin.php index e1aaebe9c..0762b36d2 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/DecoratorPlugin.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/DecoratorPlugin.php @@ -11,8 +11,8 @@ /** * Allows customization of Messages on-the-fly. * - * @author Chris Corbyn - * @author Fabien Potencier + * @author Chris Corbyn + * @author Fabien Potencier */ class Swift_Plugins_DecoratorPlugin implements Swift_Events_SendListener, Swift_Plugins_Decorator_Replacements { @@ -123,7 +123,7 @@ public function beforeSendPerformed(Swift_Events_SendEvent $evt) $children = (array) $message->getChildren(); foreach ($children as $child) { - list($type, ) = sscanf($child->getContentType(), '%[^/]/%s'); + list($type) = sscanf($child->getContentType(), '%[^/]/%s'); if ('text' == $type) { $body = $child->getBody(); $bodyReplaced = str_replace( @@ -157,12 +157,9 @@ public function getReplacementsFor($address) { if ($this->_replacements instanceof Swift_Plugins_Decorator_Replacements) { return $this->_replacements->getReplacementsFor($address); - } else { - return isset($this->_replacements[$address]) - ? $this->_replacements[$address] - : null - ; } + + return isset($this->_replacements[$address]) ? $this->_replacements[$address] : null; } /** diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/ImpersonatePlugin.php b/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/ImpersonatePlugin.php index 5bd0bbda5..7552b67a2 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/ImpersonatePlugin.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/ImpersonatePlugin.php @@ -1,4 +1,5 @@ getCommand(); - $this->_logger->add(sprintf(">> %s", $command)); + $this->_logger->add(sprintf('>> %s', $command)); } /** @@ -75,7 +75,7 @@ public function commandSent(Swift_Events_CommandEvent $evt) public function responseReceived(Swift_Events_ResponseEvent $evt) { $response = $evt->getResponse(); - $this->_logger->add(sprintf("<< %s", $response)); + $this->_logger->add(sprintf('<< %s', $response)); } /** @@ -86,7 +86,7 @@ public function responseReceived(Swift_Events_ResponseEvent $evt) public function beforeTransportStarted(Swift_Events_TransportChangeEvent $evt) { $transportName = get_class($evt->getSource()); - $this->_logger->add(sprintf("++ Starting %s", $transportName)); + $this->_logger->add(sprintf('++ Starting %s', $transportName)); } /** @@ -97,7 +97,7 @@ public function beforeTransportStarted(Swift_Events_TransportChangeEvent $evt) public function transportStarted(Swift_Events_TransportChangeEvent $evt) { $transportName = get_class($evt->getSource()); - $this->_logger->add(sprintf("++ %s started", $transportName)); + $this->_logger->add(sprintf('++ %s started', $transportName)); } /** @@ -108,7 +108,7 @@ public function transportStarted(Swift_Events_TransportChangeEvent $evt) public function beforeTransportStopped(Swift_Events_TransportChangeEvent $evt) { $transportName = get_class($evt->getSource()); - $this->_logger->add(sprintf("++ Stopping %s", $transportName)); + $this->_logger->add(sprintf('++ Stopping %s', $transportName)); } /** @@ -119,7 +119,7 @@ public function beforeTransportStopped(Swift_Events_TransportChangeEvent $evt) public function transportStopped(Swift_Events_TransportChangeEvent $evt) { $transportName = get_class($evt->getSource()); - $this->_logger->add(sprintf("++ %s stopped", $transportName)); + $this->_logger->add(sprintf('++ %s stopped', $transportName)); } /** @@ -131,11 +131,12 @@ public function exceptionThrown(Swift_Events_TransportExceptionEvent $evt) { $e = $evt->getException(); $message = $e->getMessage(); - $this->_logger->add(sprintf("!! %s", $message)); + $code = $e->getCode(); + $this->_logger->add(sprintf('!! %s (code: %s)', $message, $code)); $message .= PHP_EOL; $message .= 'Log data:'.PHP_EOL; $message .= $this->_logger->dump(); $evt->cancelBubble(); - throw new Swift_TransportException($message); + throw new Swift_TransportException($message, $code, $e->getPrevious()); } } diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/Loggers/ArrayLogger.php b/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/Loggers/ArrayLogger.php index f1739e8e6..865bb0aa3 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/Loggers/ArrayLogger.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/Loggers/ArrayLogger.php @@ -11,7 +11,7 @@ /** * Logs to an Array backend. * - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_Plugins_Loggers_ArrayLogger implements Swift_Plugins_Logger { @@ -32,7 +32,7 @@ class Swift_Plugins_Loggers_ArrayLogger implements Swift_Plugins_Logger /** * Create a new ArrayLogger with a maximum of $size entries. * - * @var int $size + * @var int */ public function __construct($size = 50) { diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/Loggers/EchoLogger.php b/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/Loggers/EchoLogger.php index e8b6c18a3..3583297ab 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/Loggers/EchoLogger.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/Loggers/EchoLogger.php @@ -11,7 +11,7 @@ /** * Prints all log messages in real time. * - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_Plugins_Loggers_EchoLogger implements Swift_Plugins_Logger { @@ -21,7 +21,7 @@ class Swift_Plugins_Loggers_EchoLogger implements Swift_Plugins_Logger /** * Create a new EchoLogger. * - * @param bool $isHtml + * @param bool $isHtml */ public function __construct($isHtml = true) { diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/MessageLogger.php b/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/MessageLogger.php index a02ad98e8..e622cb37d 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/MessageLogger.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/MessageLogger.php @@ -11,7 +11,7 @@ /** * Stores all sent emails for further usage. * - * @author Fabien Potencier + * @author Fabien Potencier */ class Swift_Plugins_MessageLogger implements Swift_Events_SendListener { @@ -26,7 +26,7 @@ public function __construct() } /** - * Get the message list + * Get the message list. * * @return array */ @@ -36,9 +36,9 @@ public function getMessages() } /** - * Get the message count + * Get the message count. * - * @return int count + * @return int count */ public function countMessages() { @@ -46,8 +46,7 @@ public function countMessages() } /** - * Empty the message list - * + * Empty the message list. */ public function clear() { diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/Pop/Pop3Connection.php b/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/Pop/Pop3Connection.php index 1e18016a9..fb99e4c94 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/Pop/Pop3Connection.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/Pop/Pop3Connection.php @@ -11,7 +11,7 @@ /** * Pop3Connection interface for connecting and disconnecting to a POP3 host. * - * @author Chris Corbyn + * @author Chris Corbyn */ interface Swift_Plugins_Pop_Pop3Connection { diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/Pop/Pop3Exception.php b/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/Pop/Pop3Exception.php index 870207269..dc7be0c4e 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/Pop/Pop3Exception.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/Pop/Pop3Exception.php @@ -11,7 +11,7 @@ /** * Pop3Exception thrown when an error occurs connecting to a POP3 host. * - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_Plugins_Pop_Pop3Exception extends Swift_IoException { diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/PopBeforeSmtpPlugin.php b/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/PopBeforeSmtpPlugin.php index 77b4d68ce..18abb7706 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/PopBeforeSmtpPlugin.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/PopBeforeSmtpPlugin.php @@ -11,7 +11,7 @@ /** * Makes sure a connection to a POP3 host has been established prior to connecting to SMTP. * - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_Plugins_PopBeforeSmtpPlugin implements Swift_Events_TransportChangeListener, Swift_Plugins_Pop_Pop3Connection { @@ -45,9 +45,9 @@ class Swift_Plugins_PopBeforeSmtpPlugin implements Swift_Events_TransportChangeL /** * Create a new PopBeforeSmtpPlugin for $host and $port. * - * @param string $host - * @param int $port - * @param string $crypto as "tls" or "ssl" + * @param string $host + * @param int $port + * @param string $crypto as "tls" or "ssl" */ public function __construct($host, $port = 110, $crypto = null) { @@ -59,9 +59,9 @@ public function __construct($host, $port = 110, $crypto = null) /** * Create a new PopBeforeSmtpPlugin for $host and $port. * - * @param string $host - * @param int $port - * @param string $crypto as "tls" or "ssl" + * @param string $host + * @param int $port + * @param string $crypto as "tls" or "ssl" * * @return Swift_Plugins_PopBeforeSmtpPlugin */ @@ -97,7 +97,7 @@ public function bindSmtp(Swift_Transport $smtp) /** * Set the connection timeout in seconds (default 10). * - * @param int $timeout + * @param int $timeout * * @return Swift_Plugins_PopBeforeSmtpPlugin */ diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/RedirectingPlugin.php b/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/RedirectingPlugin.php index cc86134c6..c3a1f8685 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/RedirectingPlugin.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/RedirectingPlugin.php @@ -11,7 +11,7 @@ /** * Redirects all email to a single recipient. * - * @author Fabien Potencier + * @author Fabien Potencier */ class Swift_Plugins_RedirectingPlugin implements Swift_Events_SendListener { @@ -23,7 +23,7 @@ class Swift_Plugins_RedirectingPlugin implements Swift_Events_SendListener private $_recipient; /** - * List of regular expression for recipient whitelisting + * List of regular expression for recipient whitelisting. * * @var array */ @@ -33,7 +33,7 @@ class Swift_Plugins_RedirectingPlugin implements Swift_Events_SendListener * Create a new RedirectingPlugin. * * @param mixed $recipient - * @param array $whitelist + * @param array $whitelist */ public function __construct($recipient, array $whitelist = array()) { @@ -62,7 +62,7 @@ public function getRecipient() } /** - * Set a list of regular expressions to whitelist certain recipients + * Set a list of regular expressions to whitelist certain recipients. * * @param array $whitelist */ @@ -72,7 +72,7 @@ public function setWhitelist(array $whitelist) } /** - * Get the whitelist + * Get the whitelist. * * @return array */ @@ -116,7 +116,7 @@ public function beforeSendPerformed(Swift_Events_SendEvent $evt) $to = array(); } - foreach ( (array) $this->_recipient as $recipient) { + foreach ((array) $this->_recipient as $recipient) { if (!array_key_exists($recipient, $to)) { $message->addTo($recipient); } @@ -124,10 +124,10 @@ public function beforeSendPerformed(Swift_Events_SendEvent $evt) } /** - * Filter header set against a whitelist of regular expressions + * Filter header set against a whitelist of regular expressions. * * @param Swift_Mime_HeaderSet $headerSet - * @param string $type + * @param string $type */ private function _filterHeaderSet(Swift_Mime_HeaderSet $headerSet, $type) { @@ -137,9 +137,10 @@ private function _filterHeaderSet(Swift_Mime_HeaderSet $headerSet, $type) } /** - * Filtered list of addresses => name pairs + * Filtered list of addresses => name pairs. * * @param array $recipients + * * @return array */ private function _filterNameAddresses(array $recipients) @@ -156,9 +157,10 @@ private function _filterNameAddresses(array $recipients) } /** - * Matches address against whitelist of regular expressions + * Matches address against whitelist of regular expressions. * * @param $recipient + * * @return bool */ protected function _isWhitelisted($recipient) diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/Reporter.php b/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/Reporter.php index 294b547d2..0f21b7d60 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/Reporter.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/Reporter.php @@ -11,7 +11,7 @@ /** * The Reporter plugin sends pass/fail notification to a Reporter. * - * @author Chris Corbyn + * @author Chris Corbyn */ interface Swift_Plugins_Reporter { diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/ReporterPlugin.php b/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/ReporterPlugin.php index 452945339..a37901ff0 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/ReporterPlugin.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/ReporterPlugin.php @@ -11,7 +11,7 @@ /** * Does real time reporting of pass/fail for each recipient. * - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_Plugins_ReporterPlugin implements Swift_Events_SendListener { @@ -49,25 +49,13 @@ public function sendPerformed(Swift_Events_SendEvent $evt) $message = $evt->getMessage(); $failures = array_flip($evt->getFailedRecipients()); foreach ((array) $message->getTo() as $address => $null) { - $this->_reporter->notify( - $message, $address, (array_key_exists($address, $failures) - ? Swift_Plugins_Reporter::RESULT_FAIL - : Swift_Plugins_Reporter::RESULT_PASS) - ); + $this->_reporter->notify($message, $address, array_key_exists($address, $failures) ? Swift_Plugins_Reporter::RESULT_FAIL : Swift_Plugins_Reporter::RESULT_PASS); } foreach ((array) $message->getCc() as $address => $null) { - $this->_reporter->notify( - $message, $address, (array_key_exists($address, $failures) - ? Swift_Plugins_Reporter::RESULT_FAIL - : Swift_Plugins_Reporter::RESULT_PASS) - ); + $this->_reporter->notify($message, $address, array_key_exists($address, $failures) ? Swift_Plugins_Reporter::RESULT_FAIL : Swift_Plugins_Reporter::RESULT_PASS); } foreach ((array) $message->getBcc() as $address => $null) { - $this->_reporter->notify( - $message, $address, (array_key_exists($address, $failures) - ? Swift_Plugins_Reporter::RESULT_FAIL - : Swift_Plugins_Reporter::RESULT_PASS) - ); + $this->_reporter->notify($message, $address, array_key_exists($address, $failures) ? Swift_Plugins_Reporter::RESULT_FAIL : Swift_Plugins_Reporter::RESULT_PASS); } } } diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/Reporters/HitReporter.php b/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/Reporters/HitReporter.php index ea60f51dc..cad9d168e 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/Reporters/HitReporter.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/Reporters/HitReporter.php @@ -11,7 +11,7 @@ /** * A reporter which "collects" failures for the Reporter plugin. * - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_Plugins_Reporters_HitReporter implements Swift_Plugins_Reporter { diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/Reporters/HtmlReporter.php b/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/Reporters/HtmlReporter.php index 817e32f51..c62593557 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/Reporters/HtmlReporter.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/Reporters/HtmlReporter.php @@ -11,7 +11,7 @@ /** * A HTML output reporter for the Reporter plugin. * - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_Plugins_Reporters_HtmlReporter implements Swift_Plugins_Reporter { @@ -25,14 +25,14 @@ class Swift_Plugins_Reporters_HtmlReporter implements Swift_Plugins_Reporter public function notify(Swift_Mime_Message $message, $address, $result) { if (self::RESULT_PASS == $result) { - echo "
".PHP_EOL; - echo "PASS ".$address.PHP_EOL; - echo "
".PHP_EOL; + echo '
'.PHP_EOL; + echo 'PASS '.$address.PHP_EOL; + echo '
'.PHP_EOL; flush(); } else { - echo "
".PHP_EOL; - echo "FAIL ".$address.PHP_EOL; - echo "
".PHP_EOL; + echo '
'.PHP_EOL; + echo 'FAIL '.$address.PHP_EOL; + echo '
'.PHP_EOL; flush(); } } diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/Sleeper.php b/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/Sleeper.php index 38727052b..595c0f603 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/Sleeper.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/Sleeper.php @@ -11,14 +11,14 @@ /** * Sleeps for a duration of time. * - * @author Chris Corbyn + * @author Chris Corbyn */ interface Swift_Plugins_Sleeper { /** * Sleep for $seconds. * - * @param int $seconds + * @param int $seconds */ public function sleep($seconds); } diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/ThrottlerPlugin.php b/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/ThrottlerPlugin.php index 0d2c135e4..2f4b9a75e 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/ThrottlerPlugin.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/ThrottlerPlugin.php @@ -11,7 +11,7 @@ /** * Throttles the rate at which emails are sent. * - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_Plugins_ThrottlerPlugin extends Swift_Plugins_BandwidthMonitorPlugin implements Swift_Plugins_Sleeper, Swift_Plugins_Timer { @@ -98,16 +98,16 @@ public function beforeSendPerformed(Swift_Events_SendEvent $evt) $duration = $time - $this->_start; switch ($this->_mode) { - case self::BYTES_PER_MINUTE : + case self::BYTES_PER_MINUTE: $sleep = $this->_throttleBytesPerMinute($duration); break; - case self::MESSAGES_PER_SECOND : + case self::MESSAGES_PER_SECOND: $sleep = $this->_throttleMessagesPerSecond($duration); break; - case self::MESSAGES_PER_MINUTE : + case self::MESSAGES_PER_MINUTE: $sleep = $this->_throttleMessagesPerMinute($duration); break; - default : + default: $sleep = 0; break; } @@ -131,7 +131,7 @@ public function sendPerformed(Swift_Events_SendEvent $evt) /** * Sleep for $seconds. * - * @param int $seconds + * @param int $seconds */ public function sleep($seconds) { @@ -151,15 +151,15 @@ public function getTimestamp() { if (isset($this->_timer)) { return $this->_timer->getTimestamp(); - } else { - return time(); } + + return time(); } /** * Get a number of seconds to sleep for. * - * @param int $timePassed + * @param int $timePassed * * @return int */ @@ -187,7 +187,7 @@ private function _throttleMessagesPerSecond($timePassed) /** * Get a number of seconds to sleep for. * - * @param int $timePassed + * @param int $timePassed * * @return int */ diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/Timer.php b/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/Timer.php index a05e3181e..9c8deb38a 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/Timer.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/Timer.php @@ -11,7 +11,7 @@ /** * Provides timestamp data. * - * @author Chris Corbyn + * @author Chris Corbyn */ interface Swift_Plugins_Timer { diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Preferences.php b/swiftmailer/swiftmailer/lib/classes/Swift/Preferences.php index 7cd61312d..503db84d8 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Preferences.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Preferences.php @@ -11,7 +11,7 @@ /** * Changes some global preference settings in Swift Mailer. * - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_Preferences { @@ -85,7 +85,7 @@ public function setCacheType($type) /** * Set the QuotedPrintable dot escaper preference. * - * @param bool $dotEscape + * @param bool $dotEscape * * @return Swift_Preferences */ diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/ReplacementFilterFactory.php b/swiftmailer/swiftmailer/lib/classes/Swift/ReplacementFilterFactory.php index ca9e4f60d..2897474e7 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/ReplacementFilterFactory.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/ReplacementFilterFactory.php @@ -11,7 +11,7 @@ /** * Creates StreamFilters. * - * @author Chris Corbyn + * @author Chris Corbyn */ interface Swift_ReplacementFilterFactory { diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/RfcComplianceException.php b/swiftmailer/swiftmailer/lib/classes/Swift/RfcComplianceException.php index cdb2bee23..81bc4031e 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/RfcComplianceException.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/RfcComplianceException.php @@ -11,7 +11,7 @@ /** * RFC Compliance Exception class. * - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_RfcComplianceException extends Swift_SwiftException { diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/SendmailTransport.php b/swiftmailer/swiftmailer/lib/classes/Swift/SendmailTransport.php index 1ef0e5e17..974b24f27 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/SendmailTransport.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/SendmailTransport.php @@ -11,7 +11,7 @@ /** * SendmailTransport for sending mail through a Sendmail/Postfix (etc..) binary. * - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_SendmailTransport extends Swift_Transport_SendmailTransport { diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/SignedMessage.php b/swiftmailer/swiftmailer/lib/classes/Swift/SignedMessage.php index 66e1c68cd..2e7a8726d 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/SignedMessage.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/SignedMessage.php @@ -15,6 +15,7 @@ * * * @author Xavier De Cock + * * @deprecated */ class Swift_SignedMessage extends Swift_Message diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Signer.php b/swiftmailer/swiftmailer/lib/classes/Swift/Signer.php index 7448179fb..2d8176d90 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Signer.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Signer.php @@ -12,7 +12,7 @@ * Base Class of Signer Infrastructure. * * - * @author Xavier De Cock + * @author Xavier De Cock */ interface Swift_Signer { diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Signers/BodySigner.php b/swiftmailer/swiftmailer/lib/classes/Swift/Signers/BodySigner.php index 93dc8ac7a..9ffcef39c 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Signers/BodySigner.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Signers/BodySigner.php @@ -9,9 +9,9 @@ */ /** - * Body Signer Interface used to apply Body-Based Signature to a message + * Body Signer Interface used to apply Body-Based Signature to a message. * - * @author Xavier De Cock + * @author Xavier De Cock */ interface Swift_Signers_BodySigner extends Swift_Signer { @@ -25,7 +25,7 @@ interface Swift_Signers_BodySigner extends Swift_Signer public function signMessage(Swift_Message $message); /** - * Return the list of header a signer might tamper + * Return the list of header a signer might tamper. * * @return array */ diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Signers/DKIMSigner.php b/swiftmailer/swiftmailer/lib/classes/Swift/Signers/DKIMSigner.php index 220c3ac98..6ddd4f928 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Signers/DKIMSigner.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Signers/DKIMSigner.php @@ -9,91 +9,91 @@ */ /** - * DKIM Signer used to apply DKIM Signature to a message + * DKIM Signer used to apply DKIM Signature to a message. * - * @author Xavier De Cock + * @author Xavier De Cock */ class Swift_Signers_DKIMSigner implements Swift_Signers_HeaderSigner { /** - * PrivateKey + * PrivateKey. * * @var string */ protected $_privateKey; /** - * DomainName + * DomainName. * * @var string */ protected $_domainName; /** - * Selector + * Selector. * * @var string */ protected $_selector; /** - * Hash algorithm used + * Hash algorithm used. * * @var string */ protected $_hashAlgorithm = 'rsa-sha1'; /** - * Body canon method + * Body canon method. * * @var string */ protected $_bodyCanon = 'simple'; /** - * Header canon method + * Header canon method. * * @var string */ protected $_headerCanon = 'simple'; /** - * Headers not being signed + * Headers not being signed. * * @var array */ - protected $_ignoredHeaders = array(); + protected $_ignoredHeaders = array('return-path' => true); /** - * Signer identity + * Signer identity. * - * @var unknown_type + * @var string */ protected $_signerIdentity; /** - * BodyLength + * BodyLength. * * @var int */ protected $_bodyLen = 0; /** - * Maximum signedLen + * Maximum signedLen. * * @var int */ protected $_maxLen = PHP_INT_MAX; /** - * Embbed bodyLen in signature + * Embbed bodyLen in signature. * * @var bool */ protected $_showLen = false; /** - * When the signature has been applied (true means time()), false means not embedded + * When the signature has been applied (true means time()), false means not embedded. * * @var mixed */ @@ -101,7 +101,7 @@ class Swift_Signers_DKIMSigner implements Swift_Signers_HeaderSigner /** * When will the signature expires false means not embedded, if sigTimestamp is auto - * Expiration is relative, otherwhise it's absolute + * Expiration is relative, otherwhise it's absolute. * * @var int */ @@ -116,40 +116,33 @@ class Swift_Signers_DKIMSigner implements Swift_Signers_HeaderSigner // work variables /** - * Headers used to generate hash + * Headers used to generate hash. * * @var array */ protected $_signedHeaders = array(); /** - * If debugHeaders is set store debugDatas here + * If debugHeaders is set store debugDatas here. * * @var string */ private $_debugHeadersData = ''; /** - * Stores the bodyHash + * Stores the bodyHash. * * @var string */ private $_bodyHash = ''; /** - * Stores the signature header + * Stores the signature header. * * @var Swift_Mime_Headers_ParameterizedHeader */ protected $_dkimHeader; - /** - * Hash Handler - * - * @var hash_ressource - */ - private $_headerHashHandler; - private $_bodyHashHandler; private $_headerHash; @@ -169,7 +162,7 @@ class Swift_Signers_DKIMSigner implements Swift_Signers_HeaderSigner private $_bound = array(); /** - * Constructor + * Constructor. * * @param string $privateKey * @param string $domainName @@ -184,11 +177,12 @@ public function __construct($privateKey, $domainName, $selector) } /** - * Instanciate DKIMSigner + * Instanciate DKIMSigner. * * @param string $privateKey * @param string $domainName * @param string $selector + * * @return Swift_Signers_DKIMSigner */ public static function newInstance($privateKey, $domainName, $selector) @@ -197,14 +191,14 @@ public static function newInstance($privateKey, $domainName, $selector) } /** - * Reset the Signer + * Reset the Signer. + * * @see Swift_Signer::reset() */ public function reset() { $this->_headerHash = null; $this->_signedHeaders = array(); - $this->_headerHashHandler = null; $this->_bodyHash = null; $this->_bodyHashHandler = null; $this->_bodyCanonIgnoreStart = 2; @@ -224,8 +218,10 @@ public function reset() * second, etc etc). * * @param string $bytes - * @return int + * * @throws Swift_IoException + * + * @return int */ public function write($bytes) { @@ -296,9 +292,10 @@ public function flushBuffers() } /** - * Set hash_algorithm, must be one of rsa-sha256 | rsa-sha1 defaults to rsa-sha256 + * Set hash_algorithm, must be one of rsa-sha256 | rsa-sha1 defaults to rsa-sha256. * * @param string $hash + * * @return Swift_Signers_DKIMSigner */ public function setHashAlgorithm($hash) @@ -314,9 +311,10 @@ public function setHashAlgorithm($hash) } /** - * Set the body canonicalization algorithm + * Set the body canonicalization algorithm. * * @param string $canon + * * @return Swift_Signers_DKIMSigner */ public function setBodyCanon($canon) @@ -331,9 +329,10 @@ public function setBodyCanon($canon) } /** - * Set the header canonicalization algorithm + * Set the header canonicalization algorithm. * * @param string $canon + * * @return Swift_Signers_DKIMSigner */ public function setHeaderCanon($canon) @@ -348,9 +347,10 @@ public function setHeaderCanon($canon) } /** - * Set the signer identity + * Set the signer identity. * * @param string $identity + * * @return Swift_Signers_DKIMSigner */ public function setSignerIdentity($identity) @@ -361,9 +361,10 @@ public function setSignerIdentity($identity) } /** - * Set the length of the body to sign + * Set the length of the body to sign. * * @param mixed $len (bool or int) + * * @return Swift_Signers_DKIMSigner */ public function setBodySignedLen($len) @@ -372,7 +373,7 @@ public function setBodySignedLen($len) $this->_showLen = true; $this->_maxLen = PHP_INT_MAX; } elseif ($len === false) { - $this->showLen = false; + $this->_showLen = false; $this->_maxLen = PHP_INT_MAX; } else { $this->_showLen = true; @@ -383,9 +384,10 @@ public function setBodySignedLen($len) } /** - * Set the signature timestamp + * Set the signature timestamp. + * + * @param int $time A timestamp * - * @param timestamp $time * @return Swift_Signers_DKIMSigner */ public function setSignatureTimestamp($time) @@ -396,9 +398,10 @@ public function setSignatureTimestamp($time) } /** - * Set the signature expiration timestamp + * Set the signature expiration timestamp. + * + * @param int $time A timestamp * - * @param timestamp $time * @return Swift_Signers_DKIMSigner */ public function setSignatureExpiration($time) @@ -409,9 +412,10 @@ public function setSignatureExpiration($time) } /** - * Enable / disable the DebugHeaders + * Enable / disable the DebugHeaders. + * + * @param bool $debug * - * @param bool $debug * @return Swift_Signers_DKIMSigner */ public function setDebugHeaders($debug) @@ -422,17 +426,16 @@ public function setDebugHeaders($debug) } /** - * Start Body - * + * Start Body. */ public function startBody() { // Init switch ($this->_hashAlgorithm) { - case 'rsa-sha256' : + case 'rsa-sha256': $this->_bodyHashHandler = hash_init('sha256'); break; - case 'rsa-sha1' : + case 'rsa-sha1': $this->_bodyHashHandler = hash_init('sha1'); break; } @@ -440,8 +443,7 @@ public function startBody() } /** - * End Body - * + * End Body. */ public function endBody() { @@ -449,7 +451,7 @@ public function endBody() } /** - * Returns the list of Headers Tampered by this plugin + * Returns the list of Headers Tampered by this plugin. * * @return array */ @@ -463,9 +465,10 @@ public function getAlteredHeaders() } /** - * Adds an ignored Header + * Adds an ignored Header. * * @param string $header_name + * * @return Swift_Signers_DKIMSigner */ public function ignoreHeader($header_name) @@ -476,9 +479,10 @@ public function ignoreHeader($header_name) } /** - * Set the headers to sign + * Set the headers to sign. * * @param Swift_Mime_HeaderSet $headers + * * @return Swift_Signers_DKIMSigner */ public function setHeaders(Swift_Mime_HeaderSet $headers) @@ -488,7 +492,7 @@ public function setHeaders(Swift_Mime_HeaderSet $headers) $listHeaders = $headers->listAll(); foreach ($listHeaders as $hName) { // Check if we need to ignore Header - if (! isset($this->_ignoredHeaders[strtolower($hName)])) { + if (!isset($this->_ignoredHeaders[strtolower($hName)])) { if ($headers->has($hName)) { $tmp = $headers->getAll($hName); foreach ($tmp as $header) { @@ -505,9 +509,10 @@ public function setHeaders(Swift_Mime_HeaderSet $headers) } /** - * Add the signature to the given Headers + * Add the signature to the given Headers. * * @param Swift_Mime_HeaderSet $headers + * * @return Swift_Signers_DKIMSigner */ public function addSignature(Swift_Mime_HeaderSet $headers) @@ -552,7 +557,7 @@ public function addSignature(Swift_Mime_HeaderSet $headers) if ($this->_debugHeaders) { $headers->addTextHeader('X-DebugHash', base64_encode($this->_headerHash)); } - $this->_dkimHeader->setValue($string." b=".trim(chunk_split(base64_encode($this->_getEncryptedHash()), 73, " "))); + $this->_dkimHeader->setValue($string.' b='.trim(chunk_split(base64_encode($this->_getEncryptedHash()), 73, ' '))); return $this; } @@ -562,39 +567,43 @@ public function addSignature(Swift_Mime_HeaderSet $headers) protected function _addHeader($header, $is_sig = false) { switch ($this->_headerCanon) { - case 'relaxed' : + case 'relaxed': // Prepare Header and cascade $exploded = explode(':', $header, 2); $name = strtolower(trim($exploded[0])); - $value = str_replace("\r\n", "", $exploded[1]); - $value = preg_replace("/[ \t][ \t]+/", " ", $value); - $header = $name.":".trim($value).($is_sig ? '' : "\r\n"); - case 'simple' : + $value = str_replace("\r\n", '', $exploded[1]); + $value = preg_replace("/[ \t][ \t]+/", ' ', $value); + $header = $name.':'.trim($value).($is_sig ? '' : "\r\n"); + case 'simple': // Nothing to do } $this->_addToHeaderHash($header); } + /** + * @deprecated This method is currently useless in this class but it must be + * kept for BC reasons due to its "protected" scope. This method + * might be overriden by custom client code. + */ protected function _endOfHeaders() { - //$this->_headerHash=hash_final($this->_headerHashHandler, true); } protected function _canonicalizeBody($string) { $len = strlen($string); $canon = ''; - $method = ($this->_bodyCanon == "relaxed"); + $method = ($this->_bodyCanon == 'relaxed'); for ($i = 0; $i < $len; ++$i) { if ($this->_bodyCanonIgnoreStart > 0) { --$this->_bodyCanonIgnoreStart; continue; } switch ($string[$i]) { - case "\r" : + case "\r": $this->_bodyCanonLastChar = "\r"; break; - case "\n" : + case "\n": if ($this->_bodyCanonLastChar == "\r") { if ($method) { $this->_bodyCanonSpace = false; @@ -610,13 +619,13 @@ protected function _canonicalizeBody($string) // todo handle it but should never happen } break; - case " " : - case "\t" : + case ' ': + case "\t": if ($method) { $this->_bodyCanonSpace = true; break; } - default : + default: if ($this->_bodyCanonEmptyCounter > 0) { $canon .= str_repeat("\r\n", $this->_bodyCanonEmptyCounter); $this->_bodyCanonEmptyCounter = 0; @@ -663,6 +672,7 @@ private function _addToHeaderHash($header) /** * @throws Swift_SwiftException + * * @return string */ private function _getEncryptedHash() diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Signers/DomainKeySigner.php b/swiftmailer/swiftmailer/lib/classes/Swift/Signers/DomainKeySigner.php index b52ffdf4e..786cee7b7 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Signers/DomainKeySigner.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Signers/DomainKeySigner.php @@ -9,56 +9,56 @@ */ /** - * DomainKey Signer used to apply DomainKeys Signature to a message + * DomainKey Signer used to apply DomainKeys Signature to a message. * - * @author Xavier De Cock + * @author Xavier De Cock */ class Swift_Signers_DomainKeySigner implements Swift_Signers_HeaderSigner { /** - * PrivateKey + * PrivateKey. * * @var string */ protected $_privateKey; /** - * DomainName + * DomainName. * * @var string */ protected $_domainName; /** - * Selector + * Selector. * * @var string */ protected $_selector; /** - * Hash algorithm used + * Hash algorithm used. * * @var string */ protected $_hashAlgorithm = 'rsa-sha1'; /** - * Canonisation method + * Canonisation method. * * @var string */ protected $_canon = 'simple'; /** - * Headers not being signed + * Headers not being signed. * * @var array */ protected $_ignoredHeaders = array(); /** - * Signer identity + * Signer identity. * * @var string */ @@ -73,21 +73,21 @@ class Swift_Signers_DomainKeySigner implements Swift_Signers_HeaderSigner // work variables /** - * Headers used to generate hash + * Headers used to generate hash. * * @var array */ private $_signedHeaders = array(); /** - * Stores the signature header + * Stores the signature header. * * @var Swift_Mime_Headers_ParameterizedHeader */ protected $_domainKeyHeader; /** - * Hash Handler + * Hash Handler. * * @var resource|null */ @@ -110,7 +110,7 @@ class Swift_Signers_DomainKeySigner implements Swift_Signers_HeaderSigner private $_bound = array(); /** - * Constructor + * Constructor. * * @param string $privateKey * @param string $domainName @@ -125,11 +125,12 @@ public function __construct($privateKey, $domainName, $selector) } /** - * Instanciate DomainKeySigner + * Instanciate DomainKeySigner. * * @param string $privateKey * @param string $domainName * @param string $selector + * * @return Swift_Signers_DomainKeySigner */ public static function newInstance($privateKey, $domainName, $selector) @@ -138,9 +139,9 @@ public static function newInstance($privateKey, $domainName, $selector) } /** - * Resets internal states + * Resets internal states. * - * @return Swift_Signers_DomainKeysSigner + * @return Swift_Signers_DomainKeySigner */ public function reset() { @@ -165,9 +166,11 @@ public function reset() * second, etc etc). * * @param string $bytes - * @return int + * * @throws Swift_IoException - * @return Swift_Signers_DomainKeysSigner + * + * @return int + * @return Swift_Signers_DomainKeySigner */ public function write($bytes) { @@ -184,7 +187,8 @@ public function write($bytes) * off the buffer. * * @throws Swift_IoException - * @return Swift_Signers_DomainKeysSigner + * + * @return Swift_Signers_DomainKeySigner */ public function commit() { @@ -198,7 +202,8 @@ public function commit() * All {@link write()} and {@link flushBuffers()} operations will be mirrored. * * @param Swift_InputByteStream $is - * @return Swift_Signers_DomainKeysSigner + * + * @return Swift_Signers_DomainKeySigner */ public function bind(Swift_InputByteStream $is) { @@ -215,7 +220,8 @@ public function bind(Swift_InputByteStream $is) * before unbinding occurs. * * @param Swift_InputByteStream $is - * @return Swift_Signers_DomainKeysSigner + * + * @return Swift_Signers_DomainKeySigner */ public function unbind(Swift_InputByteStream $is) { @@ -236,7 +242,8 @@ public function unbind(Swift_InputByteStream $is) * to the beginning. * * @throws Swift_IoException - * @return Swift_Signers_DomainKeysSigner + * + * @return Swift_Signers_DomainKeySigner */ public function flushBuffers() { @@ -246,10 +253,11 @@ public function flushBuffers() } /** - * Set hash_algorithm, must be one of rsa-sha256 | rsa-sha1 defaults to rsa-sha256 + * Set hash_algorithm, must be one of rsa-sha256 | rsa-sha1 defaults to rsa-sha256. * * @param string $hash - * @return Swift_Signers_DomainKeysSigner + * + * @return Swift_Signers_DomainKeySigner */ public function setHashAlgorithm($hash) { @@ -259,10 +267,11 @@ public function setHashAlgorithm($hash) } /** - * Set the canonicalization algorithm + * Set the canonicalization algorithm. * * @param string $canon simple | nofws defaults to simple - * @return Swift_Signers_DomainKeysSigner + * + * @return Swift_Signers_DomainKeySigner */ public function setCanon($canon) { @@ -276,9 +285,10 @@ public function setCanon($canon) } /** - * Set the signer identity + * Set the signer identity. * * @param string $identity + * * @return Swift_Signers_DomainKeySigner */ public function setSignerIdentity($identity) @@ -289,9 +299,10 @@ public function setSignerIdentity($identity) } /** - * Enable / disable the DebugHeaders + * Enable / disable the DebugHeaders. + * + * @param bool $debug * - * @param bool $debug * @return Swift_Signers_DomainKeySigner */ public function setDebugHeaders($debug) @@ -302,16 +313,14 @@ public function setDebugHeaders($debug) } /** - * Start Body - * + * Start Body. */ public function startBody() { } /** - * End Body - * + * End Body. */ public function endBody() { @@ -319,7 +328,7 @@ public function endBody() } /** - * Returns the list of Headers Tampered by this plugin + * Returns the list of Headers Tampered by this plugin. * * @return array */ @@ -327,15 +336,16 @@ public function getAlteredHeaders() { if ($this->_debugHeaders) { return array('DomainKey-Signature', 'X-DebugHash'); - } else { - return array('DomainKey-Signature'); } + + return array('DomainKey-Signature'); } /** - * Adds an ignored Header + * Adds an ignored Header. * * @param string $header_name + * * @return Swift_Signers_DomainKeySigner */ public function ignoreHeader($header_name) @@ -346,9 +356,10 @@ public function ignoreHeader($header_name) } /** - * Set the headers to sign + * Set the headers to sign. * * @param Swift_Mime_HeaderSet $headers + * * @return Swift_Signers_DomainKeySigner */ public function setHeaders(Swift_Mime_HeaderSet $headers) @@ -359,7 +370,7 @@ public function setHeaders(Swift_Mime_HeaderSet $headers) $listHeaders = $headers->listAll(); foreach ($listHeaders as $hName) { // Check if we need to ignore Header - if (! isset($this->_ignoredHeaders[strtolower($hName)])) { + if (!isset($this->_ignoredHeaders[strtolower($hName)])) { if ($headers->has($hName)) { $tmp = $headers->getAll($hName); foreach ($tmp as $header) { @@ -377,15 +388,16 @@ public function setHeaders(Swift_Mime_HeaderSet $headers) } /** - * Add the signature to the given Headers + * Add the signature to the given Headers. * * @param Swift_Mime_HeaderSet $headers + * * @return Swift_Signers_DomainKeySigner */ public function addSignature(Swift_Mime_HeaderSet $headers) { // Prepare the DomainKey-Signature Header - $params = array('a' => $this->_hashAlgorithm, 'b' => chunk_split(base64_encode($this->_getEncryptedHash()), 73, " "), 'c' => $this->_canon, 'd' => $this->_domainName, 'h' => implode(': ', $this->_signedHeaders), 'q' => 'dns', 's' => $this->_selector); + $params = array('a' => $this->_hashAlgorithm, 'b' => chunk_split(base64_encode($this->_getEncryptedHash()), 73, ' '), 'c' => $this->_canon, 'd' => $this->_domainName, 'h' => implode(': ', $this->_signedHeaders), 'q' => 'dns', 's' => $this->_selector); $string = ''; foreach ($params as $k => $v) { $string .= $k.'='.$v.'; '; @@ -401,14 +413,14 @@ public function addSignature(Swift_Mime_HeaderSet $headers) protected function _addHeader($header) { switch ($this->_canon) { - case 'nofws' : + case 'nofws': // Prepare Header and cascade $exploded = explode(':', $header, 2); $name = strtolower(trim($exploded[0])); - $value = str_replace("\r\n", "", $exploded[1]); - $value = preg_replace("/[ \t][ \t]+/", " ", $value); - $header = $name.":".trim($value)."\r\n"; - case 'simple' : + $value = str_replace("\r\n", '', $exploded[1]); + $value = preg_replace("/[ \t][ \t]+/", ' ', $value); + $header = $name.':'.trim($value)."\r\n"; + case 'simple': // Nothing to do } $this->_addToHash($header); @@ -423,17 +435,17 @@ protected function _canonicalizeBody($string) { $len = strlen($string); $canon = ''; - $nofws = ($this->_canon == "nofws"); + $nofws = ($this->_canon == 'nofws'); for ($i = 0; $i < $len; ++$i) { if ($this->_bodyCanonIgnoreStart > 0) { --$this->_bodyCanonIgnoreStart; continue; } switch ($string[$i]) { - case "\r" : + case "\r": $this->_bodyCanonLastChar = "\r"; break; - case "\n" : + case "\n": if ($this->_bodyCanonLastChar == "\r") { if ($nofws) { $this->_bodyCanonSpace = false; @@ -449,14 +461,14 @@ protected function _canonicalizeBody($string) throw new Swift_SwiftException('Invalid new line sequence in mail found \n without preceding \r'); } break; - case " " : - case "\t" : + case ' ': + case "\t": case "\x09": //HTAB if ($nofws) { $this->_bodyCanonSpace = true; break; } - default : + default: if ($this->_bodyCanonEmptyCounter > 0) { $canon .= str_repeat("\r\n", $this->_bodyCanonEmptyCounter); $this->_bodyCanonEmptyCounter = 0; @@ -486,15 +498,16 @@ private function _startHash() { // Init switch ($this->_hashAlgorithm) { - case 'rsa-sha1' : + case 'rsa-sha1': $this->_hashHandler = hash_init('sha1'); break; } - $this->_canonLine = ''; + $this->_bodyCanonLine = ''; } /** * @throws Swift_SwiftException + * * @return string */ private function _getEncryptedHash() diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Signers/HeaderSigner.php b/swiftmailer/swiftmailer/lib/classes/Swift/Signers/HeaderSigner.php index 67c794130..c75cb08a5 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Signers/HeaderSigner.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Signers/HeaderSigner.php @@ -9,14 +9,14 @@ */ /** - * Header Signer Interface used to apply Header-Based Signature to a message + * Header Signer Interface used to apply Header-Based Signature to a message. * - * @author Xavier De Cock + * @author Xavier De Cock */ interface Swift_Signers_HeaderSigner extends Swift_Signer, Swift_InputByteStream { /** - * Exclude an header from the signed headers + * Exclude an header from the signed headers. * * @param string $header_name * @@ -25,21 +25,21 @@ interface Swift_Signers_HeaderSigner extends Swift_Signer, Swift_InputByteStream public function ignoreHeader($header_name); /** - * Prepare the Signer to get a new Body + * Prepare the Signer to get a new Body. * * @return Swift_Signers_HeaderSigner */ public function startBody(); /** - * Give the signal that the body has finished streaming + * Give the signal that the body has finished streaming. * * @return Swift_Signers_HeaderSigner */ public function endBody(); /** - * Give the headers already given + * Give the headers already given. * * @param Swift_Mime_SimpleHeaderSet $headers * @@ -48,7 +48,7 @@ public function endBody(); public function setHeaders(Swift_Mime_HeaderSet $headers); /** - * Add the header(s) to the headerSet + * Add the header(s) to the headerSet. * * @param Swift_Mime_HeaderSet $headers * @@ -57,7 +57,7 @@ public function setHeaders(Swift_Mime_HeaderSet $headers); public function addSignature(Swift_Mime_HeaderSet $headers); /** - * Return the list of header a signer might tamper + * Return the list of header a signer might tamper. * * @return array */ diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Signers/OpenDKIMSigner.php b/swiftmailer/swiftmailer/lib/classes/Swift/Signers/OpenDKIMSigner.php index b9738f423..3a35ad55d 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Signers/OpenDKIMSigner.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Signers/OpenDKIMSigner.php @@ -10,9 +10,9 @@ /** * DKIM Signer used to apply DKIM Signature to a message - * Takes advantage of pecl extension + * Takes advantage of pecl extension. * - * @author Xavier De Cock + * @author Xavier De Cock */ class Swift_Signers_OpenDKIMSigner extends Swift_Signers_DKIMSigner { @@ -29,11 +29,12 @@ class Swift_Signers_OpenDKIMSigner extends Swift_Signers_DKIMSigner public function __construct($privateKey, $domainName, $selector) { - if (extension_loaded('opendkim')) { - $this->_peclLoaded = true; - } else { + if (!extension_loaded('opendkim')) { throw new Swift_SwiftException('php-opendkim extension not found'); } + + $this->_peclLoaded = true; + parent::__construct($privateKey, $domainName, $selector); } @@ -59,11 +60,11 @@ public function setHeaders(Swift_Mime_HeaderSet $headers) { $bodyLen = $this->_bodyLen; if (is_bool($bodyLen)) { - $bodyLen = - 1; + $bodyLen = -1; } - $hash = ($this->_hashAlgorithm == 'rsa-sha1') ? OpenDKIMSign::ALG_RSASHA1 : OpenDKIMSign::ALG_RSASHA256; - $bodyCanon = ($this->_bodyCanon == 'simple') ? OpenDKIMSign::CANON_SIMPLE : OpenDKIMSign::CANON_RELAXED; - $headerCanon = ($this->_headerCanon == 'simple') ? OpenDKIMSign::CANON_SIMPLE : OpenDKIMSign::CANON_RELAXED; + $hash = $this->_hashAlgorithm == 'rsa-sha1' ? OpenDKIMSign::ALG_RSASHA1 : OpenDKIMSign::ALG_RSASHA256; + $bodyCanon = $this->_bodyCanon == 'simple' ? OpenDKIMSign::CANON_SIMPLE : OpenDKIMSign::CANON_RELAXED; + $headerCanon = $this->_headerCanon == 'simple' ? OpenDKIMSign::CANON_SIMPLE : OpenDKIMSign::CANON_RELAXED; $this->_dkimHandler = new OpenDKIMSign($this->_privateKey, $this->_selector, $this->_domainName, $headerCanon, $bodyCanon, $hash, $bodyLen); // Hardcode signature Margin for now $this->_dkimHandler->setMargin(78); @@ -81,7 +82,7 @@ public function setHeaders(Swift_Mime_HeaderSet $headers) $listHeaders = $headers->listAll(); foreach ($listHeaders as $hName) { // Check if we need to ignore Header - if (! isset($this->_ignoredHeaders[strtolower($hName)])) { + if (!isset($this->_ignoredHeaders[strtolower($hName)])) { $tmp = $headers->getAll($hName); if ($headers->has($hName)) { foreach ($tmp as $header) { @@ -100,7 +101,7 @@ public function setHeaders(Swift_Mime_HeaderSet $headers) public function startBody() { - if (! $this->_peclLoaded) { + if (!$this->_peclLoaded) { return parent::startBody(); } $this->dropFirstLF = true; @@ -111,7 +112,7 @@ public function startBody() public function endBody() { - if (! $this->_peclLoaded) { + if (!$this->_peclLoaded) { return parent::endBody(); } $this->_dkimHandler->eom(); @@ -128,9 +129,10 @@ public function reset() } /** - * Set the signature timestamp + * Set the signature timestamp. + * + * @param int $time * - * @param timestamp $time * @return Swift_Signers_DKIMSigner */ public function setSignatureTimestamp($time) @@ -141,9 +143,10 @@ public function setSignatureTimestamp($time) } /** - * Set the signature expiration timestamp + * Set the signature expiration timestamp. + * + * @param int $time * - * @param timestamp $time * @return Swift_Signers_DKIMSigner */ public function setSignatureExpiration($time) @@ -154,9 +157,10 @@ public function setSignatureExpiration($time) } /** - * Enable / disable the DebugHeaders + * Enable / disable the DebugHeaders. + * + * @param bool $debug * - * @param bool $debug * @return Swift_Signers_DKIMSigner */ public function setDebugHeaders($debug) @@ -170,7 +174,7 @@ public function setDebugHeaders($debug) protected function _canonicalizeBody($string) { - if (! $this->_peclLoaded) { + if (!$this->_peclLoaded) { return parent::_canonicalizeBody($string); } if (false && $this->dropFirstLF === true) { diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Signers/SMimeSigner.php b/swiftmailer/swiftmailer/lib/classes/Swift/Signers/SMimeSigner.php index 42e294c6d..b267099a8 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Signers/SMimeSigner.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Signers/SMimeSigner.php @@ -12,8 +12,8 @@ * MIME Message Signer used to apply S/MIME Signature/Encryption to a message. * * - * @author Romain-Geissler - * @author Sebastiaan Stok + * @author Romain-Geissler + * @author Sebastiaan Stok */ class Swift_Signers_SMimeSigner implements Swift_Signers_BodySigner { @@ -26,6 +26,7 @@ class Swift_Signers_SMimeSigner implements Swift_Signers_BodySigner protected $signOptions; protected $encryptOptions; protected $encryptCipher; + protected $extraCerts = null; /** * @var Swift_StreamFilters_StringReplacementFilterFactory @@ -40,9 +41,9 @@ class Swift_Signers_SMimeSigner implements Swift_Signers_BodySigner /** * Constructor. * - * @param string $certificate - * @param string $privateKey - * @param string $encryptCertificate + * @param string|null $signCertificate + * @param string|null $signPrivateKey + * @param string|null $encryptCertificate */ public function __construct($signCertificate = null, $signPrivateKey = null, $encryptCertificate = null) { @@ -88,10 +89,11 @@ public static function newInstance($certificate = null, $privateKey = null) * @param string $certificate * @param string|array $privateKey If the key needs an passphrase use array('file-location', 'passphrase') instead * @param int $signOptions Bitwise operator options for openssl_pkcs7_sign() + * @param string $extraCerts A file containing intermediate certificates needed by the signing certificate * * @return Swift_Signers_SMimeSigner */ - public function setSignCertificate($certificate, $privateKey = null, $signOptions = PKCS7_DETACHED) + public function setSignCertificate($certificate, $privateKey = null, $signOptions = PKCS7_DETACHED, $extraCerts = null) { $this->signCertificate = 'file://'.str_replace('\\', '/', realpath($certificate)); @@ -105,6 +107,9 @@ public function setSignCertificate($certificate, $privateKey = null, $signOption } $this->signOptions = $signOptions; + if (null !== $extraCerts) { + $this->extraCerts = str_replace('\\', '/', realpath($extraCerts)); + } return $this; } @@ -162,7 +167,7 @@ public function getSignPrivateKey() * But some older mail clients, namely Microsoft Outlook 2000 will work when the message first encrypted. * As this goes against the official specs, its recommended to only use 'encryption -> signing' when specifically targeting these 'broken' clients. * - * @param string $signThenEncrypt + * @param bool $signThenEncrypt * * @return Swift_Signers_SMimeSigner */ @@ -229,7 +234,7 @@ public function getAlteredHeaders() /** * @param Swift_InputByteStream $inputStream - * @param Swift_Message $mimeEntity + * @param Swift_Message $mimeEntity */ protected function toSMimeByteStream(Swift_InputByteStream $inputStream, Swift_Message $message) { @@ -287,7 +292,12 @@ protected function messageStreamToSignedByteStream(Swift_FileStream $outputStrea { $signedMessageStream = new Swift_ByteStream_TemporaryFileByteStream(); - if (!openssl_pkcs7_sign($outputStream->getPath(), $signedMessageStream->getPath(), $this->signCertificate, $this->signPrivateKey, array(), $this->signOptions)) { + $args = array($outputStream->getPath(), $signedMessageStream->getPath(), $this->signCertificate, $this->signPrivateKey, array(), $this->signOptions); + if (null !== $this->extraCerts) { + $args[] = $this->extraCerts; + } + + if (!call_user_func_array('openssl_pkcs7_sign', $args)) { throw new Swift_IoException(sprintf('Failed to sign S/Mime message. Error: "%s".', openssl_error_string())); } @@ -390,7 +400,6 @@ protected function streamToMime(Swift_OutputByteStream $fromStream, Swift_Messag } $boundary = trim($contentTypeData['1'], '"'); - $boundaryLen = strlen($boundary); // Skip the header and CRLF CRLF $fromStream->setReadPointer($headersPosEnd + 4); diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/SmtpTransport.php b/swiftmailer/swiftmailer/lib/classes/Swift/SmtpTransport.php index 5d4945e17..625161140 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/SmtpTransport.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/SmtpTransport.php @@ -11,7 +11,8 @@ /** * Sends Messages over SMTP with ESMTP support. * - * @author Chris Corbyn + * @author Chris Corbyn + * * @method Swift_SmtpTransport setUsername(string $username) Set the username to authenticate with. * @method string getUsername() Get the username to authenticate with. * @method Swift_SmtpTransport setPassword(string $password) Set the password to authenticate with. @@ -24,9 +25,9 @@ class Swift_SmtpTransport extends Swift_Transport_EsmtpTransport /** * Create a new SmtpTransport, optionally with $host, $port and $security. * - * @param string $host - * @param int $port - * @param string $security + * @param string $host + * @param int $port + * @param string $security */ public function __construct($host = 'localhost', $port = 25, $security = null) { @@ -44,9 +45,9 @@ public function __construct($host = 'localhost', $port = 25, $security = null) /** * Create a new SmtpTransport instance. * - * @param string $host - * @param int $port - * @param string $security + * @param string $host + * @param int $port + * @param string $security * * @return Swift_SmtpTransport */ diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Spool.php b/swiftmailer/swiftmailer/lib/classes/Swift/Spool.php index afae5fac3..c16ab4b38 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Spool.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Spool.php @@ -11,7 +11,7 @@ /** * Interface for spools. * - * @author Fabien Potencier + * @author Fabien Potencier */ interface Swift_Spool { @@ -37,7 +37,7 @@ public function isStarted(); * * @param Swift_Mime_Message $message The message to store * - * @return bool Whether the operation has succeeded + * @return bool Whether the operation has succeeded */ public function queueMessage(Swift_Mime_Message $message); @@ -47,7 +47,7 @@ public function queueMessage(Swift_Mime_Message $message); * @param Swift_Transport $transport A transport instance * @param string[] $failedRecipients An array of failures by-reference * - * @return int The number of sent emails + * @return int The number of sent emails */ public function flushQueue(Swift_Transport $transport, &$failedRecipients = null); } diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/SpoolTransport.php b/swiftmailer/swiftmailer/lib/classes/Swift/SpoolTransport.php index 9351c40d3..cf9bf78fb 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/SpoolTransport.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/SpoolTransport.php @@ -11,7 +11,7 @@ /** * Stores Messages in a queue. * - * @author Fabien Potencier + * @author Fabien Potencier */ class Swift_SpoolTransport extends Swift_Transport_SpoolTransport { diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/StreamFilter.php b/swiftmailer/swiftmailer/lib/classes/Swift/StreamFilter.php index 1c3fd3a57..362be2e8d 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/StreamFilter.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/StreamFilter.php @@ -11,7 +11,7 @@ /** * Processes bytes as they pass through a stream and performs filtering. * - * @author Chris Corbyn + * @author Chris Corbyn */ interface Swift_StreamFilter { diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/StreamFilters/ByteArrayReplacementFilter.php b/swiftmailer/swiftmailer/lib/classes/Swift/StreamFilters/ByteArrayReplacementFilter.php index 886869929..0418750f1 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/StreamFilters/ByteArrayReplacementFilter.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/StreamFilters/ByteArrayReplacementFilter.php @@ -13,7 +13,7 @@ * * This stream filter deals with Byte arrays rather than simple strings. * - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_StreamFilters_ByteArrayReplacementFilter implements Swift_StreamFilter { @@ -53,11 +53,11 @@ public function __construct($search, $replace) $last_size = $size = 0; foreach ($search as $i => $search_element) { if ($tree !== null) { - $tree[-1] = min (count($replace) - 1, $i - 1); + $tree[-1] = min(count($replace) - 1, $i - 1); $tree[-2] = $last_size; } $tree = &$this->_tree; - if (is_array ($search_element)) { + if (is_array($search_element)) { foreach ($search_element as $k => $char) { $this->_index[$char] = true; if (!isset($tree[$char])) { @@ -65,7 +65,7 @@ public function __construct($search, $replace) } $tree = &$tree[$char]; } - $last_size = $k+1; + $last_size = $k + 1; $size = max($size, $last_size); } else { $last_size = 1; @@ -78,13 +78,13 @@ public function __construct($search, $replace) } } if ($i !== null) { - $tree[-1] = min (count ($replace) - 1, $i); + $tree[-1] = min(count($replace) - 1, $i); $tree[-2] = $last_size; $this->_treeMaxLen = $size; } foreach ($replace as $rep) { if (!is_array($rep)) { - $rep = array ($rep); + $rep = array($rep); } $this->_replace[] = $rep; } @@ -105,14 +105,14 @@ public function shouldBuffer($buffer) { $endOfBuffer = end($buffer); - return isset ($this->_index[$endOfBuffer]); + return isset($this->_index[$endOfBuffer]); } /** * Perform the actual replacements on $buffer and return the result. * - * @param array $buffer - * @param int $_minReplaces + * @param array $buffer + * @param int $_minReplaces * * @return array */ @@ -124,16 +124,17 @@ public function filter($buffer, $_minReplaces = -1) $newBuffer = array(); $buf_size = count($buffer); + $last_size = 0; for ($i = 0; $i < $buf_size; ++$i) { $search_pos = $this->_tree; $last_found = PHP_INT_MAX; // We try to find if the next byte is part of a search pattern for ($j = 0; $j <= $this->_treeMaxLen; ++$j) { // We have a new byte for a search pattern - if (isset ($buffer [$p = $i + $j]) && isset($search_pos[$buffer[$p]])) { + if (isset($buffer [$p = $i + $j]) && isset($search_pos[$buffer[$p]])) { $search_pos = $search_pos[$buffer[$p]]; // We have a complete pattern, save, in case we don't find a better match later - if (isset($search_pos[- 1]) && $search_pos[-1] < $last_found + if (isset($search_pos[-1]) && $search_pos[-1] < $last_found && $search_pos[-1] > $_minReplaces) { $last_found = $search_pos[-1]; $last_size = $search_pos[-2]; diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/StreamFilters/StringReplacementFilter.php b/swiftmailer/swiftmailer/lib/classes/Swift/StreamFilters/StringReplacementFilter.php index e6b9e7b8a..d0db8b961 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/StreamFilters/StringReplacementFilter.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/StreamFilters/StringReplacementFilter.php @@ -11,7 +11,7 @@ /** * Processes bytes as they pass through a buffer and replaces sequences in it. * - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_StreamFilters_StringReplacementFilter implements Swift_StreamFilter { diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/StreamFilters/StringReplacementFilterFactory.php b/swiftmailer/swiftmailer/lib/classes/Swift/StreamFilters/StringReplacementFilterFactory.php index 4b12cfffd..e98240b5b 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/StreamFilters/StringReplacementFilterFactory.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/StreamFilters/StringReplacementFilterFactory.php @@ -11,7 +11,7 @@ /** * Creates filters for replacing needles in a string buffer. * - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_StreamFilters_StringReplacementFilterFactory implements Swift_ReplacementFilterFactory { diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/SwiftException.php b/swiftmailer/swiftmailer/lib/classes/Swift/SwiftException.php index 22ee3eb40..db3d31093 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/SwiftException.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/SwiftException.php @@ -11,17 +11,19 @@ /** * Base Exception class. * - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_SwiftException extends Exception { /** * Create a new SwiftException with $message. * - * @param string $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); } } diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Transport.php b/swiftmailer/swiftmailer/lib/classes/Swift/Transport.php index ac97b409f..6535eadf2 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Transport.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Transport.php @@ -11,7 +11,7 @@ /** * Sends Messages via an abstract Transport subsystem. * - * @author Chris Corbyn + * @author Chris Corbyn */ interface Swift_Transport { diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php b/swiftmailer/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php index 137f7eb64..f4d9967a5 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php @@ -11,7 +11,7 @@ /** * Sends Messages over SMTP. * - * @author Chris Corbyn + * @author Chris Corbyn */ abstract class Swift_Transport_AbstractSmtpTransport implements Swift_Transport { @@ -87,7 +87,7 @@ public function setSourceIp($source) } /** - * Returns the IP used to connect to the destination + * Returns the IP used to connect to the destination. * * @return string */ @@ -301,7 +301,7 @@ protected function _doHeloCommand() protected function _doMailFromCommand($address) { $this->executeCommand( - sprintf("MAIL FROM: <%s>\r\n", $address), array(250) + sprintf("MAIL FROM:<%s>\r\n", $address), array(250) ); } @@ -309,7 +309,7 @@ protected function _doMailFromCommand($address) protected function _doRcptToCommand($address) { $this->executeCommand( - sprintf("RCPT TO: <%s>\r\n", $address), array(250, 251, 252) + sprintf("RCPT TO:<%s>\r\n", $address), array(250, 251, 252) ); } @@ -417,7 +417,7 @@ private function _doMailTransaction($message, $reversePath, array $recipients, a foreach ($recipients as $forwardPath) { try { $this->_doRcptToCommand($forwardPath); - $sent++; + ++$sent; } catch (Swift_TransportException $e) { $failedRecipients[] = $forwardPath; } @@ -461,11 +461,17 @@ private function _sendBcc(Swift_Mime_Message $message, $reversePath, array $bcc, /** Try to determine the hostname of the server this is run on */ private function _lookupHostname() { - if (!empty($_SERVER['SERVER_NAME']) - && $this->_isFqdn($_SERVER['SERVER_NAME'])) { + if (!empty($_SERVER['SERVER_NAME']) && $this->_isFqdn($_SERVER['SERVER_NAME'])) { $this->_domain = $_SERVER['SERVER_NAME']; } elseif (!empty($_SERVER['SERVER_ADDR'])) { - $this->_domain = sprintf('[%s]', $_SERVER['SERVER_ADDR']); + // Set the address literal tag (See RFC 5321, section: 4.1.3) + if (false === strpos($_SERVER['SERVER_ADDR'], ':')) { + $prefix = ''; // IPv4 addresses are not tagged. + } else { + $prefix = 'IPv6:'; // Adding prefix in case of IPv6. + } + + $this->_domain = sprintf('[%s%s]', $prefix, $_SERVER['SERVER_ADDR']); } } @@ -475,9 +481,9 @@ private function _isFqdn($hostname) // We could do a really thorough check, but there's really no point if (false !== $dotPos = strpos($hostname, '.')) { return ($dotPos > 0) && ($dotPos != strlen($hostname) - 1); - } else { - return false; } + + return false; } /** diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/CramMd5Authenticator.php b/swiftmailer/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/CramMd5Authenticator.php index 4774e0324..53f721d03 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/CramMd5Authenticator.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/CramMd5Authenticator.php @@ -11,7 +11,7 @@ /** * Handles CRAM-MD5 authentication. * - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_Transport_Esmtp_Auth_CramMd5Authenticator implements Swift_Transport_Esmtp_Authenticator { @@ -73,7 +73,7 @@ private function _getResponse($secret, $challenge) $k_ipad = substr($secret, 0, 64) ^ str_repeat(chr(0x36), 64); $k_opad = substr($secret, 0, 64) ^ str_repeat(chr(0x5C), 64); - $inner = pack('H32', md5($k_ipad.$challenge)); + $inner = pack('H32', md5($k_ipad.$challenge)); $digest = md5($k_opad.$inner); return $digest; diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/LoginAuthenticator.php b/swiftmailer/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/LoginAuthenticator.php index ebb35520b..6ab6e3337 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/LoginAuthenticator.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/LoginAuthenticator.php @@ -11,7 +11,7 @@ /** * Handles LOGIN authentication. * - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_Transport_Esmtp_Auth_LoginAuthenticator implements Swift_Transport_Esmtp_Authenticator { diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/NTLMAuthenticator.php b/swiftmailer/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/NTLMAuthenticator.php index 2c02bd2c1..eb04acf0c 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/NTLMAuthenticator.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/NTLMAuthenticator.php @@ -13,12 +13,12 @@ /** * Handles NTLM authentication. * - * @author Ward Peeters + * @author Ward Peeters */ class Swift_Transport_Esmtp_Auth_NTLMAuthenticator implements Swift_Transport_Esmtp_Authenticator { const NTLMSIG = "NTLMSSP\x00"; - const DESCONST = "KGS!@#$%"; + const DESCONST = 'KGS!@#$%'; /** * Get the name of the AUTH mechanism this Authenticator handles. @@ -34,23 +34,19 @@ public function getAuthKeyword() * Try to authenticate the user with $username and $password. * * @param Swift_Transport_SmtpAgent $agent - * @param string $username - * @param string $password + * @param string $username + * @param string $password * * @return bool */ public function authenticate(Swift_Transport_SmtpAgent $agent, $username, $password) { - if (!function_exists('mcrypt_module_open')) { - throw new LogicException('The mcrypt functions need to be enabled to use the NTLM authenticator.'); - } - - if (!function_exists('openssl_random_pseudo_bytes')) { + if (!function_exists('openssl_random_pseudo_bytes') || !function_exists('openssl_encrypt')) { throw new LogicException('The OpenSSL extension must be enabled to use the NTLM authenticator.'); } if (!function_exists('bcmul')) { - throw new LogicException('The BCMatch functions must be enabled to use the NTLM authenticator.'); + throw new LogicException('The BCMath functions must be enabled to use the NTLM authenticator.'); } try { @@ -59,7 +55,7 @@ public function authenticate(Swift_Transport_SmtpAgent $agent, $username, $passw $response = base64_decode(substr(trim($this->sendMessage1($agent)), 4)); // extra parameters for our unit cases - $timestamp = func_num_args() > 3 ? func_get_arg(3) : $this->getCorrectTimestamp(bcmul(microtime(true), "1000")); + $timestamp = func_num_args() > 3 ? func_get_arg(3) : $this->getCorrectTimestamp(bcmul(microtime(true), '1000')); $client = func_num_args() > 4 ? func_get_arg(4) : $this->getRandomBytes(8); // Message 3 response @@ -83,7 +79,7 @@ protected function si2bin($si, $bits = 32) // pad to $bits bit $bin_length = strlen($bin); if ($bin_length < $bits) { - $bin = str_repeat("0", $bits - $bin_length).$bin; + $bin = str_repeat('0', $bits - $bin_length).$bin; } } else { // negative @@ -91,7 +87,7 @@ protected function si2bin($si, $bits = 32) $bin = base_convert($si, 10, 2); $bin_length = strlen($bin); if ($bin_length > $bits) { - $bin = str_repeat("1", $bits - $bin_length).$bin; + $bin = str_repeat('1', $bits - $bin_length).$bin; } } } @@ -100,9 +96,10 @@ protected function si2bin($si, $bits = 32) } /** - * Send our auth message and returns the response + * Send our auth message and returns the response. * * @param Swift_Transport_SmtpAgent $agent + * * @return string SMTP Response */ protected function sendMessage1(Swift_Transport_SmtpAgent $agent) @@ -113,9 +110,10 @@ protected function sendMessage1(Swift_Transport_SmtpAgent $agent) } /** - * Fetch all details of our response (message 2) + * Fetch all details of our response (message 2). * * @param string $response + * * @return array our response parsed */ protected function parseMessage2($response) @@ -146,9 +144,10 @@ protected function parseMessage2($response) } /** - * Read the blob information in from message2 + * Read the blob information in from message2. * * @param $block + * * @return array */ protected function readSubBlock($block) @@ -177,15 +176,16 @@ protected function readSubBlock($block) } /** - * Send our final message with all our data + * Send our final message with all our data. * - * @param string $response Message 1 response (message 2) - * @param string $username - * @param string $password - * @param string $timestamp - * @param string $client + * @param string $response Message 1 response (message 2) + * @param string $username + * @param string $password + * @param string $timestamp + * @param string $client * @param Swift_Transport_SmtpAgent $agent - * @param bool $v2 Use version2 of the protocol + * @param bool $v2 Use version2 of the protocol + * * @return string */ protected function sendMessage3($response, $username, $password, $timestamp, $client, Swift_Transport_SmtpAgent $agent, $v2 = true) @@ -212,7 +212,7 @@ protected function sendMessage3($response, $username, $password, $timestamp, $cl } /** - * Create our message 1 + * Create our message 1. * * @return string */ @@ -224,13 +224,14 @@ protected function createMessage1() } /** - * Create our message 3 + * Create our message 3. * * @param string $domain * @param string $username * @param string $workstation * @param string $lmResponse * @param string $ntlmResponse + * * @return string */ protected function createMessage3($domain, $username, $workstation, $lmResponse, $ntlmResponse) @@ -253,7 +254,7 @@ protected function createMessage3($domain, $username, $workstation, $lmResponse, .$domainSec // Domain header .$userSec // User header .$workSec // Workstation header -.$this->createByte("000000009a", 8) // session key header (empty) +.$this->createByte('000000009a', 8) // session key header (empty) .$this->createByte('01020000') // FLAGS .$this->convertTo16bit($domain) // domain name .$this->convertTo16bit($username) // username @@ -263,9 +264,10 @@ protected function createMessage3($domain, $username, $workstation, $lmResponse, } /** - * @param string $timestamp Epoch timestamp in microseconds - * @param string $client Random bytes + * @param string $timestamp Epoch timestamp in microseconds + * @param string $client Random bytes * @param string $targetInfo + * * @return string */ protected function createBlob($timestamp, $client, $targetInfo) @@ -280,11 +282,12 @@ protected function createBlob($timestamp, $client, $targetInfo) } /** - * Get domain and username from our username + * Get domain and username from our username. * * @example DOMAIN\username * * @param string $name + * * @return array */ protected function getDomainAndUsername($name) @@ -299,10 +302,11 @@ protected function getDomainAndUsername($name) } /** - * Create LMv1 response + * Create LMv1 response. * * @param string $password * @param string $challenge + * * @return string */ protected function createLMPassword($password, $challenge) @@ -327,10 +331,11 @@ protected function createLMPassword($password, $challenge) } /** - * Create NTLMv1 response + * Create NTLMv1 response. * * @param string $password * @param string $challenge + * * @return string */ protected function createNTLMPassword($password, $challenge) @@ -347,9 +352,10 @@ protected function createNTLMPassword($password, $challenge) } /** - * Convert a normal timestamp to a tenth of a microtime epoch time + * Convert a normal timestamp to a tenth of a microtime epoch time. * * @param string $time + * * @return string */ protected function getCorrectTimestamp($time) @@ -358,12 +364,12 @@ protected function getCorrectTimestamp($time) bcscale(0); $time = number_format($time, 0, '.', ''); // save microtime to string - $time = bcadd($time, "11644473600000"); // add epoch time + $time = bcadd($time, '11644473600000'); // add epoch time $time = bcmul($time, 10000); // tenths of a microsecond. $binary = $this->si2bin($time, 64); // create 64 bit binary string - $timestamp = ""; - for ($i = 0; $i < 8; $i++) { + $timestamp = ''; + for ($i = 0; $i < 8; ++$i) { $timestamp .= chr(bindec(substr($binary, -(($i + 1) * 8), 8))); } @@ -371,13 +377,14 @@ protected function getCorrectTimestamp($time) } /** - * Create LMv2 response + * Create LMv2 response. * * @param string $password * @param string $username * @param string $domain * @param string $challenge NTLM Challenge - * @param string $client Random string + * @param string $client Random string + * * @return string */ protected function createLMv2Password($password, $username, $domain, $challenge, $client) @@ -395,16 +402,18 @@ protected function createLMv2Password($password, $username, $domain, $challenge, } /** - * Create NTLMv2 response + * Create NTLMv2 response. * * @param string $password * @param string $username * @param string $domain - * @param string $challenge Hex values + * @param string $challenge Hex values * @param string $targetInfo Hex values * @param string $timestamp - * @param string $client Random bytes + * @param string $client Random bytes + * * @return string + * * @see http://davenport.sourceforge.net/ntlm.html#theNtlmResponse */ protected function createNTLMv2Hash($password, $username, $domain, $challenge, $targetInfo, $timestamp, $client) @@ -424,7 +433,7 @@ protected function createDesKey($key) { $material = array(bin2hex($key[0])); $len = strlen($key); - for ($i = 1; $i < $len; $i++) { + for ($i = 1; $i < $len; ++$i) { list($high, $low) = str_split(bin2hex($key[$i])); $v = $this->castToByte(ord($key[$i - 1]) << (7 + 1 - $i) | $this->uRShift(hexdec(dechex(hexdec($high) & 0xf).dechex(hexdec($low) & 0xf)), $i)); $material[] = str_pad(substr(dechex($v), -2), 2, '0', STR_PAD_LEFT); // cast to byte @@ -451,11 +460,12 @@ protected function createDesKey($key) /** HELPER FUNCTIONS */ /** - * Create our security buffer depending on length and offset + * Create our security buffer depending on length and offset. + * + * @param string $value Value we want to put in + * @param int $offset start of value + * @param bool $is16 Do we 16bit string or not? * - * @param string $value Value we want to put in - * @param int $offset start of value - * @param bool $is16 Do we 16bit string or not? * @return string */ protected function createSecurityBuffer($value, $offset, $is16 = false) @@ -468,9 +478,10 @@ protected function createSecurityBuffer($value, $offset, $is16 = false) } /** - * Read our security buffer to fetch length and offset of our value + * Read our security buffer to fetch length and offset of our value. * * @param string $value Securitybuffer in hex + * * @return array array with length and offset */ protected function readSecurityBuffer($value) @@ -482,9 +493,10 @@ protected function readSecurityBuffer($value) } /** - * Cast to byte java equivalent to (byte) + * Cast to byte java equivalent to (byte). * * @param int $v + * * @return int */ protected function castToByte($v) @@ -494,10 +506,11 @@ protected function castToByte($v) /** * Java unsigned right bitwise - * $a >>> $b + * $a >>> $b. * * @param int $a * @param int $b + * * @return int */ protected function uRShift($a, $b) @@ -510,11 +523,12 @@ protected function uRShift($a, $b) } /** - * Right padding with 0 to certain length + * Right padding with 0 to certain length. * * @param string $input - * @param int $bytes Length of bytes - * @param bool $isHex Did we provided hex value + * @param int $bytes Length of bytes + * @param bool $isHex Did we provided hex value + * * @return string */ protected function createByte($input, $bytes = 4, $isHex = true) @@ -529,9 +543,10 @@ protected function createByte($input, $bytes = 4, $isHex = true) } /** - * Create random bytes + * Create random bytes. * * @param $length + * * @return string */ protected function getRandomBytes($length) @@ -547,25 +562,25 @@ protected function getRandomBytes($length) /** ENCRYPTION ALGORITHMS */ /** - * DES Encryption + * DES Encryption. * - * @param string $value + * @param string $value An 8-byte string * @param string $key + * * @return string */ protected function desEncrypt($value, $key) { - $cipher = mcrypt_module_open(MCRYPT_DES, '', 'ecb', ''); - mcrypt_generic_init($cipher, $key, mcrypt_create_iv(mcrypt_enc_get_iv_size($cipher), MCRYPT_DEV_RANDOM)); - - return mcrypt_generic($cipher, $value); + // 1 == OPENSSL_RAW_DATA - but constant is only available as of PHP 5.4. + return substr(openssl_encrypt($value, 'DES-ECB', $key, 1), 0, 8); } /** - * MD5 Encryption + * MD5 Encryption. * * @param string $key Encryption key * @param string $msg Message to encrypt + * * @return string */ protected function md5Encrypt($key, $msg) @@ -583,10 +598,12 @@ protected function md5Encrypt($key, $msg) } /** - * MD4 Encryption + * MD4 Encryption. * * @param string $input + * * @return string + * * @see http://php.net/manual/en/ref.hash.php */ protected function md4Encrypt($input) @@ -597,9 +614,10 @@ protected function md4Encrypt($input) } /** - * Convert UTF-8 to UTF-16 + * Convert UTF-8 to UTF-16. * * @param string $input + * * @return string */ protected function convertTo16bit($input) @@ -608,8 +626,10 @@ protected function convertTo16bit($input) } /** - * Hex2bin replacement for < PHP 5.4 + * Hex2bin replacement for < PHP 5.4. + * * @param string $hex + * * @return string Binary */ protected function hex2bin($hex) @@ -631,7 +651,7 @@ protected function debug($message) echo substr($message, 0, 16)." NTLMSSP Signature
\n"; echo $messageId." Type Indicator
\n"; - if ($messageId == "02000000") { + if ($messageId == '02000000') { $map = array( 'Challenge', 'Context', @@ -650,7 +670,7 @@ protected function debug($message) foreach ($map as $key => $value) { echo bin2hex($data[$key]).' - '.$data[$key].' ||| '.$value."
\n"; } - } elseif ($messageId == "03000000") { + } elseif ($messageId == '03000000') { $i = 0; $data[$i++] = substr($message, 24, 16); list($lmLength, $lmOffset) = $this->readSecurityBuffer($data[$i - 1]); @@ -695,6 +715,6 @@ protected function debug($message) } } - echo "

"; + echo '

'; } } diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/PlainAuthenticator.php b/swiftmailer/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/PlainAuthenticator.php index 98f6d1816..43219f934 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/PlainAuthenticator.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/PlainAuthenticator.php @@ -11,7 +11,7 @@ /** * Handles PLAIN authentication. * - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_Transport_Esmtp_Auth_PlainAuthenticator implements Swift_Transport_Esmtp_Authenticator { diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/XOAuth2Authenticator.php b/swiftmailer/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/XOAuth2Authenticator.php index 80c00b987..ca35e7b83 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/XOAuth2Authenticator.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/XOAuth2Authenticator.php @@ -19,7 +19,8 @@ * ->setPassword('YOUR_ACCESS_TOKEN'); * * - * @author xu.li + * @author xu.li + * * @see https://developers.google.com/google-apps/gmail/xoauth2_protocol */ class Swift_Transport_Esmtp_Auth_XOAuth2Authenticator implements Swift_Transport_Esmtp_Authenticator @@ -47,7 +48,7 @@ public function authenticate(Swift_Transport_SmtpAgent $agent, $email, $token) { try { $param = $this->constructXOAuth2Params($email, $token); - $agent->executeCommand("AUTH XOAUTH2 ".$param."\r\n", array(235)); + $agent->executeCommand('AUTH XOAUTH2 '.$param."\r\n", array(235)); return true; } catch (Swift_TransportException $e) { @@ -58,7 +59,7 @@ public function authenticate(Swift_Transport_SmtpAgent $agent, $email, $token) } /** - * Construct the auth parameter + * Construct the auth parameter. * * @see https://developers.google.com/google-apps/gmail/xoauth2_protocol#the_sasl_xoauth2_mechanism */ diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Transport/Esmtp/AuthHandler.php b/swiftmailer/swiftmailer/lib/classes/Swift/Transport/Esmtp/AuthHandler.php index 6b83194c9..cb36133c9 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Transport/Esmtp/AuthHandler.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Transport/Esmtp/AuthHandler.php @@ -11,7 +11,7 @@ /** * An ESMTP handler for AUTH support. * - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_Transport_Esmtp_AuthHandler implements Swift_Transport_EsmtpHandler { @@ -172,7 +172,7 @@ public function afterEhlo(Swift_Transport_SmtpAgent $agent) foreach ($this->_getAuthenticatorsForAgent() as $authenticator) { if (in_array(strtolower($authenticator->getAuthKeyword()), array_map('strtolower', $this->_esmtpParams))) { - $count++; + ++$count; if ($authenticator->authenticate($agent, $this->_username, $this->_password)) { return; } diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Transport/Esmtp/Authenticator.php b/swiftmailer/swiftmailer/lib/classes/Swift/Transport/Esmtp/Authenticator.php index 9078003a9..12a9abf81 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Transport/Esmtp/Authenticator.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Transport/Esmtp/Authenticator.php @@ -11,7 +11,7 @@ /** * An Authentication mechanism. * - * @author Chris Corbyn + * @author Chris Corbyn */ interface Swift_Transport_Esmtp_Authenticator { diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Transport/EsmtpHandler.php b/swiftmailer/swiftmailer/lib/classes/Swift/Transport/EsmtpHandler.php index cb76eddf8..c17ef8feb 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Transport/EsmtpHandler.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Transport/EsmtpHandler.php @@ -11,7 +11,7 @@ /** * An ESMTP handler. * - * @author Chris Corbyn + * @author Chris Corbyn */ interface Swift_Transport_EsmtpHandler { diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Transport/EsmtpTransport.php b/swiftmailer/swiftmailer/lib/classes/Swift/Transport/EsmtpTransport.php index e860a8ef3..4106df417 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Transport/EsmtpTransport.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Transport/EsmtpTransport.php @@ -11,7 +11,7 @@ /** * Sends Messages over SMTP with ESMTP support. * - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_Transport_EsmtpTransport extends Swift_Transport_AbstractSmtpTransport implements Swift_Transport_SmtpAgent { @@ -42,6 +42,7 @@ class Swift_Transport_EsmtpTransport extends Swift_Transport_AbstractSmtpTranspo 'blocking' => 1, 'tls' => false, 'type' => Swift_Transport_IoBuffer::TYPE_SOCKET, + 'stream_context_options' => array(), ); /** @@ -84,7 +85,7 @@ public function getHost() /** * Set the port to connect to. * - * @param int $port + * @param int $port * * @return Swift_Transport_EsmtpTransport */ @@ -108,7 +109,7 @@ public function getPort() /** * Set the connection timeout. * - * @param int $timeout seconds + * @param int $timeout seconds * * @return Swift_Transport_EsmtpTransport */ @@ -131,7 +132,7 @@ public function getTimeout() } /** - * Set the encryption type (tls or ssl) + * Set the encryption type (tls or ssl). * * @param string $encryption * @@ -139,6 +140,7 @@ public function getTimeout() */ public function setEncryption($encryption) { + $encryption = strtolower($encryption); if ('tls' == $encryption) { $this->_params['protocol'] = 'tcp'; $this->_params['tls'] = true; @@ -160,6 +162,30 @@ public function getEncryption() return $this->_params['tls'] ? 'tls' : $this->_params['protocol']; } + /** + * Sets the stream context options. + * + * @param array $options + * + * @return Swift_Transport_EsmtpTransport + */ + public function setStreamOptions($options) + { + $this->_params['stream_context_options'] = $options; + + return $this; + } + + /** + * Returns the stream context options. + * + * @return array + */ + public function getStreamOptions() + { + return $this->_params['stream_context_options']; + } + /** * Sets the source IP. * @@ -181,7 +207,7 @@ public function setSourceIp($source) */ public function getSourceIp() { - return $this->_params['sourceIp']; + return isset($this->_params['sourceIp']) ? $this->_params['sourceIp'] : null; } /** @@ -197,7 +223,8 @@ public function setExtensionHandlers(array $handlers) foreach ($handlers as $handler) { $assoc[$handler->getHandledKeyword()] = $handler; } - uasort($assoc, array($this, '_sortHandlers')); + + @uasort($assoc, array($this, '_sortHandlers')); $this->_handlers = $assoc; $this->_setHandlerParams(); @@ -318,7 +345,7 @@ protected function _doMailFromCommand($address) } $paramStr = !empty($params) ? ' '.implode(' ', $params) : ''; $this->executeCommand( - sprintf("MAIL FROM: <%s>%s\r\n", $address, $paramStr), array(250) + sprintf("MAIL FROM:<%s>%s\r\n", $address, $paramStr), array(250) ); } @@ -332,7 +359,7 @@ protected function _doRcptToCommand($address) } $paramStr = !empty($params) ? ' '.implode(' ', $params) : ''; $this->executeCommand( - sprintf("RCPT TO: <%s>%s\r\n", $address, $paramStr), array(250, 251, 252) + sprintf("RCPT TO:<%s>%s\r\n", $address, $paramStr), array(250, 251, 252) ); } diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Transport/FailoverTransport.php b/swiftmailer/swiftmailer/lib/classes/Swift/Transport/FailoverTransport.php index eafde009b..311a0f2ad 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Transport/FailoverTransport.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Transport/FailoverTransport.php @@ -11,7 +11,7 @@ /** * Contains a list of redundant Transports so when one fails, the next is used. * - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_Transport_FailoverTransport extends Swift_Transport_LoadBalancedTransport { @@ -22,9 +22,7 @@ class Swift_Transport_FailoverTransport extends Swift_Transport_LoadBalancedTran */ private $_currentTransport; - /** - * Creates a new FailoverTransport. - */ + // needed as __construct is called from elsewhere explicitly public function __construct() { parent::__construct(); @@ -45,6 +43,7 @@ public function send(Swift_Mime_Message $message, &$failedRecipients = null) { $maxTransports = count($this->_transports); $sent = 0; + $this->_lastUsedTransport = null; for ($i = 0; $i < $maxTransports && $transport = $this->_getNextTransport(); ++$i) { @@ -53,7 +52,11 @@ public function send(Swift_Mime_Message $message, &$failedRecipients = null) $transport->start(); } - return $transport->send($message, $failedRecipients); + if ($sent = $transport->send($message, $failedRecipients)) { + $this->_lastUsedTransport = $transport; + + return $sent; + } } catch (Swift_TransportException $e) { $this->_killCurrentTransport(); } diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Transport/IoBuffer.php b/swiftmailer/swiftmailer/lib/classes/Swift/Transport/IoBuffer.php index 71b3f1e5d..af97adf1f 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Transport/IoBuffer.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Transport/IoBuffer.php @@ -11,7 +11,7 @@ /** * Buffers input and output to a resource. * - * @author Chris Corbyn + * @author Chris Corbyn */ interface Swift_Transport_IoBuffer extends Swift_InputByteStream, Swift_OutputByteStream { @@ -59,7 +59,7 @@ public function setWriteTranslations(array $replacements); * The $sequence number comes from any writes and may or may not be used * depending upon the implementation. * - * @param int $sequence of last write to scan from + * @param int $sequence of last write to scan from * * @return string */ diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Transport/LoadBalancedTransport.php b/swiftmailer/swiftmailer/lib/classes/Swift/Transport/LoadBalancedTransport.php index 440e8d4b3..e2adc567e 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Transport/LoadBalancedTransport.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Transport/LoadBalancedTransport.php @@ -11,7 +11,7 @@ /** * Redundantly and rotationally uses several Transports when sending. * - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_Transport_LoadBalancedTransport implements Swift_Transport { @@ -30,8 +30,13 @@ class Swift_Transport_LoadBalancedTransport implements Swift_Transport protected $_transports = array(); /** - * Creates a new LoadBalancedTransport. + * The Transport used in the last successful send operation. + * + * @var Swift_Transport */ + protected $_lastUsedTransport = null; + + // needed as __construct is called from elsewhere explicitly public function __construct() { } @@ -57,6 +62,16 @@ public function getTransports() return array_merge($this->_transports, $this->_deadTransports); } + /** + * Get the Transport used in the last successful send operation. + * + * @return Swift_Transport + */ + public function getLastUsedTransport() + { + return $this->_lastUsedTransport; + } + /** * Test if this Transport mechanism has started. * @@ -100,6 +115,7 @@ public function send(Swift_Mime_Message $message, &$failedRecipients = null) { $maxTransports = count($this->_transports); $sent = 0; + $this->_lastUsedTransport = null; for ($i = 0; $i < $maxTransports && $transport = $this->_getNextTransport(); ++$i) { @@ -108,6 +124,7 @@ public function send(Swift_Mime_Message $message, &$failedRecipients = null) $transport->start(); } if ($sent = $transport->send($message, $failedRecipients)) { + $this->_lastUsedTransport = $transport; break; } } catch (Swift_TransportException $e) { diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Transport/MailTransport.php b/swiftmailer/swiftmailer/lib/classes/Swift/Transport/MailTransport.php index 1ec36e30d..32a11efae 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Transport/MailTransport.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Transport/MailTransport.php @@ -19,7 +19,9 @@ * due to limitations of PHP's internal mail() function. You'll get an * all-or-nothing result from sending. * - * @author Chris Corbyn + * @author Chris Corbyn + * + * @deprecated since 5.4.5 (to be removed in 6.0) */ class Swift_Transport_MailTransport implements Swift_Transport { @@ -40,6 +42,8 @@ class Swift_Transport_MailTransport implements Swift_Transport */ public function __construct(Swift_Transport_MailInvoker $invoker, Swift_Events_EventDispatcher $eventDispatcher) { + @trigger_error(sprintf('The %s class is deprecated since version 5.4.5 and will be removed in 6.0. Use the Sendmail or SMTP transport instead.', __CLASS__), E_USER_DEPRECATED); + $this->_invoker = $invoker; $this->_eventDispatcher = $eventDispatcher; } @@ -125,10 +129,10 @@ public function send(Swift_Mime_Message $message, &$failedRecipients = null) $toHeader = $message->getHeaders()->get('To'); $subjectHeader = $message->getHeaders()->get('Subject'); - if (!$toHeader) { + if (0 === $count) { $this->_throwException(new Swift_TransportException('Cannot send message without a recipient')); } - $to = $toHeader->getFieldBody(); + $to = $toHeader ? $toHeader->getFieldBody() : ''; $subject = $subjectHeader ? $subjectHeader->getFieldBody() : ''; $reversePath = $this->_getReversePath($message); @@ -139,7 +143,9 @@ public function send(Swift_Mime_Message $message, &$failedRecipients = null) $messageStr = $message->toString(); - $message->getHeaders()->set($toHeader); + if ($toHeader) { + $message->getHeaders()->set($toHeader); + } $message->getHeaders()->set($subjectHeader); // Separate headers from body @@ -156,15 +162,16 @@ public function send(Swift_Mime_Message $message, &$failedRecipients = null) if ("\r\n" != PHP_EOL) { // Non-windows (not using SMTP) $headers = str_replace("\r\n", PHP_EOL, $headers); + $subject = str_replace("\r\n", PHP_EOL, $subject); $body = str_replace("\r\n", PHP_EOL, $body); } else { // Windows, using SMTP $headers = str_replace("\r\n.", "\r\n..", $headers); + $subject = str_replace("\r\n.", "\r\n..", $subject); $body = str_replace("\r\n.", "\r\n..", $body); } - if ($this->_invoker->mail($to, $subject, $body, $headers, - sprintf($this->_extraParams, $reversePath))) { + if ($this->_invoker->mail($to, $subject, $body, $headers, $this->_formatExtraParams($this->_extraParams, $reversePath))) { if ($evt) { $evt->setResult(Swift_Events_SendEvent::RESULT_SUCCESS); $evt->setFailedRecipients($failedRecipients); @@ -234,4 +241,55 @@ private function _getReversePath(Swift_Mime_Message $message) return $path; } + + /** + * Fix CVE-2016-10074 by disallowing potentially unsafe shell characters. + * + * Note that escapeshellarg and escapeshellcmd are inadequate for our purposes, especially on Windows. + * + * @param string $string The string to be validated + * + * @return bool + */ + private function _isShellSafe($string) + { + // Future-proof + if (escapeshellcmd($string) !== $string || !in_array(escapeshellarg($string), array("'$string'", "\"$string\""))) { + return false; + } + + $length = strlen($string); + for ($i = 0; $i < $length; ++$i) { + $c = $string[$i]; + // All other characters have a special meaning in at least one common shell, including = and +. + // Full stop (.) has a special meaning in cmd.exe, but its impact should be negligible here. + // Note that this does permit non-Latin alphanumeric characters based on the current locale. + if (!ctype_alnum($c) && strpos('@_-.', $c) === false) { + return false; + } + } + + return true; + } + + /** + * Return php mail extra params to use for invoker->mail. + * + * @param $extraParams + * @param $reversePath + * + * @return string|null + */ + private function _formatExtraParams($extraParams, $reversePath) + { + if (false !== strpos($extraParams, '-f%s')) { + if (empty($reversePath) || false === $this->_isShellSafe($reversePath)) { + $extraParams = str_replace('-f%s', '', $extraParams); + } else { + $extraParams = sprintf($extraParams, $reversePath); + } + } + + return !empty($extraParams) ? $extraParams : null; + } } diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Transport/NullTransport.php b/swiftmailer/swiftmailer/lib/classes/Swift/Transport/NullTransport.php index f87cfbf3e..ad20e0e53 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Transport/NullTransport.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Transport/NullTransport.php @@ -11,7 +11,7 @@ /** * Pretends messages have been sent, but just ignores them. * - * @author Fabien Potencier + * @author Fabien Potencier */ class Swift_Transport_NullTransport implements Swift_Transport { @@ -56,7 +56,7 @@ public function stop() * @param Swift_Mime_Message $message * @param string[] $failedRecipients An array of failures by-reference * - * @return int The number of sent emails + * @return int The number of sent emails */ public function send(Swift_Mime_Message $message, &$failedRecipients = null) { diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Transport/SendmailTransport.php b/swiftmailer/swiftmailer/lib/classes/Swift/Transport/SendmailTransport.php index c508cb135..34ac4ce3a 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Transport/SendmailTransport.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Transport/SendmailTransport.php @@ -15,7 +15,7 @@ * It is advised to use -bs mode since error reporting with -t mode is not * possible. * - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_Transport_SendmailTransport extends Swift_Transport_AbstractSmtpTransport { @@ -102,6 +102,7 @@ public function send(Swift_Mime_Message $message, &$failedRecipients = null) $failedRecipients = (array) $failedRecipients; $command = $this->getCommand(); $buffer = $this->getBuffer(); + $count = 0; if (false !== strpos($command, ' -t')) { if ($evt = $this->_eventDispatcher->createSendEvent($this, $message)) { diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Transport/SimpleMailInvoker.php b/swiftmailer/swiftmailer/lib/classes/Swift/Transport/SimpleMailInvoker.php index 21e629a64..4cab66bd6 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Transport/SimpleMailInvoker.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Transport/SimpleMailInvoker.php @@ -32,8 +32,8 @@ public function mail($to, $subject, $body, $headers = null, $extraParams = null) { if (!ini_get('safe_mode')) { return @mail($to, $subject, $body, $headers, $extraParams); - } else { - return @mail($to, $subject, $body, $headers); } + + return @mail($to, $subject, $body, $headers); } } diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Transport/SmtpAgent.php b/swiftmailer/swiftmailer/lib/classes/Swift/Transport/SmtpAgent.php index 4763b67ec..90e913f8e 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Transport/SmtpAgent.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Transport/SmtpAgent.php @@ -11,7 +11,7 @@ /** * Wraps an IoBuffer to send/receive SMTP commands/responses. * - * @author Chris Corbyn + * @author Chris Corbyn */ interface Swift_Transport_SmtpAgent { diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Transport/SpoolTransport.php b/swiftmailer/swiftmailer/lib/classes/Swift/Transport/SpoolTransport.php index 6ee9ef5c7..55a799245 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Transport/SpoolTransport.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Transport/SpoolTransport.php @@ -11,7 +11,7 @@ /** * Stores Messages in a queue. * - * @author Fabien Potencier + * @author Fabien Potencier */ class Swift_Transport_SpoolTransport implements Swift_Transport { @@ -84,7 +84,7 @@ public function stop() * @param Swift_Mime_Message $message * @param string[] $failedRecipients An array of failures by-reference * - * @return int The number of sent e-mail's + * @return int The number of sent e-mail's */ public function send(Swift_Mime_Message $message, &$failedRecipients = null) { @@ -98,7 +98,7 @@ public function send(Swift_Mime_Message $message, &$failedRecipients = null) $success = $this->_spool->queueMessage($message); if ($evt) { - $evt->setResult($success ? Swift_Events_SendEvent::RESULT_SUCCESS : Swift_Events_SendEvent::RESULT_FAILED); + $evt->setResult($success ? Swift_Events_SendEvent::RESULT_SPOOLED : Swift_Events_SendEvent::RESULT_FAILED); $this->_eventDispatcher->dispatchEvent($evt, 'sendPerformed'); } diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Transport/StreamBuffer.php b/swiftmailer/swiftmailer/lib/classes/Swift/Transport/StreamBuffer.php index 53e2ffa8d..5134ea48a 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Transport/StreamBuffer.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Transport/StreamBuffer.php @@ -11,7 +11,7 @@ /** * A generic IoBuffer implementation supporting remote sockets and local processes. * - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_Transport_StreamBuffer extends Swift_ByteStream_AbstractFilterableInputStream implements Swift_Transport_IoBuffer { @@ -151,11 +151,11 @@ public function setWriteTranslations(array $replacements) * The $sequence number comes from any writes and may or may not be used * depending upon the implementation. * - * @param int $sequence of last write to scan from - * - * @return string + * @param int $sequence of last write to scan from * * @throws Swift_IoException + * + * @return string */ public function readLine($sequence) { @@ -183,11 +183,11 @@ public function readLine($sequence) * If less bytes exist than are requested the remaining bytes are given instead. * If no bytes are remaining at all, boolean false is returned. * - * @param int $length - * - * @return string|bool + * @param int $length * * @throws Swift_IoException + * + * @return string|bool */ public function read($length) { @@ -260,7 +260,11 @@ private function _establishSocketConnection() if (!empty($this->_params['sourceIp'])) { $options['socket']['bindto'] = $this->_params['sourceIp'].':0'; } - $this->_stream = @stream_socket_client($host.':'.$this->_params['port'], $errno, $errstr, $timeout, STREAM_CLIENT_CONNECT, stream_context_create($options)); + if (isset($this->_params['stream_context_options'])) { + $options = array_merge($options, $this->_params['stream_context_options']); + } + $streamContext = stream_context_create($options); + $this->_stream = @stream_socket_client($host.':'.$this->_params['port'], $errno, $errstr, $timeout, STREAM_CLIENT_CONNECT, $streamContext); if (false === $this->_stream) { throw new Swift_TransportException( 'Connection could not be established with host '.$this->_params['host']. @@ -273,8 +277,8 @@ private function _establishSocketConnection() stream_set_blocking($this->_stream, 0); } stream_set_timeout($this->_stream, $timeout); - $this->_in = & $this->_stream; - $this->_out = & $this->_stream; + $this->_in = &$this->_stream; + $this->_out = &$this->_stream; } /** @@ -295,8 +299,8 @@ private function _establishProcessConnection() 'Process could not be started ['.$err.']' ); } - $this->_in = & $pipes[0]; - $this->_out = & $pipes[1]; + $this->_in = &$pipes[0]; + $this->_out = &$pipes[1]; } private function _getReadConnectionDescription() diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/TransportException.php b/swiftmailer/swiftmailer/lib/classes/Swift/TransportException.php index bdcd23bb9..4ae2412e6 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/TransportException.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/TransportException.php @@ -11,17 +11,19 @@ /** * TransportException thrown when an error occurs in the Transport subsystem. * - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_TransportException extends Swift_IoException { /** * Create a new TransportException with $message. * - * @param string $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); } } diff --git a/swiftmailer/swiftmailer/lib/classes/Swift/Validate.php b/swiftmailer/swiftmailer/lib/classes/Swift/Validate.php index 21e16c869..e16c212c4 100644 --- a/swiftmailer/swiftmailer/lib/classes/Swift/Validate.php +++ b/swiftmailer/swiftmailer/lib/classes/Swift/Validate.php @@ -1,4 +1,5 @@ register('properties.charset') diff --git a/swiftmailer/swiftmailer/lib/swift_init.php b/swiftmailer/swiftmailer/lib/swift_init.php index 5c4bae4f4..ff7196344 100644 --- a/swiftmailer/swiftmailer/lib/swift_init.php +++ b/swiftmailer/swiftmailer/lib/swift_init.php @@ -19,10 +19,10 @@ define('SWIFT_INIT_LOADED', true); // Load in dependency maps -require dirname(__FILE__).'/dependency_maps/cache_deps.php'; -require dirname(__FILE__).'/dependency_maps/mime_deps.php'; -require dirname(__FILE__).'/dependency_maps/message_deps.php'; -require dirname(__FILE__).'/dependency_maps/transport_deps.php'; +require __DIR__.'/dependency_maps/cache_deps.php'; +require __DIR__.'/dependency_maps/mime_deps.php'; +require __DIR__.'/dependency_maps/message_deps.php'; +require __DIR__.'/dependency_maps/transport_deps.php'; // Load in global library preferences -require dirname(__FILE__).'/preferences.php'; +require __DIR__.'/preferences.php'; diff --git a/swiftmailer/swiftmailer/lib/swift_required.php b/swiftmailer/swiftmailer/lib/swift_required.php index ca7d8a38c..03a72ceae 100644 --- a/swiftmailer/swiftmailer/lib/swift_required.php +++ b/swiftmailer/swiftmailer/lib/swift_required.php @@ -17,12 +17,12 @@ } // Load Swift utility class -require dirname(__FILE__).'/classes/Swift.php'; +require __DIR__.'/classes/Swift.php'; if (!function_exists('_swiftmailer_init')) { function _swiftmailer_init() { - require dirname(__FILE__).'/swift_init.php'; + require __DIR__.'/swift_init.php'; } } diff --git a/swiftmailer/swiftmailer/lib/swift_required_pear.php b/swiftmailer/swiftmailer/lib/swift_required_pear.php index d826d0f97..2b5181a93 100644 --- a/swiftmailer/swiftmailer/lib/swift_required_pear.php +++ b/swiftmailer/swiftmailer/lib/swift_required_pear.php @@ -17,12 +17,12 @@ } // Load Swift utility class -require dirname(__FILE__).'/Swift.php'; +require __DIR__.'/Swift.php'; if (!function_exists('_swiftmailer_init')) { function _swiftmailer_init() { - require dirname(__FILE__).'/swift_init.php'; + require __DIR__.'/swift_init.php'; } } diff --git a/swiftmailer/swiftmailer/lib/swiftmailer_generate_mimes_config.php b/swiftmailer/swiftmailer/lib/swiftmailer_generate_mimes_config.php index 31cee0d01..3bb878072 100755 --- a/swiftmailer/swiftmailer/lib/swiftmailer_generate_mimes_config.php +++ b/swiftmailer/swiftmailer/lib/swiftmailer_generate_mimes_config.php @@ -22,80 +22,79 @@ function generateUpToDateMimeArray() // get current mime types files $mime_types = @file_get_contents(APACHE_MIME_TYPES_URL); - $mime_xml = @file_get_contents(FREEDESKTOP_XML_URL); + $mime_xml = @file_get_contents(FREEDESKTOP_XML_URL); // prepare valid mime types $valid_mime_types = array(); // split mime type and extensions eg. "video/x-matroska mkv mk3d mks" - if (preg_match_all('/^#?([a-z0-9\-\+\/\.]+)[\t]+(.*)$/miu', $mime_types, $matches) !== FALSE) { + if (preg_match_all('/^#?([a-z0-9\-\+\/\.]+)[\t]+(.*)$/miu', $mime_types, $matches) !== false) { // collection of predefined mimetypes (bugfix for wrong resolved or missing mime types) $valid_mime_types_preset = array( - 'php' => 'application/x-php', + 'php' => 'application/x-php', 'php3' => 'application/x-php', 'php4' => 'application/x-php', 'php5' => 'application/x-php', - 'zip' => 'application/zip', - 'gif' => 'image/gif', - 'png' => 'image/png', - 'css' => 'text/css', - 'js' => 'text/javascript', - 'txt' => 'text/plain', - 'xml' => 'text/xml', - 'aif' => 'audio/x-aiff', + 'zip' => 'application/zip', + 'gif' => 'image/gif', + 'png' => 'image/png', + 'css' => 'text/css', + 'js' => 'text/javascript', + 'txt' => 'text/plain', + 'aif' => 'audio/x-aiff', 'aiff' => 'audio/x-aiff', - 'avi' => 'video/avi', - 'bmp' => 'image/bmp', - 'bz2' => 'application/x-bz2', - 'csv' => 'text/csv', - 'dmg' => 'application/x-apple-diskimage', - 'doc' => 'application/msword', + 'avi' => 'video/avi', + 'bmp' => 'image/bmp', + 'bz2' => 'application/x-bz2', + 'csv' => 'text/csv', + 'dmg' => 'application/x-apple-diskimage', + 'doc' => 'application/msword', 'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', - 'eml' => 'message/rfc822', - 'aps' => 'application/postscript', - 'exe' => 'application/x-ms-dos-executable', - 'flv' => 'video/x-flv', - 'gz' => 'application/x-gzip', - 'hqx' => 'application/stuffit', - 'htm' => 'text/html', + 'eml' => 'message/rfc822', + 'aps' => 'application/postscript', + 'exe' => 'application/x-ms-dos-executable', + 'flv' => 'video/x-flv', + 'gz' => 'application/x-gzip', + 'hqx' => 'application/stuffit', + 'htm' => 'text/html', 'html' => 'text/html', - 'jar' => 'application/x-java-archive', + 'jar' => 'application/x-java-archive', 'jpeg' => 'image/jpeg', - 'jpg' => 'image/jpeg', - 'm3u' => 'audio/x-mpegurl', - 'm4a' => 'audio/mp4', - 'mdb' => 'application/x-msaccess', - 'mid' => 'audio/midi', + 'jpg' => 'image/jpeg', + 'm3u' => 'audio/x-mpegurl', + 'm4a' => 'audio/mp4', + 'mdb' => 'application/x-msaccess', + 'mid' => 'audio/midi', 'midi' => 'audio/midi', - 'mov' => 'video/quicktime', - 'mp3' => 'audio/mpeg', - 'mp4' => 'video/mp4', + 'mov' => 'video/quicktime', + 'mp3' => 'audio/mpeg', + 'mp4' => 'video/mp4', 'mpeg' => 'video/mpeg', - 'mpg' => 'video/mpeg', - 'odg' => 'vnd.oasis.opendocument.graphics', - 'odp' => 'vnd.oasis.opendocument.presentation', - 'odt' => 'vnd.oasis.opendocument.text', - 'ods' => 'vnd.oasis.opendocument.spreadsheet', - 'ogg' => 'audio/ogg', - 'pdf' => 'application/pdf', - 'ppt' => 'application/vnd.ms-powerpoint', + 'mpg' => 'video/mpeg', + 'odg' => 'vnd.oasis.opendocument.graphics', + 'odp' => 'vnd.oasis.opendocument.presentation', + 'odt' => 'vnd.oasis.opendocument.text', + 'ods' => 'vnd.oasis.opendocument.spreadsheet', + 'ogg' => 'audio/ogg', + 'pdf' => 'application/pdf', + 'ppt' => 'application/vnd.ms-powerpoint', 'pptx' => 'application/vnd.openxmlformats-officedocument.presentationml.presentation', - 'ps' => 'application/postscript', - 'rar' => 'application/x-rar-compressed', - 'rtf' => 'application/rtf', - 'tar' => 'application/x-tar', - 'sit' => 'application/x-stuffit', - 'svg' => 'image/svg+xml', - 'tif' => 'image/tiff', + 'ps' => 'application/postscript', + 'rar' => 'application/x-rar-compressed', + 'rtf' => 'application/rtf', + 'tar' => 'application/x-tar', + 'sit' => 'application/x-stuffit', + 'svg' => 'image/svg+xml', + 'tif' => 'image/tiff', 'tiff' => 'image/tiff', - 'ttf' => 'application/x-font-truetype', - 'vcf' => 'text/x-vcard', - 'wav' => 'audio/wav', - 'wma' => 'audio/x-ms-wma', - 'wmv' => 'audio/x-ms-wmv', - 'xls' => 'application/excel', + 'ttf' => 'application/x-font-truetype', + 'vcf' => 'text/x-vcard', + 'wav' => 'audio/wav', + 'wma' => 'audio/x-ms-wma', + 'wmv' => 'audio/x-ms-wmv', + 'xls' => 'application/excel', 'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', - 'xml' => 'application/xml', + 'xml' => 'application/xml', ); // wrap array for generating file @@ -110,7 +109,7 @@ function generateUpToDateMimeArray() // all extensions from second match foreach ($matches[2] as $i => $extensions) { // explode multiple extensions from string - $extensions = explode(" ", strtolower($extensions)); + $extensions = explode(' ', strtolower($extensions)); // force array for foreach if (!is_array($extensions)) { @@ -139,14 +138,14 @@ function generateUpToDateMimeArray() foreach ($xml as $node) { // check if there is no pattern - if (!isset($node->glob["pattern"])) { + if (!isset($node->glob['pattern'])) { continue; } // get all matching extensions from match - foreach ((array) $node->glob["pattern"] as $extension) { + foreach ((array) $node->glob['pattern'] as $extension) { // skip none glob extensions - if (strpos($extension, '.') === FALSE) { + if (strpos($extension, '.') === false) { continue; } @@ -160,15 +159,15 @@ function generateUpToDateMimeArray() } } - if (isset($node->glob["pattern"][0])) { + if (isset($node->glob['pattern'][0])) { // mime type - $mime_type = strtolower((string) $node["type"]); + $mime_type = strtolower((string) $node['type']); // get first extension - $extension = strtolower(trim($node->glob["ddpattern"][0], '*.')); + $extension = strtolower(trim($node->glob['ddpattern'][0], '*.')); // skip none glob extensions and check if string length between 1 and 10 - if (strpos($extension, '.') !== FALSE || strlen($extension) < 1 || strlen($extension) > 9) { + if (strpos($extension, '.') !== false || strlen($extension) < 1 || strlen($extension) > 9) { continue; }