From d956682b9fc9a061c86dfe05f83585fbcb38ab14 Mon Sep 17 00:00:00 2001 From: Stephen Abello Date: Fri, 27 Apr 2018 14:06:51 +0000 Subject: [PATCH] =?UTF-8?q?N=C2=B01285=20&=20N=C2=B01278:=20Updated=20swif?= =?UTF-8?q?tmailer=20to=20v5.4.9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit SVN:trunk[5754] --- lib/swiftmailer/CHANGES | 102 ++++++++ lib/swiftmailer/LICENSE | 2 +- lib/swiftmailer/README | 5 +- lib/swiftmailer/VERSION | 2 +- lib/swiftmailer/lib/classes/Swift.php | 9 +- .../lib/classes/Swift/Attachment.php | 4 +- .../AbstractFilterableInputStream.php | 12 +- .../Swift/ByteStream/ArrayByteStream.php | 14 +- .../Swift/ByteStream/FileByteStream.php | 44 ++-- .../ByteStream/TemporaryFileByteStream.php | 4 +- .../lib/classes/Swift/CharacterReader.php | 20 +- .../GenericFixedWidthReader.php | 24 +- .../Swift/CharacterReader/UsAsciiReader.php | 33 ++- .../Swift/CharacterReader/Utf8Reader.php | 137 +++++----- .../classes/Swift/CharacterReaderFactory.php | 4 +- .../SimpleCharacterReaderFactory.php | 22 +- .../lib/classes/Swift/CharacterStream.php | 10 +- .../CharacterStream/ArrayCharacterStream.php | 15 +- .../CharacterStream/NgCharacterStream.php | 64 ++--- .../lib/classes/Swift/ConfigurableSpool.php | 11 +- .../lib/classes/Swift/DependencyContainer.php | 58 ++--- .../lib/classes/Swift/DependencyException.php | 3 +- .../lib/classes/Swift/EmbeddedFile.php | 4 +- lib/swiftmailer/lib/classes/Swift/Encoder.php | 9 +- .../classes/Swift/Encoder/Base64Encoder.php | 14 +- .../lib/classes/Swift/Encoder/QpEncoder.php | 102 ++++---- .../classes/Swift/Encoder/Rfc2231Encoder.php | 28 +- .../lib/classes/Swift/Encoding.php | 6 +- .../lib/classes/Swift/Events/CommandEvent.php | 8 +- .../classes/Swift/Events/CommandListener.php | 4 +- .../lib/classes/Swift/Events/Event.php | 6 +- .../classes/Swift/Events/EventDispatcher.php | 4 +- .../classes/Swift/Events/EventListener.php | 4 +- .../lib/classes/Swift/Events/EventObject.php | 6 +- .../classes/Swift/Events/ResponseEvent.php | 5 +- .../classes/Swift/Events/ResponseListener.php | 4 +- .../lib/classes/Swift/Events/SendEvent.php | 9 +- .../lib/classes/Swift/Events/SendListener.php | 4 +- .../Swift/Events/SimpleEventDispatcher.php | 11 +- .../Swift/Events/TransportChangeEvent.php | 4 +- .../Swift/Events/TransportChangeListener.php | 4 +- .../Swift/Events/TransportExceptionEvent.php | 4 +- .../Events/TransportExceptionListener.php | 4 +- .../lib/classes/Swift/FailoverTransport.php | 6 +- .../lib/classes/Swift/FileSpool.php | 37 ++- .../lib/classes/Swift/FileStream.php | 4 +- .../lib/classes/Swift/Filterable.php | 3 +- lib/swiftmailer/lib/classes/Swift/Image.php | 14 +- .../lib/classes/Swift/InputByteStream.php | 8 +- .../lib/classes/Swift/IoException.php | 11 +- .../lib/classes/Swift/KeyCache.php | 12 +- .../classes/Swift/KeyCache/ArrayKeyCache.php | 22 +- .../classes/Swift/KeyCache/DiskKeyCache.php | 55 ++-- .../Swift/KeyCache/KeyCacheInputStream.php | 4 +- .../classes/Swift/KeyCache/NullKeyCache.php | 12 +- .../KeyCache/SimpleKeyCacheInputStream.php | 4 +- .../classes/Swift/LoadBalancedTransport.php | 6 +- .../lib/classes/Swift/MailTransport.php | 8 +- lib/swiftmailer/lib/classes/Swift/Mailer.php | 7 +- .../Swift/Mailer/ArrayRecipientIterator.php | 6 +- .../Swift/Mailer/RecipientIterator.php | 6 +- .../lib/classes/Swift/MemorySpool.php | 40 ++- lib/swiftmailer/lib/classes/Swift/Message.php | 202 +++++++------- .../lib/classes/Swift/Mime/Attachment.php | 22 +- .../classes/Swift/Mime/CharsetObserver.php | 4 +- .../lib/classes/Swift/Mime/ContentEncoder.php | 4 +- .../ContentEncoder/Base64ContentEncoder.php | 47 +++- .../ContentEncoder/NativeQpContentEncoder.php | 16 +- .../ContentEncoder/PlainContentEncoder.php | 31 +-- .../Mime/ContentEncoder/QpContentEncoder.php | 27 +- .../ContentEncoder/QpContentEncoderProxy.php | 14 +- .../Mime/ContentEncoder/RawContentEncoder.php | 11 +- .../lib/classes/Swift/Mime/EmbeddedFile.php | 4 +- .../classes/Swift/Mime/EncodingObserver.php | 4 +- .../lib/classes/Swift/Mime/Grammar.php | 106 ++++---- .../lib/classes/Swift/Mime/Header.php | 4 +- .../lib/classes/Swift/Mime/HeaderEncoder.php | 4 +- .../HeaderEncoder/Base64HeaderEncoder.php | 12 +- .../Mime/HeaderEncoder/QpHeaderEncoder.php | 10 +- .../lib/classes/Swift/Mime/HeaderFactory.php | 8 +- .../lib/classes/Swift/Mime/HeaderSet.php | 26 +- .../Swift/Mime/Headers/AbstractHeader.php | 65 +++-- .../classes/Swift/Mime/Headers/DateHeader.php | 10 +- .../Mime/Headers/IdentificationHeader.php | 19 +- .../Swift/Mime/Headers/MailboxHeader.php | 55 ++-- .../Swift/Mime/Headers/OpenDKIMHeader.php | 44 ++-- .../Mime/Headers/ParameterizedHeader.php | 53 ++-- .../classes/Swift/Mime/Headers/PathHeader.php | 13 +- .../Swift/Mime/Headers/UnstructuredHeader.php | 4 +- .../lib/classes/Swift/Mime/Message.php | 6 +- .../lib/classes/Swift/Mime/MimeEntity.php | 8 +- .../lib/classes/Swift/Mime/MimePart.php | 28 +- .../Swift/Mime/ParameterizedHeader.php | 4 +- .../Swift/Mime/SimpleHeaderFactory.php | 25 +- .../classes/Swift/Mime/SimpleHeaderSet.php | 81 ++++-- .../lib/classes/Swift/Mime/SimpleMessage.php | 81 +++--- .../classes/Swift/Mime/SimpleMimeEntity.php | 182 ++++++------- .../lib/classes/Swift/MimePart.php | 6 +- .../lib/classes/Swift/NullTransport.php | 8 +- .../lib/classes/Swift/OutputByteStream.php | 16 +- .../classes/Swift/Plugins/AntiFloodPlugin.php | 10 +- .../Swift/Plugins/BandwidthMonitorPlugin.php | 4 +- .../Swift/Plugins/Decorator/Replacements.php | 4 +- .../classes/Swift/Plugins/DecoratorPlugin.php | 17 +- .../Swift/Plugins/ImpersonatePlugin.php | 11 +- .../lib/classes/Swift/Plugins/Logger.php | 4 +- .../classes/Swift/Plugins/LoggerPlugin.php | 23 +- .../Swift/Plugins/Loggers/ArrayLogger.php | 6 +- .../Swift/Plugins/Loggers/EchoLogger.php | 6 +- .../classes/Swift/Plugins/MessageLogger.php | 17 +- .../Swift/Plugins/Pop/Pop3Connection.php | 4 +- .../Swift/Plugins/Pop/Pop3Exception.php | 4 +- .../Swift/Plugins/PopBeforeSmtpPlugin.php | 37 ++- .../Swift/Plugins/RedirectingPlugin.php | 36 +-- .../lib/classes/Swift/Plugins/Reporter.php | 4 +- .../classes/Swift/Plugins/ReporterPlugin.php | 24 +- .../Swift/Plugins/Reporters/HitReporter.php | 4 +- .../Swift/Plugins/Reporters/HtmlReporter.php | 16 +- .../lib/classes/Swift/Plugins/Sleeper.php | 6 +- .../classes/Swift/Plugins/ThrottlerPlugin.php | 26 +- .../lib/classes/Swift/Plugins/Timer.php | 4 +- .../lib/classes/Swift/Preferences.php | 24 +- .../Swift/ReplacementFilterFactory.php | 3 +- .../classes/Swift/RfcComplianceException.php | 3 +- .../lib/classes/Swift/SendmailTransport.php | 6 +- .../lib/classes/Swift/SignedMessage.php | 6 +- lib/swiftmailer/lib/classes/Swift/Signer.php | 4 +- .../lib/classes/Swift/Signers/BodySigner.php | 10 +- .../lib/classes/Swift/Signers/DKIMSigner.php | 222 +++++++++------- .../classes/Swift/Signers/DomainKeySigner.php | 160 ++++++------ .../classes/Swift/Signers/HeaderSigner.php | 28 +- .../classes/Swift/Signers/OpenDKIMSigner.php | 100 +++---- .../lib/classes/Swift/Signers/SMimeSigner.php | 62 +++-- .../lib/classes/Swift/SmtpTransport.php | 19 +- lib/swiftmailer/lib/classes/Swift/Spool.php | 7 +- .../lib/classes/Swift/SpoolTransport.php | 5 +- .../lib/classes/Swift/StreamFilter.php | 3 +- .../ByteArrayReplacementFilter.php | 27 +- .../StreamFilters/StringReplacementFilter.php | 7 +- .../StringReplacementFilterFactory.php | 3 +- .../lib/classes/Swift/SwiftException.php | 11 +- .../lib/classes/Swift/Transport.php | 4 +- .../Swift/Transport/AbstractSmtpTransport.php | 78 +++--- .../Esmtp/Auth/CramMd5Authenticator.php | 10 +- .../Esmtp/Auth/LoginAuthenticator.php | 4 +- .../Esmtp/Auth/NTLMAuthenticator.php | 246 ++++++++++-------- .../Esmtp/Auth/PlainAuthenticator.php | 6 +- .../Esmtp/Auth/XOAuth2Authenticator.php | 15 +- .../Swift/Transport/Esmtp/AuthHandler.php | 15 +- .../Swift/Transport/Esmtp/Authenticator.php | 4 +- .../classes/Swift/Transport/EsmtpHandler.php | 4 +- .../Swift/Transport/EsmtpTransport.php | 78 +++--- .../Swift/Transport/FailoverTransport.php | 20 +- .../lib/classes/Swift/Transport/IoBuffer.php | 6 +- .../Swift/Transport/LoadBalancedTransport.php | 28 +- .../classes/Swift/Transport/MailInvoker.php | 2 - .../classes/Swift/Transport/MailTransport.php | 97 ++++++- .../classes/Swift/Transport/NullTransport.php | 5 +- .../Swift/Transport/SendmailTransport.php | 17 +- .../Swift/Transport/SimpleMailInvoker.php | 6 +- .../lib/classes/Swift/Transport/SmtpAgent.php | 4 +- .../Swift/Transport/SpoolTransport.php | 9 +- .../classes/Swift/Transport/StreamBuffer.php | 64 +++-- .../lib/classes/Swift/TransportException.php | 12 +- .../lib/classes/Swift/Validate.php | 8 +- .../lib/dependency_maps/mime_deps.php | 14 +- .../lib/dependency_maps/transport_deps.php | 8 +- lib/swiftmailer/lib/mime_types.php | 6 +- lib/swiftmailer/lib/preferences.php | 16 +- lib/swiftmailer/lib/swift_init.php | 10 +- lib/swiftmailer/lib/swift_required.php | 4 +- lib/swiftmailer/lib/swift_required_pear.php | 4 +- 172 files changed, 2102 insertions(+), 2051 deletions(-) diff --git a/lib/swiftmailer/CHANGES b/lib/swiftmailer/CHANGES index c78c46326..07fa342bc 100644 --- a/lib/swiftmailer/CHANGES +++ b/lib/swiftmailer/CHANGES @@ -1,6 +1,108 @@ Changelog ========= +5.4.9 (2018-01-23) +------------------ + + * no changes, last version of the 5.x series + +5.4.8 (2017-05-01) +------------------ + + * fixed encoding inheritance in addPart() + * fixed sorting MIME children when their types are equal + +5.4.7 (2017-04-20) +------------------ + + * fixed NTLMAuthenticator clobbering bcmath scale + +5.4.6 (2017-02-13) +------------------ + + * removed exceptions thrown in destructors as they lead to fatal errors + * switched to use sha256 by default in DKIM as per the RFC + * fixed an 'Undefined variable: pipes' PHP notice + * fixed long To headers when using the mail transport + * fixed NTLMAuthenticator when no domain is passed with the username + * prevented fatal error during unserialization of a message + * fixed a PHP warning when sending a message that has a length of a multiple of 8192 + +5.4.5 (2016-12-29) +------------------ + + * SECURITY FIX: fixed CVE-2016-10074 by disallowing potentially unsafe shell characters + + Prior to 5.4.5, the mail transport (Swift_Transport_MailTransport) was vulnerable to passing + arbitrary shell arguments if the "From", "ReturnPath" or "Sender" header came + from a non-trusted source, potentially allowing Remote Code Execution + * deprecated the mail transport + +5.4.4 (2016-11-23) +------------------ + + * reverted escaping command-line args to mail (PHP mail() function already does it) + +5.4.3 (2016-07-08) +------------------ + + * fixed SimpleHeaderSet::has()/get() when the 0 index is removed + * removed the need to have mcrypt installed + * fixed broken MIME header encoding with quotes/colons and non-ascii chars + * allowed mail transport send for messages without To header + * fixed PHP 7 support + +5.4.2 (2016-05-01) +------------------ + + * fixed support for IPv6 sockets + * added auto-retry when sending messages from the memory spool + * fixed consecutive read calls in Swift_ByteStream_FileByteStream + * added support for iso-8859-15 encoding + * fixed PHP mail extra params on missing reversePath + * added methods to set custom stream context options + * fixed charset changes in QpContentEncoderProxy + * added return-path header to the ignoredHeaders list of DKIMSigner + * fixed crlf for subject using mail + * fixed add soft line break only when necessary + * fixed escaping command-line args to mail + +5.4.1 (2015-06-06) +------------------ + + * made Swiftmailer exceptions confirm to PHP base exception constructor signature + * fixed MAIL FROM & RCPT TO headers to be RFC compliant + +5.4.0 (2015-03-14) +------------------ + + * added the possibility to add extra certs to PKCS#7 signature + * fix base64 encoding with streams + * added a new RESULT_SPOOLED status for SpoolTransport + * fixed getBody() on attachments when called more than once + * removed dots from generated filenames in filespool + +5.3.1 (2014-12-05) +------------------ + + * fixed cloning of messages with attachments + +5.3.0 (2014-10-04) +------------------ + + * fixed cloning when using signers + * reverted removal of Swift_Encoding + * drop support for PHP 5.2.x + +5.2.2 (2014-09-20) +------------------ + + * fixed Japanese support + * fixed the memory spool when the message changes when in the pool + * added support for cloning messages + * fixed PHP warning in the redirect plugin + * changed the way to and cc-ed email are sent to only use one transaction + 5.2.1 (2014-06-13) ------------------ diff --git a/lib/swiftmailer/LICENSE b/lib/swiftmailer/LICENSE index 674bb2a6e..485f1d6d6 100644 --- a/lib/swiftmailer/LICENSE +++ b/lib/swiftmailer/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2013 Fabien Potencier +Copyright (c) 2013-2016 Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/lib/swiftmailer/README b/lib/swiftmailer/README index eb5f8bcfa..52c075758 100644 --- a/lib/swiftmailer/README +++ b/lib/swiftmailer/README @@ -4,9 +4,8 @@ Swift Mailer Swift Mailer is a component based mailing solution for PHP 5. It is released under the MIT license. -Homepage: http://swiftmailer.org -Documentation: http://swiftmailer.org/docs -Mailing List: http://groups.google.com/group/swiftmailer +Homepage: https://swiftmailer.symfony.com/ +Documentation: https://swiftmailer.symfony.com/docs/introduction.html Bugs: https://github.com/swiftmailer/swiftmailer/issues Repository: https://github.com/swiftmailer/swiftmailer diff --git a/lib/swiftmailer/VERSION b/lib/swiftmailer/VERSION index 064e3a3be..1842f65a0 100644 --- a/lib/swiftmailer/VERSION +++ b/lib/swiftmailer/VERSION @@ -1 +1 @@ -Swift-5.2.1 +Swift-5.4.9 diff --git a/lib/swiftmailer/lib/classes/Swift.php b/lib/swiftmailer/lib/classes/Swift.php index 1d1f8215e..82c381b73 100644 --- a/lib/swiftmailer/lib/classes/Swift.php +++ b/lib/swiftmailer/lib/classes/Swift.php @@ -11,18 +11,17 @@ /** * General utility class in Swift Mailer, not to be instantiated. * - * @package Swift * * @author Chris Corbyn */ abstract class Swift { - public static $initialized = false; - public static $inits = array(); - /** Swift Mailer Version number generated during dist release process */ const VERSION = '@SWIFT_VERSION_NUMBER@'; + public static $initialized = false; + public static $inits = array(); + /** * Registers an initializer callable that will be called the first time * a SwiftMailer class is autoloaded. @@ -48,7 +47,7 @@ abstract class Swift return; } - $path = dirname(__FILE__).'/'.str_replace('_', '/', $class).'.php'; + $path = __DIR__.'/'.str_replace('_', '/', $class).'.php'; if (!file_exists($path)) { return; diff --git a/lib/swiftmailer/lib/classes/Swift/Attachment.php b/lib/swiftmailer/lib/classes/Swift/Attachment.php index 7fdbcb999..a95bccfdf 100644 --- a/lib/swiftmailer/lib/classes/Swift/Attachment.php +++ b/lib/swiftmailer/lib/classes/Swift/Attachment.php @@ -11,9 +11,7 @@ /** * Attachment class for attaching files to a {@link Swift_Mime_Message}. * - * @package Swift - * @subpackage Mime - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_Attachment extends Swift_Mime_Attachment { diff --git a/lib/swiftmailer/lib/classes/Swift/ByteStream/AbstractFilterableInputStream.php b/lib/swiftmailer/lib/classes/Swift/ByteStream/AbstractFilterableInputStream.php index e12c0dd5d..a7b0e3a62 100644 --- a/lib/swiftmailer/lib/classes/Swift/ByteStream/AbstractFilterableInputStream.php +++ b/lib/swiftmailer/lib/classes/Swift/ByteStream/AbstractFilterableInputStream.php @@ -11,9 +11,7 @@ /** * Provides the base functionality for an InputStream supporting filters. * - * @package Swift - * @subpackage ByteStream - * @author Chris Corbyn + * @author Chris Corbyn */ abstract class Swift_ByteStream_AbstractFilterableInputStream implements Swift_InputByteStream, Swift_Filterable { @@ -24,6 +22,8 @@ abstract class Swift_ByteStream_AbstractFilterableInputStream implements Swift_I /** * StreamFilters. + * + * @var Swift_StreamFilter[] */ private $_filters = array(); @@ -77,9 +77,9 @@ abstract class Swift_ByteStream_AbstractFilterableInputStream implements Swift_I * * @param string $bytes * - * @return int - * * @throws Swift_IoException + * + * @return int */ public function write($bytes) { @@ -157,8 +157,6 @@ abstract class Swift_ByteStream_AbstractFilterableInputStream implements Swift_I } } - // -- Private methods - /** Run $bytes through all filters */ private function _filter($bytes) { diff --git a/lib/swiftmailer/lib/classes/Swift/ByteStream/ArrayByteStream.php b/lib/swiftmailer/lib/classes/Swift/ByteStream/ArrayByteStream.php index aa2959736..ef05a6d5e 100644 --- a/lib/swiftmailer/lib/classes/Swift/ByteStream/ArrayByteStream.php +++ b/lib/swiftmailer/lib/classes/Swift/ByteStream/ArrayByteStream.php @@ -11,9 +11,7 @@ /** * Allows reading and writing of bytes to and from an array. * - * @package Swift - * @subpackage ByteStream - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_ByteStream_ArrayByteStream implements Swift_InputByteStream, Swift_OutputByteStream { @@ -25,7 +23,7 @@ class Swift_ByteStream_ArrayByteStream implements Swift_InputByteStream, Swift_O private $_array = array(); /** - * The size of the stack + * The size of the stack. * * @var int */ @@ -72,7 +70,7 @@ class Swift_ByteStream_ArrayByteStream implements Swift_InputByteStream, Swift_O * remaining bytes are given instead. If no bytes are remaining at all, boolean * false is returned. * - * @param int $length + * @param int $length * * @return string */ @@ -84,9 +82,7 @@ class Swift_ByteStream_ArrayByteStream implements Swift_InputByteStream, Swift_O // Don't use array slice $end = $length + $this->_offset; - $end = $this->_arraySize<$end - ?$this->_arraySize - :$end; + $end = $this->_arraySize < $end ? $this->_arraySize : $end; $ret = ''; for (; $this->_offset < $end; ++$this->_offset) { $ret .= $this->_array[$this->_offset]; @@ -154,7 +150,7 @@ class Swift_ByteStream_ArrayByteStream implements Swift_InputByteStream, Swift_O /** * Move the internal read pointer to $byteOffset in the stream. * - * @param int $byteOffset + * @param int $byteOffset * * @return bool */ diff --git a/lib/swiftmailer/lib/classes/Swift/ByteStream/FileByteStream.php b/lib/swiftmailer/lib/classes/Swift/ByteStream/FileByteStream.php index 6f1d87e0f..9ed852310 100644 --- a/lib/swiftmailer/lib/classes/Swift/ByteStream/FileByteStream.php +++ b/lib/swiftmailer/lib/classes/Swift/ByteStream/FileByteStream.php @@ -11,9 +11,7 @@ /** * Allows reading and writing of bytes to and from a file. * - * @package Swift - * @subpackage ByteStream - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_ByteStream_FileByteStream extends Swift_ByteStream_AbstractFilterableInputStream implements Swift_FileStream { @@ -41,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) { @@ -75,11 +73,11 @@ class Swift_ByteStream_FileByteStream extends Swift_ByteStream_AbstractFilterabl * 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) { @@ -93,13 +91,13 @@ class Swift_ByteStream_FileByteStream extends Swift_ByteStream_AbstractFilterabl ini_set('magic_quotes_runtime', 1); } $this->_offset = ftell($fp); - + // If we read one byte after reaching the end of the file // feof() will return false and an empty string is returned if ($bytes === '' && feof($fp)) { - $this->_resetReadHandle(); - - return false; + $this->_resetReadHandle(); + + return false; } return $bytes; @@ -113,7 +111,7 @@ class Swift_ByteStream_FileByteStream extends Swift_ByteStream_AbstractFilterabl /** * Move the internal read pointer to $byteOffset in the stream. * - * @param int $byteOffset + * @param int $byteOffset * * @return bool */ @@ -125,8 +123,6 @@ class Swift_ByteStream_FileByteStream extends Swift_ByteStream_AbstractFilterabl $this->_offset = $byteOffset; } - // -- Private methods - /** Just write the bytes to the file */ protected function _commit($bytes) { @@ -143,12 +139,14 @@ class Swift_ByteStream_FileByteStream extends Swift_ByteStream_AbstractFilterabl private function _getReadHandle() { if (!isset($this->_reader)) { - if (!$this->_reader = fopen($this->_path, 'rb')) { + $pointer = @fopen($this->_path, 'rb'); + if (!$pointer) { throw new Swift_IoException( - 'Unable to open file for reading [' . $this->_path . ']' + 'Unable to open file for reading ['.$this->_path.']' ); } - if ($this->_offset <> 0) { + $this->_reader = $pointer; + if ($this->_offset != 0) { $this->_getReadStreamSeekableStatus(); $this->_seekReadStreamToPosition($this->_offset); } @@ -163,7 +161,7 @@ class Swift_ByteStream_FileByteStream extends Swift_ByteStream_AbstractFilterabl if (!isset($this->_writer)) { if (!$this->_writer = fopen($this->_path, $this->_mode)) { throw new Swift_IoException( - 'Unable to open file for writing [' . $this->_path . ']' + 'Unable to open file for writing ['.$this->_path.']' ); } } @@ -190,13 +188,13 @@ class Swift_ByteStream_FileByteStream extends Swift_ByteStream_AbstractFilterabl /** Streams in a readOnly stream ensuring copy if needed */ private function _seekReadStreamToPosition($offset) { - if ($this->_seekable===null) { + if ($this->_seekable === null) { $this->_getReadStreamSeekableStatus(); } 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; @@ -220,7 +218,7 @@ class Swift_ByteStream_FileByteStream extends Swift_ByteStream_AbstractFilterabl fclose($this->_reader); $source = fopen($this->_path, 'rb'); if (!$source) { - throw new Swift_IoException('Unable to open file for copying [' . $this->_path . ']'); + throw new Swift_IoException('Unable to open file for copying ['.$this->_path.']'); } fseek($tmpFile, 0, SEEK_SET); while (!feof($source)) { diff --git a/lib/swiftmailer/lib/classes/Swift/ByteStream/TemporaryFileByteStream.php b/lib/swiftmailer/lib/classes/Swift/ByteStream/TemporaryFileByteStream.php index f35f885e3..1c9a80c03 100644 --- a/lib/swiftmailer/lib/classes/Swift/ByteStream/TemporaryFileByteStream.php +++ b/lib/swiftmailer/lib/classes/Swift/ByteStream/TemporaryFileByteStream.php @@ -9,9 +9,7 @@ */ /** - * @package Swift - * @subpackage ByteStream - * @author Romain-Geissler + * @author Romain-Geissler */ class Swift_ByteStream_TemporaryFileByteStream extends Swift_ByteStream_FileByteStream { diff --git a/lib/swiftmailer/lib/classes/Swift/CharacterReader.php b/lib/swiftmailer/lib/classes/Swift/CharacterReader.php index 91a9c9680..4267adbc5 100644 --- a/lib/swiftmailer/lib/classes/Swift/CharacterReader.php +++ b/lib/swiftmailer/lib/classes/Swift/CharacterReader.php @@ -11,10 +11,8 @@ /** * Analyzes characters for a specific character set. * - * @package Swift - * @subpackage Encoder - * @author Chris Corbyn - * @author Xavier De Cock + * @author Chris Corbyn + * @author Xavier De Cock */ interface Swift_CharacterReader { @@ -23,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 */ @@ -50,8 +48,8 @@ interface Swift_CharacterReader * A value of zero means this is already a valid character. * A value of -1 means this cannot possibly be a valid character. * - * @param integer[] $bytes - * @param int $size + * @param int[] $bytes + * @param int $size * * @return int */ diff --git a/lib/swiftmailer/lib/classes/Swift/CharacterReader/GenericFixedWidthReader.php b/lib/swiftmailer/lib/classes/Swift/CharacterReader/GenericFixedWidthReader.php index 654761205..6a18e1dd1 100644 --- a/lib/swiftmailer/lib/classes/Swift/CharacterReader/GenericFixedWidthReader.php +++ b/lib/swiftmailer/lib/classes/Swift/CharacterReader/GenericFixedWidthReader.php @@ -11,10 +11,8 @@ /** * Provides fixed-width byte sizes for reading fixed-width character sets. * - * @package Swift - * @subpackage Encoder - * @author Chris Corbyn - * @author Xavier De Cock + * @author Chris Corbyn + * @author Xavier De Cock */ class Swift_CharacterReader_GenericFixedWidthReader implements Swift_CharacterReader { @@ -28,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) { @@ -38,10 +36,10 @@ class Swift_CharacterReader_GenericFixedWidthReader implements Swift_CharacterRe /** * 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 */ @@ -50,7 +48,7 @@ class Swift_CharacterReader_GenericFixedWidthReader implements Swift_CharacterRe $strlen = strlen($string); // % and / are CPU intensive, so, maybe find a better way $ignored = $strlen % $this->_width; - $ignoredChars = substr($string, - $ignored); + $ignoredChars = $ignored ? substr($string, -$ignored) : ''; $currentMap = $this->_width; return ($strlen - $ignored) / $this->_width; @@ -75,8 +73,8 @@ class Swift_CharacterReader_GenericFixedWidthReader implements Swift_CharacterRe * 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 */ @@ -84,7 +82,7 @@ class Swift_CharacterReader_GenericFixedWidthReader implements Swift_CharacterRe { $needed = $this->_width - $size; - return ($needed > -1) ? $needed : -1; + return $needed > -1 ? $needed : -1; } /** diff --git a/lib/swiftmailer/lib/classes/Swift/CharacterReader/UsAsciiReader.php b/lib/swiftmailer/lib/classes/Swift/CharacterReader/UsAsciiReader.php index 8d03f316d..67da48f6c 100644 --- a/lib/swiftmailer/lib/classes/Swift/CharacterReader/UsAsciiReader.php +++ b/lib/swiftmailer/lib/classes/Swift/CharacterReader/UsAsciiReader.php @@ -11,29 +11,28 @@ /** * Analyzes US-ASCII characters. * - * @package Swift - * @subpackage Encoder - * @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 */ public function getCharPositions($string, $startOffset, &$currentMap, &$ignoredChars) { - $strlen=strlen($string); - $ignoredChars=''; + $strlen = strlen($string); + $ignoredChars = ''; for ($i = 0; $i < $strlen; ++$i) { - if ($string[$i]>"\x07F") { // Invalid char - $currentMap[$i+$startOffset]=$string[$i]; + if ($string[$i] > "\x07F") { + // Invalid char + $currentMap[$i + $startOffset] = $string[$i]; } } @@ -41,9 +40,9 @@ class Swift_CharacterReader_UsAsciiReader implements Swift_CharacterReader } /** - * Returns mapType + * Returns mapType. * - * @return int mapType + * @return int mapType */ public function getMapType() { @@ -58,8 +57,8 @@ class Swift_CharacterReader_UsAsciiReader implements Swift_CharacterReader * A value of zero means this is already a valid character. * A value of -1 means this cannot possibly be a valid character. * - * @param string $bytes - * @param int $size + * @param string $bytes + * @param int $size * * @return int */ @@ -68,9 +67,9 @@ class Swift_CharacterReader_UsAsciiReader implements Swift_CharacterReader $byte = reset($bytes); if (1 == count($bytes) && $byte >= 0x00 && $byte <= 0x7F) { return 0; - } else { - return -1; } + + return -1; } /** diff --git a/lib/swiftmailer/lib/classes/Swift/CharacterReader/Utf8Reader.php b/lib/swiftmailer/lib/classes/Swift/CharacterReader/Utf8Reader.php index 900bad557..22746bd85 100644 --- a/lib/swiftmailer/lib/classes/Swift/CharacterReader/Utf8Reader.php +++ b/lib/swiftmailer/lib/classes/Swift/CharacterReader/Utf8Reader.php @@ -11,89 +11,87 @@ /** * Analyzes UTF-8 characters. * - * @package Swift - * @subpackage Encoder - * @author Chris Corbyn - * @author Xavier De Cock + * @author Chris Corbyn + * @author Xavier De Cock */ class Swift_CharacterReader_Utf8Reader implements Swift_CharacterReader { /** Pre-computed for optimization */ - private static $length_map=array( + private static $length_map = array( // N=0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F, - 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, // 0x0N - 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, // 0x1N - 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, // 0x2N - 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, // 0x3N - 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, // 0x4N - 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, // 0x5N - 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, // 0x6N - 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, // 0x7N - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, // 0x8N - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, // 0x9N - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, // 0xAN - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, // 0xBN - 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, // 0xCN - 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, // 0xDN - 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3, // 0xEN - 4,4,4,4,4,4,4,4,5,5,5,5,6,6,0,0 // 0xFN + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x0N + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x1N + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x2N + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x3N + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x4N + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x5N + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x6N + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x7N + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x8N + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x9N + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0xAN + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0xBN + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, // 0xCN + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, // 0xDN + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // 0xEN + 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 0, 0, // 0xFN ); - private static $s_length_map=array( - "\x00"=>1, "\x01"=>1, "\x02"=>1, "\x03"=>1, "\x04"=>1, "\x05"=>1, "\x06"=>1, "\x07"=>1, - "\x08"=>1, "\x09"=>1, "\x0a"=>1, "\x0b"=>1, "\x0c"=>1, "\x0d"=>1, "\x0e"=>1, "\x0f"=>1, - "\x10"=>1, "\x11"=>1, "\x12"=>1, "\x13"=>1, "\x14"=>1, "\x15"=>1, "\x16"=>1, "\x17"=>1, - "\x18"=>1, "\x19"=>1, "\x1a"=>1, "\x1b"=>1, "\x1c"=>1, "\x1d"=>1, "\x1e"=>1, "\x1f"=>1, - "\x20"=>1, "\x21"=>1, "\x22"=>1, "\x23"=>1, "\x24"=>1, "\x25"=>1, "\x26"=>1, "\x27"=>1, - "\x28"=>1, "\x29"=>1, "\x2a"=>1, "\x2b"=>1, "\x2c"=>1, "\x2d"=>1, "\x2e"=>1, "\x2f"=>1, - "\x30"=>1, "\x31"=>1, "\x32"=>1, "\x33"=>1, "\x34"=>1, "\x35"=>1, "\x36"=>1, "\x37"=>1, - "\x38"=>1, "\x39"=>1, "\x3a"=>1, "\x3b"=>1, "\x3c"=>1, "\x3d"=>1, "\x3e"=>1, "\x3f"=>1, - "\x40"=>1, "\x41"=>1, "\x42"=>1, "\x43"=>1, "\x44"=>1, "\x45"=>1, "\x46"=>1, "\x47"=>1, - "\x48"=>1, "\x49"=>1, "\x4a"=>1, "\x4b"=>1, "\x4c"=>1, "\x4d"=>1, "\x4e"=>1, "\x4f"=>1, - "\x50"=>1, "\x51"=>1, "\x52"=>1, "\x53"=>1, "\x54"=>1, "\x55"=>1, "\x56"=>1, "\x57"=>1, - "\x58"=>1, "\x59"=>1, "\x5a"=>1, "\x5b"=>1, "\x5c"=>1, "\x5d"=>1, "\x5e"=>1, "\x5f"=>1, - "\x60"=>1, "\x61"=>1, "\x62"=>1, "\x63"=>1, "\x64"=>1, "\x65"=>1, "\x66"=>1, "\x67"=>1, - "\x68"=>1, "\x69"=>1, "\x6a"=>1, "\x6b"=>1, "\x6c"=>1, "\x6d"=>1, "\x6e"=>1, "\x6f"=>1, - "\x70"=>1, "\x71"=>1, "\x72"=>1, "\x73"=>1, "\x74"=>1, "\x75"=>1, "\x76"=>1, "\x77"=>1, - "\x78"=>1, "\x79"=>1, "\x7a"=>1, "\x7b"=>1, "\x7c"=>1, "\x7d"=>1, "\x7e"=>1, "\x7f"=>1, - "\x80"=>0, "\x81"=>0, "\x82"=>0, "\x83"=>0, "\x84"=>0, "\x85"=>0, "\x86"=>0, "\x87"=>0, - "\x88"=>0, "\x89"=>0, "\x8a"=>0, "\x8b"=>0, "\x8c"=>0, "\x8d"=>0, "\x8e"=>0, "\x8f"=>0, - "\x90"=>0, "\x91"=>0, "\x92"=>0, "\x93"=>0, "\x94"=>0, "\x95"=>0, "\x96"=>0, "\x97"=>0, - "\x98"=>0, "\x99"=>0, "\x9a"=>0, "\x9b"=>0, "\x9c"=>0, "\x9d"=>0, "\x9e"=>0, "\x9f"=>0, - "\xa0"=>0, "\xa1"=>0, "\xa2"=>0, "\xa3"=>0, "\xa4"=>0, "\xa5"=>0, "\xa6"=>0, "\xa7"=>0, - "\xa8"=>0, "\xa9"=>0, "\xaa"=>0, "\xab"=>0, "\xac"=>0, "\xad"=>0, "\xae"=>0, "\xaf"=>0, - "\xb0"=>0, "\xb1"=>0, "\xb2"=>0, "\xb3"=>0, "\xb4"=>0, "\xb5"=>0, "\xb6"=>0, "\xb7"=>0, - "\xb8"=>0, "\xb9"=>0, "\xba"=>0, "\xbb"=>0, "\xbc"=>0, "\xbd"=>0, "\xbe"=>0, "\xbf"=>0, - "\xc0"=>2, "\xc1"=>2, "\xc2"=>2, "\xc3"=>2, "\xc4"=>2, "\xc5"=>2, "\xc6"=>2, "\xc7"=>2, - "\xc8"=>2, "\xc9"=>2, "\xca"=>2, "\xcb"=>2, "\xcc"=>2, "\xcd"=>2, "\xce"=>2, "\xcf"=>2, - "\xd0"=>2, "\xd1"=>2, "\xd2"=>2, "\xd3"=>2, "\xd4"=>2, "\xd5"=>2, "\xd6"=>2, "\xd7"=>2, - "\xd8"=>2, "\xd9"=>2, "\xda"=>2, "\xdb"=>2, "\xdc"=>2, "\xdd"=>2, "\xde"=>2, "\xdf"=>2, - "\xe0"=>3, "\xe1"=>3, "\xe2"=>3, "\xe3"=>3, "\xe4"=>3, "\xe5"=>3, "\xe6"=>3, "\xe7"=>3, - "\xe8"=>3, "\xe9"=>3, "\xea"=>3, "\xeb"=>3, "\xec"=>3, "\xed"=>3, "\xee"=>3, "\xef"=>3, - "\xf0"=>4, "\xf1"=>4, "\xf2"=>4, "\xf3"=>4, "\xf4"=>4, "\xf5"=>4, "\xf6"=>4, "\xf7"=>4, - "\xf8"=>5, "\xf9"=>5, "\xfa"=>5, "\xfb"=>5, "\xfc"=>6, "\xfd"=>6, "\xfe"=>0, "\xff"=>0, + private static $s_length_map = array( + "\x00" => 1, "\x01" => 1, "\x02" => 1, "\x03" => 1, "\x04" => 1, "\x05" => 1, "\x06" => 1, "\x07" => 1, + "\x08" => 1, "\x09" => 1, "\x0a" => 1, "\x0b" => 1, "\x0c" => 1, "\x0d" => 1, "\x0e" => 1, "\x0f" => 1, + "\x10" => 1, "\x11" => 1, "\x12" => 1, "\x13" => 1, "\x14" => 1, "\x15" => 1, "\x16" => 1, "\x17" => 1, + "\x18" => 1, "\x19" => 1, "\x1a" => 1, "\x1b" => 1, "\x1c" => 1, "\x1d" => 1, "\x1e" => 1, "\x1f" => 1, + "\x20" => 1, "\x21" => 1, "\x22" => 1, "\x23" => 1, "\x24" => 1, "\x25" => 1, "\x26" => 1, "\x27" => 1, + "\x28" => 1, "\x29" => 1, "\x2a" => 1, "\x2b" => 1, "\x2c" => 1, "\x2d" => 1, "\x2e" => 1, "\x2f" => 1, + "\x30" => 1, "\x31" => 1, "\x32" => 1, "\x33" => 1, "\x34" => 1, "\x35" => 1, "\x36" => 1, "\x37" => 1, + "\x38" => 1, "\x39" => 1, "\x3a" => 1, "\x3b" => 1, "\x3c" => 1, "\x3d" => 1, "\x3e" => 1, "\x3f" => 1, + "\x40" => 1, "\x41" => 1, "\x42" => 1, "\x43" => 1, "\x44" => 1, "\x45" => 1, "\x46" => 1, "\x47" => 1, + "\x48" => 1, "\x49" => 1, "\x4a" => 1, "\x4b" => 1, "\x4c" => 1, "\x4d" => 1, "\x4e" => 1, "\x4f" => 1, + "\x50" => 1, "\x51" => 1, "\x52" => 1, "\x53" => 1, "\x54" => 1, "\x55" => 1, "\x56" => 1, "\x57" => 1, + "\x58" => 1, "\x59" => 1, "\x5a" => 1, "\x5b" => 1, "\x5c" => 1, "\x5d" => 1, "\x5e" => 1, "\x5f" => 1, + "\x60" => 1, "\x61" => 1, "\x62" => 1, "\x63" => 1, "\x64" => 1, "\x65" => 1, "\x66" => 1, "\x67" => 1, + "\x68" => 1, "\x69" => 1, "\x6a" => 1, "\x6b" => 1, "\x6c" => 1, "\x6d" => 1, "\x6e" => 1, "\x6f" => 1, + "\x70" => 1, "\x71" => 1, "\x72" => 1, "\x73" => 1, "\x74" => 1, "\x75" => 1, "\x76" => 1, "\x77" => 1, + "\x78" => 1, "\x79" => 1, "\x7a" => 1, "\x7b" => 1, "\x7c" => 1, "\x7d" => 1, "\x7e" => 1, "\x7f" => 1, + "\x80" => 0, "\x81" => 0, "\x82" => 0, "\x83" => 0, "\x84" => 0, "\x85" => 0, "\x86" => 0, "\x87" => 0, + "\x88" => 0, "\x89" => 0, "\x8a" => 0, "\x8b" => 0, "\x8c" => 0, "\x8d" => 0, "\x8e" => 0, "\x8f" => 0, + "\x90" => 0, "\x91" => 0, "\x92" => 0, "\x93" => 0, "\x94" => 0, "\x95" => 0, "\x96" => 0, "\x97" => 0, + "\x98" => 0, "\x99" => 0, "\x9a" => 0, "\x9b" => 0, "\x9c" => 0, "\x9d" => 0, "\x9e" => 0, "\x9f" => 0, + "\xa0" => 0, "\xa1" => 0, "\xa2" => 0, "\xa3" => 0, "\xa4" => 0, "\xa5" => 0, "\xa6" => 0, "\xa7" => 0, + "\xa8" => 0, "\xa9" => 0, "\xaa" => 0, "\xab" => 0, "\xac" => 0, "\xad" => 0, "\xae" => 0, "\xaf" => 0, + "\xb0" => 0, "\xb1" => 0, "\xb2" => 0, "\xb3" => 0, "\xb4" => 0, "\xb5" => 0, "\xb6" => 0, "\xb7" => 0, + "\xb8" => 0, "\xb9" => 0, "\xba" => 0, "\xbb" => 0, "\xbc" => 0, "\xbd" => 0, "\xbe" => 0, "\xbf" => 0, + "\xc0" => 2, "\xc1" => 2, "\xc2" => 2, "\xc3" => 2, "\xc4" => 2, "\xc5" => 2, "\xc6" => 2, "\xc7" => 2, + "\xc8" => 2, "\xc9" => 2, "\xca" => 2, "\xcb" => 2, "\xcc" => 2, "\xcd" => 2, "\xce" => 2, "\xcf" => 2, + "\xd0" => 2, "\xd1" => 2, "\xd2" => 2, "\xd3" => 2, "\xd4" => 2, "\xd5" => 2, "\xd6" => 2, "\xd7" => 2, + "\xd8" => 2, "\xd9" => 2, "\xda" => 2, "\xdb" => 2, "\xdc" => 2, "\xdd" => 2, "\xde" => 2, "\xdf" => 2, + "\xe0" => 3, "\xe1" => 3, "\xe2" => 3, "\xe3" => 3, "\xe4" => 3, "\xe5" => 3, "\xe6" => 3, "\xe7" => 3, + "\xe8" => 3, "\xe9" => 3, "\xea" => 3, "\xeb" => 3, "\xec" => 3, "\xed" => 3, "\xee" => 3, "\xef" => 3, + "\xf0" => 4, "\xf1" => 4, "\xf2" => 4, "\xf3" => 4, "\xf4" => 4, "\xf5" => 4, "\xf6" => 4, "\xf7" => 4, + "\xf8" => 5, "\xf9" => 5, "\xfa" => 5, "\xfb" => 5, "\xfc" => 6, "\xfd" => 6, "\xfe" => 0, "\xff" => 0, ); /** * 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(); } - $strlen=strlen($string); - $charPos=count($currentMap['p']); - $foundChars=0; - $invalid=false; + $strlen = strlen($string); + $charPos = count($currentMap['p']); + $foundChars = 0; + $invalid = false; for ($i = 0; $i < $strlen; ++$i) { $char = $string[$i]; $size = self::$s_length_map[$char]; @@ -136,7 +134,7 @@ class Swift_CharacterReader_Utf8Reader implements Swift_CharacterReader /** * Returns mapType. * - * @return int mapType + * @return int mapType */ public function getMapType() { @@ -151,22 +149,19 @@ class Swift_CharacterReader_Utf8Reader implements Swift_CharacterReader * A value of zero means this is already a valid character. * A value of -1 means this cannot possibly be a valid character. * - * @param 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/lib/swiftmailer/lib/classes/Swift/CharacterReaderFactory.php b/lib/swiftmailer/lib/classes/Swift/CharacterReaderFactory.php index d653b8131..15b6c6920 100644 --- a/lib/swiftmailer/lib/classes/Swift/CharacterReaderFactory.php +++ b/lib/swiftmailer/lib/classes/Swift/CharacterReaderFactory.php @@ -11,9 +11,7 @@ /** * A factory for creating CharacterReaders. * - * @package Swift - * @subpackage Encoder - * @author Chris Corbyn + * @author Chris Corbyn */ interface Swift_CharacterReaderFactory { diff --git a/lib/swiftmailer/lib/classes/Swift/CharacterReaderFactory/SimpleCharacterReaderFactory.php b/lib/swiftmailer/lib/classes/Swift/CharacterReaderFactory/SimpleCharacterReaderFactory.php index d74b2c539..9171a0bac 100644 --- a/lib/swiftmailer/lib/classes/Swift/CharacterReaderFactory/SimpleCharacterReaderFactory.php +++ b/lib/swiftmailer/lib/classes/Swift/CharacterReaderFactory/SimpleCharacterReaderFactory.php @@ -11,9 +11,7 @@ /** * Standard factory for creating CharacterReaders. * - * @package Swift - * @subpackage Encoder - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_CharacterReaderFactory_SimpleCharacterReaderFactory implements Swift_CharacterReaderFactory { @@ -53,24 +51,24 @@ class Swift_CharacterReaderFactory_SimpleCharacterReaderFactory implements Swift $prefix = 'Swift_CharacterReader_'; $singleByte = array( - 'class' => $prefix . 'GenericFixedWidthReader', - 'constructor' => array(1) + 'class' => $prefix.'GenericFixedWidthReader', + 'constructor' => array(1), ); $doubleByte = array( - 'class' => $prefix . 'GenericFixedWidthReader', - 'constructor' => array(2) + 'class' => $prefix.'GenericFixedWidthReader', + 'constructor' => array(2), ); $fourBytes = array( - 'class' => $prefix . 'GenericFixedWidthReader', - 'constructor' => array(4) + 'class' => $prefix.'GenericFixedWidthReader', + 'constructor' => array(4), ); // Utf-8 self::$_map['utf-?8'] = array( - 'class' => $prefix . 'Utf8Reader', - 'constructor' => array() + 'class' => $prefix.'Utf8Reader', + 'constructor' => array(), ); //7-8 bit charsets @@ -107,7 +105,7 @@ class Swift_CharacterReaderFactory_SimpleCharacterReaderFactory implements Swift { $charset = trim(strtolower($charset)); foreach (self::$_map as $pattern => $spec) { - $re = '/^' . $pattern . '$/D'; + $re = '/^'.$pattern.'$/D'; if (preg_match($re, $charset)) { if (!array_key_exists($pattern, self::$_loaded)) { $reflector = new ReflectionClass($spec['class']); diff --git a/lib/swiftmailer/lib/classes/Swift/CharacterStream.php b/lib/swiftmailer/lib/classes/Swift/CharacterStream.php index a0f0721c2..717924f5d 100644 --- a/lib/swiftmailer/lib/classes/Swift/CharacterStream.php +++ b/lib/swiftmailer/lib/classes/Swift/CharacterStream.php @@ -15,9 +15,7 @@ * Classes implementing this interface may use a subsystem which requires less * memory than working with large strings of data. * - * @package Swift - * @subpackage CharacterStream - * @author Chris Corbyn + * @author Chris Corbyn */ interface Swift_CharacterStream { @@ -54,7 +52,7 @@ interface Swift_CharacterStream * Read $length characters from the stream and move the internal pointer * $length further into the stream. * - * @param int $length + * @param int $length * * @return string */ @@ -64,7 +62,7 @@ interface Swift_CharacterStream * Read $length characters from the stream and return a 1-dimensional array * containing there octet values. * - * @param int $length + * @param int $length * * @return int[] */ @@ -80,7 +78,7 @@ interface Swift_CharacterStream /** * Move the internal pointer to $charOffset in the stream. * - * @param int $charOffset + * @param int $charOffset */ public function setPointer($charOffset); diff --git a/lib/swiftmailer/lib/classes/Swift/CharacterStream/ArrayCharacterStream.php b/lib/swiftmailer/lib/classes/Swift/CharacterStream/ArrayCharacterStream.php index 17f32c0cf..7213a40d7 100644 --- a/lib/swiftmailer/lib/classes/Swift/CharacterStream/ArrayCharacterStream.php +++ b/lib/swiftmailer/lib/classes/Swift/CharacterStream/ArrayCharacterStream.php @@ -11,9 +11,7 @@ /** * A CharacterStream implementation which stores characters in an internal array. * - * @package Swift - * @subpackage CharacterStream - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_CharacterStream_ArrayCharacterStream implements Swift_CharacterStream { @@ -97,8 +95,7 @@ class Swift_CharacterStream_ArrayCharacterStream implements Swift_CharacterStrea $need = $this->_charReader ->validateByteSequence($c, $size); if ($need > 0 && - false !== $bytes = $os->read($need)) - { + false !== $bytes = $os->read($need)) { for ($i = 0, $len = strlen($bytes); $i < $len; ++$i) { $c[] = self::$_byteMap[$bytes[$i]]; } @@ -124,7 +121,7 @@ class Swift_CharacterStream_ArrayCharacterStream implements Swift_CharacterStrea * Read $length characters from the stream and move the internal pointer * $length further into the stream. * - * @param int $length + * @param int $length * * @return string */ @@ -156,9 +153,9 @@ class Swift_CharacterStream_ArrayCharacterStream implements Swift_CharacterStrea * Read $length characters from the stream and return a 1-dimensional array * containing there octet values. * - * @param int $length + * @param int $length * - * @return integer[] + * @return int[] */ public function readBytes($length) { @@ -247,7 +244,7 @@ class Swift_CharacterStream_ArrayCharacterStream implements Swift_CharacterStrea /** * Move the internal pointer to $charOffset in the stream. * - * @param int $charOffset + * @param int $charOffset */ public function setPointer($charOffset) { diff --git a/lib/swiftmailer/lib/classes/Swift/CharacterStream/NgCharacterStream.php b/lib/swiftmailer/lib/classes/Swift/CharacterStream/NgCharacterStream.php index d43c4e0ca..58bd140fd 100644 --- a/lib/swiftmailer/lib/classes/Swift/CharacterStream/NgCharacterStream.php +++ b/lib/swiftmailer/lib/classes/Swift/CharacterStream/NgCharacterStream.php @@ -11,11 +11,8 @@ /** * A CharacterStream implementation which stores characters in an internal array. * - * @package Swift - * @subpackage CharacterStream - * @author Xavier De Cock + * @author Xavier De Cock */ - class Swift_CharacterStream_NgCharacterStream implements Swift_CharacterStream { /** @@ -47,7 +44,7 @@ class Swift_CharacterStream_NgCharacterStream implements Swift_CharacterStream private $_datas = ''; /** - * Number of bytes in the stream + * Number of bytes in the stream. * * @var int */ @@ -137,10 +134,11 @@ class Swift_CharacterStream_NgCharacterStream implements Swift_CharacterStream public function importByteStream(Swift_OutputByteStream $os) { $this->flushContents(); - $blocks=512; + $blocks = 512; $os->setReadPointer(0); - while(false!==($read = $os->read($blocks))) + while (false !== ($read = $os->read($blocks))) { $this->write($read); + } } /** @@ -157,22 +155,20 @@ class Swift_CharacterStream_NgCharacterStream implements Swift_CharacterStream /** * @see Swift_CharacterStream::read() * - * @param int $length + * @param int $length * * @return string */ public function read($length) { - if ($this->_currentPos>=$this->_charCount) { - return false; + if ($this->_currentPos >= $this->_charCount) { + return false; } - $ret=false; - $length = ($this->_currentPos+$length > $this->_charCount) - ? $this->_charCount - $this->_currentPos - : $length; - switch ($this->_mapType) { + $ret = false; + $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); @@ -180,13 +176,9 @@ class Swift_CharacterStream_NgCharacterStream implements Swift_CharacterStream break; case Swift_CharacterReader::MAP_TYPE_INVALID: - $end = $this->_currentPos + $length; - $end = $end > $this->_charCount - ?$this->_charCount - :$end; $ret = ''; for (; $this->_currentPos < $length; ++$this->_currentPos) { - if (isset ($this->_map[$this->_currentPos])) { + if (isset($this->_map[$this->_currentPos])) { $ret .= '?'; } else { $ret .= $this->_datas[$this->_currentPos]; @@ -196,13 +188,11 @@ class Swift_CharacterStream_NgCharacterStream implements Swift_CharacterStream case Swift_CharacterReader::MAP_TYPE_POSITIONS: $end = $this->_currentPos + $length; - $end = $end > $this->_charCount - ?$this->_charCount - :$end; + $end = $end > $this->_charCount ? $this->_charCount : $end; $ret = ''; $start = 0; - if ($this->_currentPos>0) { - $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) { @@ -223,14 +213,14 @@ class Swift_CharacterStream_NgCharacterStream implements Swift_CharacterStream /** * @see Swift_CharacterStream::readBytes() * - * @param int $length + * @param int $length * - * @return integer[] + * @return int[] */ public function readBytes($length) { - $read=$this->read($length); - if ($read!==false) { + $read = $this->read($length); + if ($read !== false) { $ret = array_map('ord', str_split($read, 1)); return $ret; @@ -242,12 +232,12 @@ class Swift_CharacterStream_NgCharacterStream implements Swift_CharacterStream /** * @see Swift_CharacterStream::setPointer() * - * @param int $charOffset + * @param int $charOffset */ public function setPointer($charOffset) { - if ($this->_charCount<$charOffset) { - $charOffset=$this->_charCount; + if ($this->_charCount < $charOffset) { + $charOffset = $this->_charCount; } $this->_currentPos = $charOffset; } @@ -265,13 +255,13 @@ class Swift_CharacterStream_NgCharacterStream implements Swift_CharacterStream $this->_map = array(); $this->_mapType = $this->_charReader->getMapType(); } - $ignored=''; + $ignored = ''; $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); + if ($ignored !== false) { + $this->_datasSize = strlen($this->_datas) - strlen($ignored); } else { - $this->_datasSize=strlen($this->_datas); + $this->_datasSize = strlen($this->_datas); } } } diff --git a/lib/swiftmailer/lib/classes/Swift/ConfigurableSpool.php b/lib/swiftmailer/lib/classes/Swift/ConfigurableSpool.php index 11179f8da..4ae5bacfc 100644 --- a/lib/swiftmailer/lib/classes/Swift/ConfigurableSpool.php +++ b/lib/swiftmailer/lib/classes/Swift/ConfigurableSpool.php @@ -11,8 +11,7 @@ /** * Base class for Spools (implements time and message limits). * - * @package Swift - * @author Fabien Potencier + * @author Fabien Potencier */ abstract class Swift_ConfigurableSpool implements Swift_Spool { @@ -25,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) { @@ -35,7 +34,7 @@ abstract class Swift_ConfigurableSpool implements Swift_Spool /** * Gets the maximum number of messages to send per flush. * - * @return int The limit + * @return int The limit */ public function getMessageLimit() { @@ -45,7 +44,7 @@ abstract class Swift_ConfigurableSpool implements Swift_Spool /** * Sets the time limit (in seconds) per flush. * - * @param int $limit The limit + * @param int $limit The limit */ public function setTimeLimit($limit) { @@ -55,7 +54,7 @@ abstract class Swift_ConfigurableSpool implements Swift_Spool /** * Gets the time limit (in seconds) per flush. * - * @return int The limit + * @return int The limit */ public function getTimeLimit() { diff --git a/lib/swiftmailer/lib/classes/Swift/DependencyContainer.php b/lib/swiftmailer/lib/classes/Swift/DependencyContainer.php index 2f9a77432..befec9ac0 100644 --- a/lib/swiftmailer/lib/classes/Swift/DependencyContainer.php +++ b/lib/swiftmailer/lib/classes/Swift/DependencyContainer.php @@ -11,8 +11,7 @@ /** * Dependency Injection container. * - * @package Swift - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_DependencyContainer { @@ -42,12 +41,14 @@ class Swift_DependencyContainer * * Use {@link getInstance()} instead. */ - public function __construct() { } + public function __construct() + { + } /** * Returns a singleton of the DependencyContainer. * - * @return Swift_DependencyContainer + * @return self */ public static function getInstance() { @@ -90,15 +91,15 @@ class Swift_DependencyContainer * * @param string $itemName * - * @return mixed - * * @throws Swift_DependencyException If the dependency is not found + * + * @return mixed */ public function lookup($itemName) { if (!$this->has($itemName)) { throw new Swift_DependencyException( - 'Cannot lookup dependency "' . $itemName . '" since it is not registered.' + 'Cannot lookup dependency "'.$itemName.'" since it is not registered.' ); } @@ -137,16 +138,17 @@ class Swift_DependencyContainer * This method returns the current DependencyContainer instance because it * requires the use of the fluid interface to set the specific details for the * dependency. + * * @see asNewInstanceOf(), asSharedInstanceOf(), asValue() * * @param string $itemName * - * @return Swift_DependencyContainer + * @return $this */ public function register($itemName) { $this->_store[$itemName] = array(); - $this->_endPoint =& $this->_store[$itemName]; + $this->_endPoint = &$this->_store[$itemName]; return $this; } @@ -158,11 +160,11 @@ class Swift_DependencyContainer * * @param mixed $value * - * @return Swift_DependencyContainer + * @return $this */ public function asValue($value) { - $endPoint =& $this->_getEndPoint(); + $endPoint = &$this->_getEndPoint(); $endPoint['lookupType'] = self::TYPE_VALUE; $endPoint['value'] = $value; @@ -174,11 +176,11 @@ class Swift_DependencyContainer * * @param string $lookup * - * @return Swift_DependencyContainer + * @return $this */ public function asAliasOf($lookup) { - $endPoint =& $this->_getEndPoint(); + $endPoint = &$this->_getEndPoint(); $endPoint['lookupType'] = self::TYPE_ALIAS; $endPoint['ref'] = $lookup; @@ -196,11 +198,11 @@ class Swift_DependencyContainer * * @param string $className * - * @return Swift_DependencyContainer + * @return $this */ public function asNewInstanceOf($className) { - $endPoint =& $this->_getEndPoint(); + $endPoint = &$this->_getEndPoint(); $endPoint['lookupType'] = self::TYPE_INSTANCE; $endPoint['className'] = $className; @@ -214,11 +216,11 @@ class Swift_DependencyContainer * * @param string $className * - * @return Swift_DependencyContainer + * @return $this */ public function asSharedInstanceOf($className) { - $endPoint =& $this->_getEndPoint(); + $endPoint = &$this->_getEndPoint(); $endPoint['lookupType'] = self::TYPE_SHARED; $endPoint['className'] = $className; @@ -234,11 +236,11 @@ class Swift_DependencyContainer * * @param array $lookups * - * @return Swift_DependencyContainer + * @return $this */ public function withDependencies(array $lookups) { - $endPoint =& $this->_getEndPoint(); + $endPoint = &$this->_getEndPoint(); $endPoint['args'] = array(); foreach ($lookups as $lookup) { $this->addConstructorLookup($lookup); @@ -255,11 +257,11 @@ class Swift_DependencyContainer * * @param mixed $value * - * @return Swift_DependencyContainer + * @return $this */ public function addConstructorValue($value) { - $endPoint =& $this->_getEndPoint(); + $endPoint = &$this->_getEndPoint(); if (!isset($endPoint['args'])) { $endPoint['args'] = array(); } @@ -276,11 +278,11 @@ class Swift_DependencyContainer * * @param string $lookup * - * @return Swift_DependencyContainer + * @return $this */ public function addConstructorLookup($lookup) { - $endPoint =& $this->_getEndPoint(); + $endPoint = &$this->_getEndPoint(); if (!isset($this->_endPoint['args'])) { $endPoint['args'] = array(); } @@ -289,8 +291,6 @@ class Swift_DependencyContainer return $this; } - // -- Private methods - /** Get the literal value with $itemName */ private function _getValue($itemName) { @@ -311,9 +311,9 @@ class Swift_DependencyContainer return $reflector->newInstanceArgs( $this->createDependenciesFor($itemName) ); - } else { - return $reflector->newInstance(); } + + return $reflector->newInstance(); } /** Create and register a shared instance of $itemName */ @@ -366,8 +366,8 @@ class Swift_DependencyContainer } return $collection; - } else { - return $this->lookup($item); } + + return $this->lookup($item); } } diff --git a/lib/swiftmailer/lib/classes/Swift/DependencyException.php b/lib/swiftmailer/lib/classes/Swift/DependencyException.php index b3f017094..799d38d83 100644 --- a/lib/swiftmailer/lib/classes/Swift/DependencyException.php +++ b/lib/swiftmailer/lib/classes/Swift/DependencyException.php @@ -11,8 +11,7 @@ /** * DependencyException gets thrown when a requested dependency is missing. * - * @package Swift - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_DependencyException extends Swift_SwiftException { diff --git a/lib/swiftmailer/lib/classes/Swift/EmbeddedFile.php b/lib/swiftmailer/lib/classes/Swift/EmbeddedFile.php index a39a3478a..d8c72ad4d 100644 --- a/lib/swiftmailer/lib/classes/Swift/EmbeddedFile.php +++ b/lib/swiftmailer/lib/classes/Swift/EmbeddedFile.php @@ -11,9 +11,7 @@ /** * An embedded file, in a multipart message. * - * @package Swift - * @subpackage Mime - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_EmbeddedFile extends Swift_Mime_EmbeddedFile { diff --git a/lib/swiftmailer/lib/classes/Swift/Encoder.php b/lib/swiftmailer/lib/classes/Swift/Encoder.php index 2ad62e6cb..2073abca1 100644 --- a/lib/swiftmailer/lib/classes/Swift/Encoder.php +++ b/lib/swiftmailer/lib/classes/Swift/Encoder.php @@ -10,8 +10,7 @@ /** * Interface for all Encoder schemes. - * @package Swift - * @subpackage Encoder + * * @author Chris Corbyn */ interface Swift_Encoder extends Swift_Mime_CharsetObserver @@ -19,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/lib/swiftmailer/lib/classes/Swift/Encoder/Base64Encoder.php b/lib/swiftmailer/lib/classes/Swift/Encoder/Base64Encoder.php index 63e473136..0e7b2a1b0 100644 --- a/lib/swiftmailer/lib/classes/Swift/Encoder/Base64Encoder.php +++ b/lib/swiftmailer/lib/classes/Swift/Encoder/Base64Encoder.php @@ -11,9 +11,7 @@ /** * Handles Base 64 Encoding in Swift Mailer. * - * @package Swift - * @subpackage Encoder - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_Encoder_Base64Encoder implements Swift_Encoder { @@ -24,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 */ @@ -42,13 +40,13 @@ class Swift_Encoder_Base64Encoder implements Swift_Encoder if (0 != $firstLineOffset) { $firstLine = substr( $encodedString, 0, $maxLineLength - $firstLineOffset - ) . "\r\n"; + )."\r\n"; $encodedString = substr( $encodedString, $maxLineLength - $firstLineOffset ); } - return $firstLine . trim(chunk_split($encodedString, $maxLineLength, "\r\n")); + return $firstLine.trim(chunk_split($encodedString, $maxLineLength, "\r\n")); } /** diff --git a/lib/swiftmailer/lib/classes/Swift/Encoder/QpEncoder.php b/lib/swiftmailer/lib/classes/Swift/Encoder/QpEncoder.php index 3c362ed57..edec10c51 100644 --- a/lib/swiftmailer/lib/classes/Swift/Encoder/QpEncoder.php +++ b/lib/swiftmailer/lib/classes/Swift/Encoder/QpEncoder.php @@ -13,9 +13,7 @@ * * Possibly the most accurate RFC 2045 QP implementation found in PHP. * - * @package Swift - * @subpackage Encoder - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_Encoder_QpEncoder implements Swift_Encoder { @@ -39,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', @@ -90,7 +88,7 @@ class Swift_Encoder_QpEncoder implements Swift_Encoder 240 => '=F0', 241 => '=F1', 242 => '=F2', 243 => '=F3', 244 => '=F4', 245 => '=F5', 246 => '=F6', 247 => '=F7', 248 => '=F8', 249 => '=F9', 250 => '=FA', 251 => '=FB', 252 => '=FC', 253 => '=FD', 254 => '=FE', - 255 => '=FF' + 255 => '=FF', ); protected static $_safeMapShare = array(); @@ -143,8 +141,7 @@ class Swift_Encoder_QpEncoder implements Swift_Encoder protected function initSafeMap() { foreach (array_merge( - array(0x09, 0x20), range(0x21, 0x3C), range(0x3E, 0x7E)) as $byte) - { + array(0x09, 0x20), range(0x21, 0x3C), range(0x3E, 0x7E)) as $byte) { $this->_safeMap[$byte] = chr($byte); } } @@ -156,9 +153,9 @@ class Swift_Encoder_QpEncoder implements Swift_Encoder * 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 */ @@ -173,8 +170,8 @@ class Swift_Encoder_QpEncoder implements Swift_Encoder $lines = array(); $lNo = 0; $lines[$lNo] = ''; - $currentLine =& $lines[$lNo++]; - $size=$lineLen=0; + $currentLine = &$lines[$lNo++]; + $size = $lineLen = 0; $this->_charStream->flushContents(); $this->_charStream->importString($string); @@ -201,14 +198,25 @@ class Swift_Encoder_QpEncoder implements Swift_Encoder } $enc = $this->_encodeByteSequence($bytes, $size); - if ($currentLine && $lineLen+$size >= $thisLineLength) { + + $i = strpos($enc, '=0D=0A'); + $newLineLength = $lineLen + ($i === false ? $size : $i); + + if ($currentLine && $newLineLength >= $thisLineLength) { $lines[$lNo] = ''; - $currentLine =& $lines[$lNo++]; + $currentLine = &$lines[$lNo++]; $thisLineLength = $maxLineLength; - $lineLen=0; + $lineLen = 0; } - $lineLen+=$size; + $currentLine .= $enc; + + if ($i === false) { + $lineLen += $size; + } else { + // 6 is the length of '=0D=0A'. + $lineLen = $size - strrpos($enc, '=0D=0A') - 6; + } } return $this->_standardize(implode("=\r\n", $lines)); @@ -224,27 +232,25 @@ class Swift_Encoder_QpEncoder implements Swift_Encoder $this->_charStream->setCharacterSet($charset); } - // -- Protected methods - /** * Encode the given byte array into a verbatim QP form. * - * @param integer[] $bytes - * @param int $size + * @param int[] $bytes + * @param int $size * * @return string */ protected function _encodeByteSequence(array $bytes, &$size) { $ret = ''; - $size=0; + $size = 0; foreach ($bytes as $b) { if (isset($this->_safeMap[$b])) { $ret .= $this->_safeMap[$b]; ++$size; } else { $ret .= self::$_qpMap[$b]; - $size+=3; + $size += 3; } } @@ -254,9 +260,9 @@ class Swift_Encoder_QpEncoder implements Swift_Encoder /** * 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[] + * @return int[] */ protected function _nextSequence($size = 4) { @@ -272,7 +278,7 @@ class Swift_Encoder_QpEncoder implements Swift_Encoder */ protected function _standardize($string) { - $string = str_replace(array("\t=0D=0A", " =0D=0A", "=0D=0A"), + $string = str_replace(array("\t=0D=0A", ' =0D=0A', '=0D=0A'), array("=09\r\n", "=20\r\n", "\r\n"), $string ); switch ($end = ord(substr($string, -1))) { @@ -283,4 +289,12 @@ class Swift_Encoder_QpEncoder implements Swift_Encoder return $string; } + + /** + * Make a deep copy of object. + */ + public function __clone() + { + $this->_charStream = clone $this->_charStream; + } } diff --git a/lib/swiftmailer/lib/classes/Swift/Encoder/Rfc2231Encoder.php b/lib/swiftmailer/lib/classes/Swift/Encoder/Rfc2231Encoder.php index aa914a89d..b0215e883 100644 --- a/lib/swiftmailer/lib/classes/Swift/Encoder/Rfc2231Encoder.php +++ b/lib/swiftmailer/lib/classes/Swift/Encoder/Rfc2231Encoder.php @@ -11,9 +11,7 @@ /** * Handles RFC 2231 specified Encoding in Swift Mailer. * - * @package Swift - * @subpackage Encoder - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_Encoder_Rfc2231Encoder implements Swift_Encoder { @@ -38,17 +36,18 @@ class Swift_Encoder_Rfc2231Encoder implements Swift_Encoder * 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 */ public function encodeString($string, $firstLineOffset = 0, $maxLineLength = 0) { - $lines = array(); $lineCount = 0; + $lines = array(); + $lineCount = 0; $lines[] = ''; - $currentLine =& $lines[$lineCount++]; + $currentLine = &$lines[$lineCount++]; if (0 >= $maxLineLength) { $maxLineLength = 75; @@ -62,10 +61,9 @@ class Swift_Encoder_Rfc2231Encoder implements Swift_Encoder while (false !== $char = $this->_charStream->read(4)) { $encodedChar = rawurlencode($char); if (0 != strlen($currentLine) - && strlen($currentLine . $encodedChar) > $thisLineLength) - { + && strlen($currentLine.$encodedChar) > $thisLineLength) { $lines[] = ''; - $currentLine =& $lines[$lineCount++]; + $currentLine = &$lines[$lineCount++]; $thisLineLength = $maxLineLength; } $currentLine .= $encodedChar; @@ -83,4 +81,12 @@ class Swift_Encoder_Rfc2231Encoder implements Swift_Encoder { $this->_charStream->setCharacterSet($charset); } + + /** + * Make a deep copy of object. + */ + public function __clone() + { + $this->_charStream = clone $this->_charStream; + } } diff --git a/lib/swiftmailer/lib/classes/Swift/Encoding.php b/lib/swiftmailer/lib/classes/Swift/Encoding.php index 96391949c..245878706 100644 --- a/lib/swiftmailer/lib/classes/Swift/Encoding.php +++ b/lib/swiftmailer/lib/classes/Swift/Encoding.php @@ -11,9 +11,7 @@ /** * Provides quick access to each encoding type. * - * @package Swift - * @subpackage Encoder - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_Encoding { @@ -57,8 +55,6 @@ class Swift_Encoding return self::_lookup('mime.base64contentencoder'); } - // -- Private Static Methods - private static function _lookup($key) { return Swift_DependencyContainer::getInstance()->lookup($key); diff --git a/lib/swiftmailer/lib/classes/Swift/Events/CommandEvent.php b/lib/swiftmailer/lib/classes/Swift/Events/CommandEvent.php index fa4f44470..674e6b5e4 100644 --- a/lib/swiftmailer/lib/classes/Swift/Events/CommandEvent.php +++ b/lib/swiftmailer/lib/classes/Swift/Events/CommandEvent.php @@ -11,9 +11,7 @@ /** * Generated when a command is sent over an SMTP connection. * - * @package Swift - * @subpackage Events - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_Events_CommandEvent extends Swift_Events_EventObject { @@ -27,7 +25,7 @@ class Swift_Events_CommandEvent extends Swift_Events_EventObject /** * An array of codes which a successful response will contain. * - * @var integer[] + * @var int[] */ private $_successCodes = array(); @@ -58,7 +56,7 @@ class Swift_Events_CommandEvent extends Swift_Events_EventObject /** * Get the numeric response codes which indicate success for this command. * - * @return integer[] + * @return int[] */ public function getSuccessCodes() { diff --git a/lib/swiftmailer/lib/classes/Swift/Events/CommandListener.php b/lib/swiftmailer/lib/classes/Swift/Events/CommandListener.php index 68009047f..7545404e7 100644 --- a/lib/swiftmailer/lib/classes/Swift/Events/CommandListener.php +++ b/lib/swiftmailer/lib/classes/Swift/Events/CommandListener.php @@ -11,9 +11,7 @@ /** * Listens for Transports to send commands to the server. * - * @package Swift - * @subpackage Events - * @author Chris Corbyn + * @author Chris Corbyn */ interface Swift_Events_CommandListener extends Swift_Events_EventListener { diff --git a/lib/swiftmailer/lib/classes/Swift/Events/Event.php b/lib/swiftmailer/lib/classes/Swift/Events/Event.php index c93bd9936..720b15637 100644 --- a/lib/swiftmailer/lib/classes/Swift/Events/Event.php +++ b/lib/swiftmailer/lib/classes/Swift/Events/Event.php @@ -11,9 +11,7 @@ /** * The minimum interface for an Event. * - * @package Swift - * @subpackage Events - * @author Chris Corbyn + * @author Chris Corbyn */ interface Swift_Events_Event { @@ -27,7 +25,7 @@ interface Swift_Events_Event /** * 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/lib/swiftmailer/lib/classes/Swift/Events/EventDispatcher.php b/lib/swiftmailer/lib/classes/Swift/Events/EventDispatcher.php index 59aeac855..aac36aaa7 100644 --- a/lib/swiftmailer/lib/classes/Swift/Events/EventDispatcher.php +++ b/lib/swiftmailer/lib/classes/Swift/Events/EventDispatcher.php @@ -11,9 +11,7 @@ /** * Interface for the EventDispatcher which handles the event dispatching layer. * - * @package Swift - * @subpackage Events - * @author Chris Corbyn + * @author Chris Corbyn */ interface Swift_Events_EventDispatcher { diff --git a/lib/swiftmailer/lib/classes/Swift/Events/EventListener.php b/lib/swiftmailer/lib/classes/Swift/Events/EventListener.php index bb2133145..512909541 100644 --- a/lib/swiftmailer/lib/classes/Swift/Events/EventListener.php +++ b/lib/swiftmailer/lib/classes/Swift/Events/EventListener.php @@ -11,9 +11,7 @@ /** * An identity interface which all EventListeners must extend. * - * @package Swift - * @subpackage Events - * @author Chris Corbyn + * @author Chris Corbyn */ interface Swift_Events_EventListener { diff --git a/lib/swiftmailer/lib/classes/Swift/Events/EventObject.php b/lib/swiftmailer/lib/classes/Swift/Events/EventObject.php index 30526ce2d..90694a9a6 100644 --- a/lib/swiftmailer/lib/classes/Swift/Events/EventObject.php +++ b/lib/swiftmailer/lib/classes/Swift/Events/EventObject.php @@ -11,9 +11,7 @@ /** * A base Event which all Event classes inherit from. * - * @package Swift - * @subpackage Events - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_Events_EventObject implements Swift_Events_Event { @@ -46,7 +44,7 @@ class Swift_Events_EventObject implements Swift_Events_Event /** * 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/lib/swiftmailer/lib/classes/Swift/Events/ResponseEvent.php b/lib/swiftmailer/lib/classes/Swift/Events/ResponseEvent.php index 6d7eb2710..2e92ba940 100644 --- a/lib/swiftmailer/lib/classes/Swift/Events/ResponseEvent.php +++ b/lib/swiftmailer/lib/classes/Swift/Events/ResponseEvent.php @@ -11,9 +11,7 @@ /** * Generated when a response is received on a SMTP connection. * - * @package Swift - * @subpackage Events - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_Events_ResponseEvent extends Swift_Events_EventObject { @@ -64,5 +62,4 @@ class Swift_Events_ResponseEvent extends Swift_Events_EventObject { return $this->_valid; } - } diff --git a/lib/swiftmailer/lib/classes/Swift/Events/ResponseListener.php b/lib/swiftmailer/lib/classes/Swift/Events/ResponseListener.php index a39ba435c..c40919d21 100644 --- a/lib/swiftmailer/lib/classes/Swift/Events/ResponseListener.php +++ b/lib/swiftmailer/lib/classes/Swift/Events/ResponseListener.php @@ -11,9 +11,7 @@ /** * Listens for responses from a remote SMTP server. * - * @package Swift - * @subpackage Events - * @author Chris Corbyn + * @author Chris Corbyn */ interface Swift_Events_ResponseListener extends Swift_Events_EventListener { diff --git a/lib/swiftmailer/lib/classes/Swift/Events/SendEvent.php b/lib/swiftmailer/lib/classes/Swift/Events/SendEvent.php index 0e055405d..10da8080f 100644 --- a/lib/swiftmailer/lib/classes/Swift/Events/SendEvent.php +++ b/lib/swiftmailer/lib/classes/Swift/Events/SendEvent.php @@ -11,15 +11,16 @@ /** * Generated when a message is being sent. * - * @package Swift - * @subpackage Events - * @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; @@ -106,7 +107,7 @@ class Swift_Events_SendEvent extends Swift_Events_EventObject /** * Set the result of sending. * - * @param int $result + * @param int $result */ public function setResult($result) { diff --git a/lib/swiftmailer/lib/classes/Swift/Events/SendListener.php b/lib/swiftmailer/lib/classes/Swift/Events/SendListener.php index bc914f542..d922e1bfa 100644 --- a/lib/swiftmailer/lib/classes/Swift/Events/SendListener.php +++ b/lib/swiftmailer/lib/classes/Swift/Events/SendListener.php @@ -11,9 +11,7 @@ /** * Listens for Messages being sent from within the Transport system. * - * @package Swift - * @subpackage Events - * @author Chris Corbyn + * @author Chris Corbyn */ interface Swift_Events_SendListener extends Swift_Events_EventListener { diff --git a/lib/swiftmailer/lib/classes/Swift/Events/SimpleEventDispatcher.php b/lib/swiftmailer/lib/classes/Swift/Events/SimpleEventDispatcher.php index b869481ef..e8aca752f 100644 --- a/lib/swiftmailer/lib/classes/Swift/Events/SimpleEventDispatcher.php +++ b/lib/swiftmailer/lib/classes/Swift/Events/SimpleEventDispatcher.php @@ -11,9 +11,7 @@ /** * The EventDispatcher which handles the event dispatching layer. * - * @package Swift - * @subpackage Events - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_Events_SimpleEventDispatcher implements Swift_Events_EventDispatcher { @@ -36,7 +34,7 @@ class Swift_Events_SimpleEventDispatcher implements Swift_Events_EventDispatcher 'Swift_Events_ResponseEvent' => 'Swift_Events_ResponseListener', 'Swift_Events_SendEvent' => 'Swift_Events_SendListener', 'Swift_Events_TransportChangeEvent' => 'Swift_Events_TransportChangeListener', - 'Swift_Events_TransportExceptionEvent' => 'Swift_Events_TransportExceptionListener' + 'Swift_Events_TransportExceptionEvent' => 'Swift_Events_TransportExceptionListener', ); } @@ -134,8 +132,6 @@ class Swift_Events_SimpleEventDispatcher implements Swift_Events_EventDispatcher $this->_bubble($evt, $target); } - // -- Private methods - /** Queue listeners on a stack ready for $evt to be bubbled up it */ private function _prepareBubbleQueue(Swift_Events_EventObject $evt) { @@ -143,8 +139,7 @@ class Swift_Events_SimpleEventDispatcher implements Swift_Events_EventDispatcher $evtClass = get_class($evt); foreach ($this->_listeners as $listener) { if (array_key_exists($evtClass, $this->_eventMap) - && ($listener instanceof $this->_eventMap[$evtClass])) - { + && ($listener instanceof $this->_eventMap[$evtClass])) { $this->_bubbleQueue[] = $listener; } } diff --git a/lib/swiftmailer/lib/classes/Swift/Events/TransportChangeEvent.php b/lib/swiftmailer/lib/classes/Swift/Events/TransportChangeEvent.php index d8b5316bf..a8972fda9 100644 --- a/lib/swiftmailer/lib/classes/Swift/Events/TransportChangeEvent.php +++ b/lib/swiftmailer/lib/classes/Swift/Events/TransportChangeEvent.php @@ -11,9 +11,7 @@ /** * Generated when the state of a Transport is changed (i.e. stopped/started). * - * @package Swift - * @subpackage Events - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_Events_TransportChangeEvent extends Swift_Events_EventObject { diff --git a/lib/swiftmailer/lib/classes/Swift/Events/TransportChangeListener.php b/lib/swiftmailer/lib/classes/Swift/Events/TransportChangeListener.php index 15550370e..253165de8 100644 --- a/lib/swiftmailer/lib/classes/Swift/Events/TransportChangeListener.php +++ b/lib/swiftmailer/lib/classes/Swift/Events/TransportChangeListener.php @@ -11,9 +11,7 @@ /** * Listens for changes within the Transport system. * - * @package Swift - * @subpackage Events - * @author Chris Corbyn + * @author Chris Corbyn */ interface Swift_Events_TransportChangeListener extends Swift_Events_EventListener { diff --git a/lib/swiftmailer/lib/classes/Swift/Events/TransportExceptionEvent.php b/lib/swiftmailer/lib/classes/Swift/Events/TransportExceptionEvent.php index 88cf4746d..f87154fb9 100644 --- a/lib/swiftmailer/lib/classes/Swift/Events/TransportExceptionEvent.php +++ b/lib/swiftmailer/lib/classes/Swift/Events/TransportExceptionEvent.php @@ -11,9 +11,7 @@ /** * Generated when a TransportException is thrown from the Transport system. * - * @package Swift - * @subpackage Events - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_Events_TransportExceptionEvent extends Swift_Events_EventObject { diff --git a/lib/swiftmailer/lib/classes/Swift/Events/TransportExceptionListener.php b/lib/swiftmailer/lib/classes/Swift/Events/TransportExceptionListener.php index 709abda33..cc3c09937 100644 --- a/lib/swiftmailer/lib/classes/Swift/Events/TransportExceptionListener.php +++ b/lib/swiftmailer/lib/classes/Swift/Events/TransportExceptionListener.php @@ -11,9 +11,7 @@ /** * Listens for Exceptions thrown from within the Transport system. * - * @package Swift - * @subpackage Events - * @author Chris Corbyn + * @author Chris Corbyn */ interface Swift_Events_TransportExceptionListener extends Swift_Events_EventListener { diff --git a/lib/swiftmailer/lib/classes/Swift/FailoverTransport.php b/lib/swiftmailer/lib/classes/Swift/FailoverTransport.php index 22a82c690..9951c5977 100644 --- a/lib/swiftmailer/lib/classes/Swift/FailoverTransport.php +++ b/lib/swiftmailer/lib/classes/Swift/FailoverTransport.php @@ -11,9 +11,7 @@ /** * Contains a list of redundant Transports so when one fails, the next is used. * - * @package Swift - * @subpackage Transport - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_FailoverTransport extends Swift_Transport_FailoverTransport { @@ -38,7 +36,7 @@ class Swift_FailoverTransport extends Swift_Transport_FailoverTransport * * @param Swift_Transport[] $transports * - * @return Swift_FailoverTransport + * @return self */ public static function newInstance($transports = array()) { diff --git a/lib/swiftmailer/lib/classes/Swift/FileSpool.php b/lib/swiftmailer/lib/classes/Swift/FileSpool.php index c2f8d7cff..c82c5dbf1 100644 --- a/lib/swiftmailer/lib/classes/Swift/FileSpool.php +++ b/lib/swiftmailer/lib/classes/Swift/FileSpool.php @@ -11,9 +11,8 @@ /** * Stores Messages on the filesystem. * - * @package Swift - * @author Fabien Potencier - * @author Xavier De Cock + * @author Fabien Potencier + * @author Xavier De Cock */ class Swift_FileSpool extends Swift_ConfigurableSpool { @@ -21,11 +20,11 @@ class Swift_FileSpool extends Swift_ConfigurableSpool private $_path; /** - * File WriteRetry Limit + * File WriteRetry Limit. * * @var int */ - private $_retryLimit=10; + private $_retryLimit = 10; /** * Create a new FileSpool. @@ -40,7 +39,7 @@ class Swift_FileSpool extends Swift_ConfigurableSpool if (!file_exists($this->_path)) { if (!mkdir($this->_path, 0777, true)) { - throw new Swift_IoException('Unable to create Path ['.$this->_path.']'); + throw new Swift_IoException(sprintf('Unable to create path "%s".', $this->_path)); } } } @@ -74,11 +73,11 @@ class Swift_FileSpool extends Swift_ConfigurableSpool * * Default, is ten and allows over 64^20 different fileNames * - * @param int $limit + * @param int $limit */ public function setRetryLimit($limit) { - $this->_retryLimit=$limit; + $this->_retryLimit = $limit; } /** @@ -86,17 +85,17 @@ class Swift_FileSpool extends Swift_ConfigurableSpool * * @param Swift_Mime_Message $message The message to store * - * @return bool - * * @throws Swift_IoException + * + * @return bool */ public function queueMessage(Swift_Mime_Message $message) { $ser = serialize($message); - $fileName = $this->_path . '/' . $this->getRandomString(10); + $fileName = $this->_path.'/'.$this->getRandomString(10); for ($i = 0; $i < $this->_retryLimit; ++$i) { /* We try an exclusive creation of the file. This is an atomic operation, it avoid locking mechanism */ - $fp = @fopen($fileName . '.message', 'x'); + $fp = @fopen($fileName.'.message', 'x'); if (false !== $fp) { if (false === fwrite($fp, $ser)) { return false; @@ -109,23 +108,23 @@ class Swift_FileSpool extends Swift_ConfigurableSpool } } - throw new Swift_IoException('Unable to create a file for enqueuing Message'); + throw new Swift_IoException(sprintf('Unable to create a file for enqueuing Message in "%s".', $this->_path)); } /** * 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)); } } } @@ -137,7 +136,7 @@ class Swift_FileSpool extends Swift_ConfigurableSpool * @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) { @@ -190,14 +189,14 @@ class Swift_FileSpool extends Swift_ConfigurableSpool /** * 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/lib/swiftmailer/lib/classes/Swift/FileStream.php b/lib/swiftmailer/lib/classes/Swift/FileStream.php index 567633ecd..0b24db1ce 100644 --- a/lib/swiftmailer/lib/classes/Swift/FileStream.php +++ b/lib/swiftmailer/lib/classes/Swift/FileStream.php @@ -11,9 +11,7 @@ /** * An OutputByteStream which specifically reads from a file. * - * @package Swift - * @subpackage ByteStream - * @author Chris Corbyn + * @author Chris Corbyn */ interface Swift_FileStream extends Swift_OutputByteStream { diff --git a/lib/swiftmailer/lib/classes/Swift/Filterable.php b/lib/swiftmailer/lib/classes/Swift/Filterable.php index 64ad3b56c..6b75b5274 100644 --- a/lib/swiftmailer/lib/classes/Swift/Filterable.php +++ b/lib/swiftmailer/lib/classes/Swift/Filterable.php @@ -11,8 +11,7 @@ /** * Allows StreamFilters to operate on a stream. * - * @package Swift - * @author Chris Corbyn + * @author Chris Corbyn */ interface Swift_Filterable { diff --git a/lib/swiftmailer/lib/classes/Swift/Image.php b/lib/swiftmailer/lib/classes/Swift/Image.php index ccc485ddd..4213ee27e 100644 --- a/lib/swiftmailer/lib/classes/Swift/Image.php +++ b/lib/swiftmailer/lib/classes/Swift/Image.php @@ -11,9 +11,7 @@ /** * An image, embedded in a multipart message. * - * @package Swift - * @subpackage Mime - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_Image extends Swift_EmbeddedFile { @@ -38,7 +36,7 @@ class Swift_Image extends Swift_EmbeddedFile * @param string $filename * @param string $contentType * - * @return Swift_Image + * @return self */ public static function newInstance($data = null, $filename = null, $contentType = null) { @@ -50,14 +48,10 @@ class Swift_Image extends Swift_EmbeddedFile * * @param string $path * - * @return Swift_Image + * @return self */ public static function fromPath($path) { - $image = self::newInstance()->setFile( - new Swift_ByteStream_FileByteStream($path) - ); - - return $image; + return self::newInstance()->setFile(new Swift_ByteStream_FileByteStream($path)); } } diff --git a/lib/swiftmailer/lib/classes/Swift/InputByteStream.php b/lib/swiftmailer/lib/classes/Swift/InputByteStream.php index 3506aca2e..56efc7593 100644 --- a/lib/swiftmailer/lib/classes/Swift/InputByteStream.php +++ b/lib/swiftmailer/lib/classes/Swift/InputByteStream.php @@ -14,9 +14,7 @@ * Classes implementing this interface may use a subsystem which requires less * memory than working with large strings of data. * - * @package Swift - * @subpackage ByteStream - * @author Chris Corbyn + * @author Chris Corbyn */ interface Swift_InputByteStream { @@ -32,9 +30,9 @@ interface Swift_InputByteStream * * @param string $bytes * - * @return int - * * @throws Swift_IoException + * + * @return int */ public function write($bytes); diff --git a/lib/swiftmailer/lib/classes/Swift/IoException.php b/lib/swiftmailer/lib/classes/Swift/IoException.php index dca105743..c405f352b 100644 --- a/lib/swiftmailer/lib/classes/Swift/IoException.php +++ b/lib/swiftmailer/lib/classes/Swift/IoException.php @@ -11,18 +11,19 @@ /** * I/O Exception class. * - * @package Swift - * @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/lib/swiftmailer/lib/classes/Swift/KeyCache.php b/lib/swiftmailer/lib/classes/Swift/KeyCache.php index 606f55ee7..cd6f786df 100644 --- a/lib/swiftmailer/lib/classes/Swift/KeyCache.php +++ b/lib/swiftmailer/lib/classes/Swift/KeyCache.php @@ -11,9 +11,7 @@ /** * Provides a mechanism for storing data using two keys. * - * @package Swift - * @subpackage KeyCache - * @author Chris Corbyn + * @author Chris Corbyn */ interface Swift_KeyCache { @@ -28,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/lib/swiftmailer/lib/classes/Swift/KeyCache/ArrayKeyCache.php b/lib/swiftmailer/lib/classes/Swift/KeyCache/ArrayKeyCache.php index 8ef3dcc99..b37f07f74 100644 --- a/lib/swiftmailer/lib/classes/Swift/KeyCache/ArrayKeyCache.php +++ b/lib/swiftmailer/lib/classes/Swift/KeyCache/ArrayKeyCache.php @@ -11,9 +11,7 @@ /** * A basic KeyCache backed by an array. * - * @package Swift - * @subpackage KeyCache - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_KeyCache_ArrayKeyCache implements Swift_KeyCache { @@ -47,10 +45,10 @@ class Swift_KeyCache_ArrayKeyCache 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) { @@ -67,8 +65,8 @@ class Swift_KeyCache_ArrayKeyCache implements Swift_KeyCache break; default: throw new Swift_SwiftException( - 'Invalid mode [' . $mode . '] used to set nsKey='. - $nsKey . ', itemKey=' . $itemKey + 'Invalid mode ['.$mode.'] used to set nsKey='. + $nsKey.', itemKey='.$itemKey ); } } @@ -99,8 +97,8 @@ class Swift_KeyCache_ArrayKeyCache implements Swift_KeyCache break; default: throw new Swift_SwiftException( - 'Invalid mode [' . $mode . '] used to set nsKey='. - $nsKey . ', itemKey=' . $itemKey + 'Invalid mode ['.$mode.'] used to set nsKey='. + $nsKey.', itemKey='.$itemKey ); } } @@ -194,8 +192,6 @@ class Swift_KeyCache_ArrayKeyCache implements Swift_KeyCache unset($this->_contents[$nsKey]); } - // -- Private methods - /** * Initialize the namespace of $nsKey if needed. * diff --git a/lib/swiftmailer/lib/classes/Swift/KeyCache/DiskKeyCache.php b/lib/swiftmailer/lib/classes/Swift/KeyCache/DiskKeyCache.php index abd8611f2..453f50a15 100644 --- a/lib/swiftmailer/lib/classes/Swift/KeyCache/DiskKeyCache.php +++ b/lib/swiftmailer/lib/classes/Swift/KeyCache/DiskKeyCache.php @@ -11,9 +11,7 @@ /** * A KeyCache which streams to and from disk. * - * @package Swift - * @subpackage KeyCache - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_KeyCache_DiskKeyCache implements Swift_KeyCache { @@ -76,10 +74,10 @@ class Swift_KeyCache_DiskKeyCache 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 * * @throws Swift_IoException */ @@ -95,8 +93,8 @@ class Swift_KeyCache_DiskKeyCache implements Swift_KeyCache break; default: throw new Swift_SwiftException( - 'Invalid mode [' . $mode . '] used to set nsKey='. - $nsKey . ', itemKey=' . $itemKey + 'Invalid mode ['.$mode.'] used to set nsKey='. + $nsKey.', itemKey='.$itemKey ); break; } @@ -128,8 +126,8 @@ class Swift_KeyCache_DiskKeyCache implements Swift_KeyCache break; default: throw new Swift_SwiftException( - 'Invalid mode [' . $mode . '] used to set nsKey='. - $nsKey . ', itemKey=' . $itemKey + 'Invalid mode ['.$mode.'] used to set nsKey='. + $nsKey.', itemKey='.$itemKey ); break; } @@ -169,9 +167,9 @@ class Swift_KeyCache_DiskKeyCache implements Swift_KeyCache * @param string $nsKey * @param string $itemKey * - * @return string - * * @throws Swift_IoException + * + * @return string */ public function getString($nsKey, $itemKey) { @@ -228,7 +226,7 @@ class Swift_KeyCache_DiskKeyCache implements Swift_KeyCache */ public function hasKey($nsKey, $itemKey) { - return is_file($this->_path . '/' . $nsKey . '/' . $itemKey); + return is_file($this->_path.'/'.$nsKey.'/'.$itemKey); } /** @@ -241,7 +239,7 @@ class Swift_KeyCache_DiskKeyCache implements Swift_KeyCache { if ($this->hasKey($nsKey, $itemKey)) { $this->_freeHandle($nsKey, $itemKey); - unlink($this->_path . '/' . $nsKey . '/' . $itemKey); + unlink($this->_path.'/'.$nsKey.'/'.$itemKey); } } @@ -253,18 +251,16 @@ class Swift_KeyCache_DiskKeyCache implements Swift_KeyCache public function clearAll($nsKey) { if (array_key_exists($nsKey, $this->_keys)) { - foreach ($this->_keys[$nsKey] as $itemKey=>$null) { + foreach ($this->_keys[$nsKey] as $itemKey => $null) { $this->clearKey($nsKey, $itemKey); } - if (is_dir($this->_path . '/' . $nsKey)) { - rmdir($this->_path . '/' . $nsKey); + if (is_dir($this->_path.'/'.$nsKey)) { + rmdir($this->_path.'/'.$nsKey); } unset($this->_keys[$nsKey]); } } - // -- Private methods - /** * Initialize the namespace of $nsKey if needed. * @@ -272,10 +268,10 @@ class Swift_KeyCache_DiskKeyCache implements Swift_KeyCache */ private function _prepareCache($nsKey) { - $cacheDir = $this->_path . '/' . $nsKey; + $cacheDir = $this->_path.'/'.$nsKey; if (!is_dir($cacheDir)) { if (!mkdir($cacheDir)) { - throw new Swift_IoException('Failed to create cache directory ' . $cacheDir); + throw new Swift_IoException('Failed to create cache directory '.$cacheDir); } $this->_keys[$nsKey] = array(); } @@ -284,20 +280,17 @@ class Swift_KeyCache_DiskKeyCache implements Swift_KeyCache /** * 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' - ; - $fp = fopen($this->_path . '/' . $nsKey . '/' . $itemKey, $openMode); + $openMode = $this->hasKey($nsKey, $itemKey) ? 'r+b' : 'w+b'; + $fp = fopen($this->_path.'/'.$nsKey.'/'.$itemKey, $openMode); $this->_keys[$nsKey][$itemKey] = $fp; } if (self::POSITION_START == $position) { @@ -321,7 +314,7 @@ class Swift_KeyCache_DiskKeyCache implements Swift_KeyCache */ public function __destruct() { - foreach ($this->_keys as $nsKey=>$null) { + foreach ($this->_keys as $nsKey => $null) { $this->clearAll($nsKey); } } diff --git a/lib/swiftmailer/lib/classes/Swift/KeyCache/KeyCacheInputStream.php b/lib/swiftmailer/lib/classes/Swift/KeyCache/KeyCacheInputStream.php index f4f8adb96..af80bdca6 100644 --- a/lib/swiftmailer/lib/classes/Swift/KeyCache/KeyCacheInputStream.php +++ b/lib/swiftmailer/lib/classes/Swift/KeyCache/KeyCacheInputStream.php @@ -11,9 +11,7 @@ /** * Writes data to a KeyCache using a stream. * - * @package Swift - * @subpackage KeyCache - * @author Chris Corbyn + * @author Chris Corbyn */ interface Swift_KeyCache_KeyCacheInputStream extends Swift_InputByteStream { diff --git a/lib/swiftmailer/lib/classes/Swift/KeyCache/NullKeyCache.php b/lib/swiftmailer/lib/classes/Swift/KeyCache/NullKeyCache.php index 5c4e2cfd6..4efe78564 100644 --- a/lib/swiftmailer/lib/classes/Swift/KeyCache/NullKeyCache.php +++ b/lib/swiftmailer/lib/classes/Swift/KeyCache/NullKeyCache.php @@ -11,9 +11,7 @@ /** * A null KeyCache that does not cache at all. * - * @package Swift - * @subpackage KeyCache - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_KeyCache_NullKeyCache implements Swift_KeyCache { @@ -22,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/lib/swiftmailer/lib/classes/Swift/KeyCache/SimpleKeyCacheInputStream.php b/lib/swiftmailer/lib/classes/Swift/KeyCache/SimpleKeyCacheInputStream.php index aa7de04a7..b00d458a6 100644 --- a/lib/swiftmailer/lib/classes/Swift/KeyCache/SimpleKeyCacheInputStream.php +++ b/lib/swiftmailer/lib/classes/Swift/KeyCache/SimpleKeyCacheInputStream.php @@ -11,9 +11,7 @@ /** * Writes data to a KeyCache using a stream. * - * @package Swift - * @subpackage KeyCache - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_KeyCache_SimpleKeyCacheInputStream implements Swift_KeyCache_KeyCacheInputStream { diff --git a/lib/swiftmailer/lib/classes/Swift/LoadBalancedTransport.php b/lib/swiftmailer/lib/classes/Swift/LoadBalancedTransport.php index 6eb3db706..e151b8a9c 100644 --- a/lib/swiftmailer/lib/classes/Swift/LoadBalancedTransport.php +++ b/lib/swiftmailer/lib/classes/Swift/LoadBalancedTransport.php @@ -11,9 +11,7 @@ /** * Redundantly and rotationally uses several Transport implementations when sending. * - * @package Swift - * @subpackage Transport - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_LoadBalancedTransport extends Swift_Transport_LoadBalancedTransport { @@ -38,7 +36,7 @@ class Swift_LoadBalancedTransport extends Swift_Transport_LoadBalancedTransport * * @param array $transports * - * @return Swift_LoadBalancedTransport + * @return self */ public static function newInstance($transports = array()) { diff --git a/lib/swiftmailer/lib/classes/Swift/MailTransport.php b/lib/swiftmailer/lib/classes/Swift/MailTransport.php index 6c5793967..18556989a 100644 --- a/lib/swiftmailer/lib/classes/Swift/MailTransport.php +++ b/lib/swiftmailer/lib/classes/Swift/MailTransport.php @@ -11,9 +11,9 @@ /** * Sends Messages using the mail() function. * - * @package Swift - * @subpackage Transport - * @author Chris Corbyn + * @author Chris Corbyn + * + * @deprecated since 5.4.5 (to be removed in 6.0) */ class Swift_MailTransport extends Swift_Transport_MailTransport { @@ -38,7 +38,7 @@ class Swift_MailTransport extends Swift_Transport_MailTransport * * @param string $extraParams To be passed to mail() * - * @return Swift_MailTransport + * @return self */ public static function newInstance($extraParams = '-f%s') { diff --git a/lib/swiftmailer/lib/classes/Swift/Mailer.php b/lib/swiftmailer/lib/classes/Swift/Mailer.php index f4e051232..8314fe8fc 100644 --- a/lib/swiftmailer/lib/classes/Swift/Mailer.php +++ b/lib/swiftmailer/lib/classes/Swift/Mailer.php @@ -11,8 +11,7 @@ /** * Swift Mailer class. * - * @package Swift - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_Mailer { @@ -34,7 +33,7 @@ class Swift_Mailer * * @param Swift_Transport $transport * - * @return Swift_Mailer + * @return self */ public static function newInstance(Swift_Transport $transport) { @@ -70,7 +69,7 @@ class Swift_Mailer * @param Swift_Mime_Message $message * @param array $failedRecipients An array of failures by-reference * - * @return int + * @return int The number of successful recipients. Can be 0 which indicates failure */ public function send(Swift_Mime_Message $message, &$failedRecipients = null) { diff --git a/lib/swiftmailer/lib/classes/Swift/Mailer/ArrayRecipientIterator.php b/lib/swiftmailer/lib/classes/Swift/Mailer/ArrayRecipientIterator.php index 1dd32415b..e3e6cad05 100644 --- a/lib/swiftmailer/lib/classes/Swift/Mailer/ArrayRecipientIterator.php +++ b/lib/swiftmailer/lib/classes/Swift/Mailer/ArrayRecipientIterator.php @@ -11,9 +11,7 @@ /** * Wraps a standard PHP array in an iterator. * - * @package Swift - * @subpackage Mailer - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_Mailer_ArrayRecipientIterator implements Swift_Mailer_RecipientIterator { @@ -46,7 +44,7 @@ class Swift_Mailer_ArrayRecipientIterator implements Swift_Mailer_RecipientItera /** * Returns an array where the keys are the addresses of recipients and the - * values are the names. e.g. ('foo@bar' => 'Foo') or ('foo@bar' => NULL) + * values are the names. e.g. ('foo@bar' => 'Foo') or ('foo@bar' => NULL). * * @return array */ diff --git a/lib/swiftmailer/lib/classes/Swift/Mailer/RecipientIterator.php b/lib/swiftmailer/lib/classes/Swift/Mailer/RecipientIterator.php index 8f109fa95..650f3ec3d 100644 --- a/lib/swiftmailer/lib/classes/Swift/Mailer/RecipientIterator.php +++ b/lib/swiftmailer/lib/classes/Swift/Mailer/RecipientIterator.php @@ -11,9 +11,7 @@ /** * Provides an abstract way of specifying recipients for batch sending. * - * @package Swift - * @subpackage Mailer - * @author Chris Corbyn + * @author Chris Corbyn */ interface Swift_Mailer_RecipientIterator { @@ -26,7 +24,7 @@ interface Swift_Mailer_RecipientIterator /** * Returns an array where the keys are the addresses of recipients and the - * values are the names. e.g. ('foo@bar' => 'Foo') or ('foo@bar' => NULL) + * values are the names. e.g. ('foo@bar' => 'Foo') or ('foo@bar' => NULL). * * @return array */ diff --git a/lib/swiftmailer/lib/classes/Swift/MemorySpool.php b/lib/swiftmailer/lib/classes/Swift/MemorySpool.php index 6e042cd6a..2cafb6751 100644 --- a/lib/swiftmailer/lib/classes/Swift/MemorySpool.php +++ b/lib/swiftmailer/lib/classes/Swift/MemorySpool.php @@ -11,12 +11,12 @@ /** * Stores Messages in memory. * - * @package Swift - * @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. @@ -42,16 +42,25 @@ class Swift_MemorySpool implements Swift_Spool { } + /** + * @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) { - $this->messages[] = $message; + //clone the message to make sure it is not changed while in the queue + $this->messages[] = clone $message; return true; } @@ -62,7 +71,7 @@ class Swift_MemorySpool implements Swift_Spool * @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 @@ class Swift_MemorySpool implements Swift_Spool } $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/lib/swiftmailer/lib/classes/Swift/Message.php b/lib/swiftmailer/lib/classes/Swift/Message.php index a5aac9eaa..242cbf314 100644 --- a/lib/swiftmailer/lib/classes/Swift/Message.php +++ b/lib/swiftmailer/lib/classes/Swift/Message.php @@ -11,9 +11,7 @@ /** * The Message class for building emails. * - * @package Swift - * @subpackage Mime - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_Message extends Swift_Mime_SimpleMessage { @@ -32,7 +30,7 @@ class Swift_Message extends Swift_Mime_SimpleMessage */ private $savedMessage = array(); - /** + /** * Create a new Message. * * Details may be optionally passed into the constructor. @@ -70,7 +68,7 @@ class Swift_Message extends Swift_Mime_SimpleMessage * @param string $contentType * @param string $charset * - * @return Swift_Message + * @return $this */ public static function newInstance($subject = null, $body = null, $contentType = null, $charset = null) { @@ -84,20 +82,19 @@ class Swift_Message extends Swift_Mime_SimpleMessage * @param string $contentType * @param string $charset * - * @return Swift_Mime_SimpleMessage + * @return $this */ public function addPart($body, $contentType = null, $charset = null) { - return $this->attach(Swift_MimePart::newInstance( - $body, $contentType, $charset - )); + return $this->attach(Swift_MimePart::newInstance($body, $contentType, $charset)->setEncoder($this->getEncoder())); } - + /** - * Attach a new signature handler to the message. + * Detach a signature handler from a message. * * @param Swift_Signer $signer - * @return Swift_Message + * + * @return $this */ public function attachSigner(Swift_Signer $signer) { @@ -106,7 +103,7 @@ class Swift_Message extends Swift_Mime_SimpleMessage } elseif ($signer instanceof Swift_Signers_BodySigner) { $this->bodySigners[] = $signer; } - + return $this; } @@ -114,7 +111,8 @@ class Swift_Message extends Swift_Mime_SimpleMessage * Attach a new signature handler to the message. * * @param Swift_Signer $signer - * @return Swift_Message + * + * @return $this */ public function detachSigner(Swift_Signer $signer) { @@ -122,6 +120,7 @@ class Swift_Message extends Swift_Mime_SimpleMessage foreach ($this->headerSigners as $k => $headerSigner) { if ($headerSigner === $signer) { unset($this->headerSigners[$k]); + return $this; } } @@ -129,14 +128,15 @@ class Swift_Message extends Swift_Mime_SimpleMessage foreach ($this->bodySigners as $k => $bodySigner) { if ($bodySigner === $signer) { unset($this->bodySigners[$k]); + return $this; } } - } - - return $this; + } + + return $this; } - + /** * Get this message as a complete string. * @@ -144,21 +144,21 @@ class Swift_Message extends Swift_Mime_SimpleMessage */ public function toString() { - if (empty($this->headerSigners) && empty($this->bodySigners)) { - return parent::toString(); - } - + if (empty($this->headerSigners) && empty($this->bodySigners)) { + return parent::toString(); + } + $this->saveMessage(); - + $this->doSign(); - + $string = parent::toString(); - + $this->restoreMessage(); - - return $string; + + return $string; } - + /** * Write this message to a {@link Swift_InputByteStream}. * @@ -168,106 +168,122 @@ class Swift_Message extends Swift_Mime_SimpleMessage { if (empty($this->headerSigners) && empty($this->bodySigners)) { parent::toByteStream($is); + return; } - + $this->saveMessage(); - + $this->doSign(); - + parent::toByteStream($is); - + $this->restoreMessage(); - } - + public function __wakeup() { Swift_DependencyContainer::getInstance()->createDependenciesFor('mime.message'); } - - /* -- Protected Methods -- */ - + /** - * loops through signers and apply the signatures + * loops through signers and apply the signatures. */ protected function doSign() { - foreach ($this->bodySigners as $signer) { - $altered = $signer->getAlteredHeaders(); - $this->saveHeaders($altered); - $signer->signMessage($this); - } - - foreach ($this->headerSigners as $signer) { - $altered = $signer->getAlteredHeaders(); - $this->saveHeaders($altered); - $signer->reset(); - - $signer->setHeaders($this->getHeaders()); - - $signer->startBody(); - $this->_bodyToByteStream($signer); - $signer->endBody(); - - $signer->addSignature($this->getHeaders()); - } + foreach ($this->bodySigners as $signer) { + $altered = $signer->getAlteredHeaders(); + $this->saveHeaders($altered); + $signer->signMessage($this); + } + + foreach ($this->headerSigners as $signer) { + $altered = $signer->getAlteredHeaders(); + $this->saveHeaders($altered); + $signer->reset(); + + $signer->setHeaders($this->getHeaders()); + + $signer->startBody(); + $this->_bodyToByteStream($signer); + $signer->endBody(); + + $signer->addSignature($this->getHeaders()); + } } - + /** - * save the message before any signature is applied + * save the message before any signature is applied. */ protected function saveMessage() { - $this->savedMessage = array('headers'=> array()); - $this->savedMessage['body'] = $this->getBody(); - $this->savedMessage['children'] = $this->getChildren(); - if (count($this->savedMessage['children']) > 0 && $this->getBody() != '') { - $this->setChildren(array_merge(array($this->_becomeMimePart()), $this->savedMessage['children'])); - $this->setBody(''); - } + $this->savedMessage = array('headers' => array()); + $this->savedMessage['body'] = $this->getBody(); + $this->savedMessage['children'] = $this->getChildren(); + if (count($this->savedMessage['children']) > 0 && $this->getBody() != '') { + $this->setChildren(array_merge(array($this->_becomeMimePart()), $this->savedMessage['children'])); + $this->setBody(''); + } } - + /** - * save the original headers + * save the original headers. + * * @param array $altered */ protected function saveHeaders(array $altered) { - foreach ($altered as $head) { - $lc = strtolower($head); - - if (!isset($this->savedMessage['headers'][$lc])) { - $this->savedMessage['headers'][$lc] = $this->getHeaders()->getAll($head); - } - } + foreach ($altered as $head) { + $lc = strtolower($head); + + if (!isset($this->savedMessage['headers'][$lc])) { + $this->savedMessage['headers'][$lc] = $this->getHeaders()->getAll($head); + } + } } - + /** - * Remove or restore altered headers + * Remove or restore altered headers. */ protected function restoreHeaders() { - foreach ($this->savedMessage['headers'] as $name => $savedValue) { - $headers = $this->getHeaders()->getAll($name); - - foreach ($headers as $key => $value) { - if (!isset($savedValue[$key])) { - $this->getHeaders()->remove($name, $key); - } - } - } + foreach ($this->savedMessage['headers'] as $name => $savedValue) { + $headers = $this->getHeaders()->getAll($name); + + foreach ($headers as $key => $value) { + if (!isset($savedValue[$key])) { + $this->getHeaders()->remove($name, $key); + } + } + } } - + /** - * Restore message body + * Restore message body. */ protected function restoreMessage() { - $this->setBody($this->savedMessage['body']); - $this->setChildren($this->savedMessage['children']); - - $this->restoreHeaders(); - $this->savedMessage = array(); + $this->setBody($this->savedMessage['body']); + $this->setChildren($this->savedMessage['children']); + + $this->restoreHeaders(); + $this->savedMessage = array(); + } + + /** + * Clone Message Signers. + * + * @see Swift_Mime_SimpleMimeEntity::__clone() + */ + public function __clone() + { + parent::__clone(); + foreach ($this->bodySigners as $key => $bodySigner) { + $this->bodySigners[$key] = clone $bodySigner; + } + + foreach ($this->headerSigners as $key => $headerSigner) { + $this->headerSigners[$key] = clone $headerSigner; + } } } diff --git a/lib/swiftmailer/lib/classes/Swift/Mime/Attachment.php b/lib/swiftmailer/lib/classes/Swift/Mime/Attachment.php index 108a02adf..d5ba14b91 100644 --- a/lib/swiftmailer/lib/classes/Swift/Mime/Attachment.php +++ b/lib/swiftmailer/lib/classes/Swift/Mime/Attachment.php @@ -11,9 +11,7 @@ /** * An attachment, in a multipart message. * - * @package Swift - * @subpackage Mime - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_Mime_Attachment extends Swift_Mime_SimpleMimeEntity { @@ -66,14 +64,12 @@ class Swift_Mime_Attachment extends Swift_Mime_SimpleMimeEntity * * @param string $disposition * - * @return Swift_Mime_Attachment + * @return $this */ public function setDisposition($disposition) { if (!$this->_setHeaderFieldModel('Content-Disposition', $disposition)) { - $this->getHeaders()->addParameterizedHeader( - 'Content-Disposition', $disposition - ); + $this->getHeaders()->addParameterizedHeader('Content-Disposition', $disposition); } return $this; @@ -94,7 +90,7 @@ class Swift_Mime_Attachment extends Swift_Mime_SimpleMimeEntity * * @param string $filename * - * @return Swift_Mime_Attachment + * @return $this */ public function setFilename($filename) { @@ -117,9 +113,9 @@ class Swift_Mime_Attachment extends Swift_Mime_SimpleMimeEntity /** * Set the file size of this attachment. * - * @param int $size + * @param int $size * - * @return Swift_Mime_Attachment + * @return $this */ public function setSize($size) { @@ -134,16 +130,14 @@ class Swift_Mime_Attachment extends Swift_Mime_SimpleMimeEntity * @param Swift_FileStream $file * @param string $contentType optional * - * @return Swift_Mime_Attachment + * @return $this */ public function setFile(Swift_FileStream $file, $contentType = null) { $this->setFilename(basename($file->getPath())); $this->setBody($file, $contentType); if (!isset($contentType)) { - $extension = strtolower(substr( - $file->getPath(), strrpos($file->getPath(), '.') + 1 - )); + $extension = strtolower(substr($file->getPath(), strrpos($file->getPath(), '.') + 1)); if (array_key_exists($extension, $this->_mimeTypes)) { $this->setContentType($this->_mimeTypes[$extension]); diff --git a/lib/swiftmailer/lib/classes/Swift/Mime/CharsetObserver.php b/lib/swiftmailer/lib/classes/Swift/Mime/CharsetObserver.php index bfd41edfe..b49c3a873 100644 --- a/lib/swiftmailer/lib/classes/Swift/Mime/CharsetObserver.php +++ b/lib/swiftmailer/lib/classes/Swift/Mime/CharsetObserver.php @@ -11,9 +11,7 @@ /** * Observes changes in an Mime entity's character set. * - * @package Swift - * @subpackage Mime - * @author Chris Corbyn + * @author Chris Corbyn */ interface Swift_Mime_CharsetObserver { diff --git a/lib/swiftmailer/lib/classes/Swift/Mime/ContentEncoder.php b/lib/swiftmailer/lib/classes/Swift/Mime/ContentEncoder.php index 67fbf94df..d43ea9f40 100644 --- a/lib/swiftmailer/lib/classes/Swift/Mime/ContentEncoder.php +++ b/lib/swiftmailer/lib/classes/Swift/Mime/ContentEncoder.php @@ -11,9 +11,7 @@ /** * Interface for all Transfer Encoding schemes. * - * @package Swift - * @subpackage Mime - * @author Chris Corbyn + * @author Chris Corbyn */ interface Swift_Mime_ContentEncoder extends Swift_Encoder { diff --git a/lib/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/Base64ContentEncoder.php b/lib/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/Base64ContentEncoder.php index ed9baf469..8f76d70f3 100644 --- a/lib/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/Base64ContentEncoder.php +++ b/lib/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/Base64ContentEncoder.php @@ -11,9 +11,7 @@ /** * Handles Base 64 Transfer Encoding in Swift Mailer. * - * @package Swift - * @subpackage Mime - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_Mime_ContentEncoder_Base64ContentEncoder extends Swift_Encoder_Base64Encoder implements Swift_Mime_ContentEncoder { @@ -32,14 +30,47 @@ class Swift_Mime_ContentEncoder_Base64ContentEncoder extends Swift_Encoder_Base6 } $remainder = 0; + $base64ReadBufferRemainderBytes = null; - while (false !== $bytes = $os->read(8190)) { - $encoded = base64_encode($bytes); + // To reduce memory usage, the output buffer is streamed to the input buffer like so: + // Output Stream => base64encode => wrap line length => Input Stream + // HOWEVER it's important to note that base64_encode() should only be passed whole triplets of data (except for the final chunk of data) + // otherwise it will assume the input data has *ended* and it will incorrectly pad/terminate the base64 data mid-stream. + // We use $base64ReadBufferRemainderBytes to carry over 1-2 "remainder" bytes from the each chunk from OutputStream and pre-pend those onto the + // chunk of bytes read in the next iteration. + // When the OutputStream is empty, we must flush any remainder bytes. + while (true) { + $readBytes = $os->read(8192); + $atEOF = ($readBytes === false); + + if ($atEOF) { + $streamTheseBytes = $base64ReadBufferRemainderBytes; + } else { + $streamTheseBytes = $base64ReadBufferRemainderBytes.$readBytes; + } + $base64ReadBufferRemainderBytes = null; + $bytesLength = strlen($streamTheseBytes); + + if ($bytesLength === 0) { // no data left to encode + break; + } + + // if we're not on the last block of the ouput stream, make sure $streamTheseBytes ends with a complete triplet of data + // and carry over remainder 1-2 bytes to the next loop iteration + if (!$atEOF) { + $excessBytes = $bytesLength % 3; + if ($excessBytes !== 0) { + $base64ReadBufferRemainderBytes = substr($streamTheseBytes, -$excessBytes); + $streamTheseBytes = substr($streamTheseBytes, 0, $bytesLength - $excessBytes); + } + } + + $encoded = base64_encode($streamTheseBytes); $encodedTransformed = ''; $thisMaxLineLength = $maxLineLength - $remainder - $firstLineOffset; while ($thisMaxLineLength < strlen($encoded)) { - $encodedTransformed .= substr($encoded, 0, $thisMaxLineLength) . "\r\n"; + $encodedTransformed .= substr($encoded, 0, $thisMaxLineLength)."\r\n"; $firstLineOffset = 0; $encoded = substr($encoded, $thisMaxLineLength); $thisMaxLineLength = $maxLineLength; @@ -53,6 +84,10 @@ class Swift_Mime_ContentEncoder_Base64ContentEncoder extends Swift_Encoder_Base6 } $is->write($encodedTransformed); + + if ($atEOF) { + break; + } } } diff --git a/lib/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/NativeQpContentEncoder.php b/lib/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/NativeQpContentEncoder.php index ce7c31ea8..710b5ac9e 100644 --- a/lib/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/NativeQpContentEncoder.php +++ b/lib/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/NativeQpContentEncoder.php @@ -11,9 +11,7 @@ /** * Handles Quoted Printable (QP) Transfer Encoding in Swift Mailer using the PHP core function. * - * @package Swift - * @subpackage Mime - * @author Lars Strojny + * @author Lars Strojny */ class Swift_Mime_ContentEncoder_NativeQpContentEncoder implements Swift_Mime_ContentEncoder { @@ -79,13 +77,13 @@ class Swift_Mime_ContentEncoder_NativeQpContentEncoder implements Swift_Mime_Con /** * 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) { @@ -109,7 +107,7 @@ class Swift_Mime_ContentEncoder_NativeQpContentEncoder implements Swift_Mime_Con // transform CR or LF to CRLF $string = preg_replace('~=0D(?!=0A)|(?read(8192)) { - $toencode = $leftOver . $bytes; + $toencode = $leftOver.$bytes; if ($this->_canonical) { $toencode = $this->_canonicalize($toencode); } @@ -106,14 +104,12 @@ class Swift_Mime_ContentEncoder_PlainContentEncoder implements Swift_Mime_Conten { } - // -- Private methods - /** * A safer (but weaker) wordwrap for unicode. * - * @param string $string - * @param int $length - * @param string $le + * @param string $string + * @param int $length + * @param string $le * * @return string */ @@ -130,17 +126,16 @@ class Swift_Mime_ContentEncoder_PlainContentEncoder implements Swift_Mime_Conten foreach ($originalLines as $originalLine) { $lines[] = ''; - $currentLine =& $lines[$lineCount++]; + $currentLine = &$lines[$lineCount++]; //$chunks = preg_split('/(?<=[\ \t,\.!\?\-&\+\/])/', $originalLine); $chunks = preg_split('/(?<=\s)/', $originalLine); foreach ($chunks as $chunk) { if (0 != strlen($currentLine) - && strlen($currentLine . $chunk) > $length) - { + && strlen($currentLine.$chunk) > $length) { $lines[] = ''; - $currentLine =& $lines[$lineCount++]; + $currentLine = &$lines[$lineCount++]; } $currentLine .= $chunk; } diff --git a/lib/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/QpContentEncoder.php b/lib/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/QpContentEncoder.php index 6df4a5f3f..5cc907b8e 100644 --- a/lib/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/QpContentEncoder.php +++ b/lib/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/QpContentEncoder.php @@ -11,9 +11,7 @@ /** * Handles Quoted Printable (QP) Transfer Encoding in Swift Mailer. * - * @package Swift - * @subpackage Mime - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_Mime_ContentEncoder_QpContentEncoder extends Swift_Encoder_QpEncoder implements Swift_Mime_ContentEncoder { @@ -76,7 +74,7 @@ class Swift_Mime_ContentEncoder_QpContentEncoder extends Swift_Encoder_QpEncoder $currentLine = ''; $prepend = ''; - $size=$lineLen=0; + $size = $lineLen = 0; while (false !== $bytes = $this->_nextSequence()) { // If we're filtering the input @@ -97,18 +95,29 @@ class Swift_Mime_ContentEncoder_QpContentEncoder extends Swift_Encoder_QpEncoder } $enc = $this->_encodeByteSequence($bytes, $size); - if ($currentLine && $lineLen+$size >= $thisLineLength) { - $is->write($prepend . $this->_standardize($currentLine)); + + $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 = 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)); + $is->write($prepend.$this->_standardize($currentLine)); } } diff --git a/lib/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/QpContentEncoderProxy.php b/lib/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/QpContentEncoderProxy.php index 491409acd..3214e1cf3 100644 --- a/lib/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/QpContentEncoderProxy.php +++ b/lib/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/QpContentEncoderProxy.php @@ -13,9 +13,7 @@ * * Switches on the best QP encoder implementation for current charset. * - * @package Swift - * @subpackage Mime - * @author Jean-François Simon + * @author Jean-François Simon */ class Swift_Mime_ContentEncoder_QpContentEncoderProxy implements Swift_Mime_ContentEncoder { @@ -48,12 +46,22 @@ class Swift_Mime_ContentEncoder_QpContentEncoderProxy implements Swift_Mime_Cont $this->charset = $charset; } + /** + * Make a deep copy of object. + */ + public function __clone() + { + $this->safeEncoder = clone $this->safeEncoder; + $this->nativeEncoder = clone $this->nativeEncoder; + } + /** * {@inheritdoc} */ public function charsetChanged($charset) { $this->charset = $charset; + $this->safeEncoder->charsetChanged($charset); } /** diff --git a/lib/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/RawContentEncoder.php b/lib/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/RawContentEncoder.php index 8f1f9b575..0b8526e38 100644 --- a/lib/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/RawContentEncoder.php +++ b/lib/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/RawContentEncoder.php @@ -11,19 +11,18 @@ /** * Handles raw Transfer Encoding in Swift Mailer. * - * @package Swift - * @subpackage Mime * - * @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/lib/swiftmailer/lib/classes/Swift/Mime/EmbeddedFile.php b/lib/swiftmailer/lib/classes/Swift/Mime/EmbeddedFile.php index 9079fabf5..6af757124 100644 --- a/lib/swiftmailer/lib/classes/Swift/Mime/EmbeddedFile.php +++ b/lib/swiftmailer/lib/classes/Swift/Mime/EmbeddedFile.php @@ -11,9 +11,7 @@ /** * An embedded file, in a multipart message. * - * @package Swift - * @subpackage Mime - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_Mime_EmbeddedFile extends Swift_Mime_Attachment { diff --git a/lib/swiftmailer/lib/classes/Swift/Mime/EncodingObserver.php b/lib/swiftmailer/lib/classes/Swift/Mime/EncodingObserver.php index e7e6f20d6..cc44a6efb 100644 --- a/lib/swiftmailer/lib/classes/Swift/Mime/EncodingObserver.php +++ b/lib/swiftmailer/lib/classes/Swift/Mime/EncodingObserver.php @@ -11,9 +11,7 @@ /** * Observes changes for a Mime entity's ContentEncoder. * - * @package Swift - * @subpackage Mime - * @author Chris Corbyn + * @author Chris Corbyn */ interface Swift_Mime_EncodingObserver { diff --git a/lib/swiftmailer/lib/classes/Swift/Mime/Grammar.php b/lib/swiftmailer/lib/classes/Swift/Mime/Grammar.php index 9b0670741..a09f33831 100644 --- a/lib/swiftmailer/lib/classes/Swift/Mime/Grammar.php +++ b/lib/swiftmailer/lib/classes/Swift/Mime/Grammar.php @@ -11,8 +11,6 @@ /** * Defines the grammar to use for validation, implements the RFC 2822 (and friends) ABNF grammar definitions. * - * @package Swift - * @subpackage Mime * @author Fabien Potencier * @author Chris Corbyn */ @@ -53,7 +51,7 @@ class Swift_Mime_Grammar self::$_specials = array( '(', ')', '<', '>', '[', ']', - ':', ';', '@', ',', '.', '"' + ':', ';', '@', ',', '.', '"', ); /*** Refer to RFC 2822 for ABNF grammar ***/ @@ -62,62 +60,62 @@ class Swift_Mime_Grammar self::$_grammar['NO-WS-CTL'] = '[\x01-\x08\x0B\x0C\x0E-\x19\x7F]'; self::$_grammar['WSP'] = '[ \t]'; self::$_grammar['CRLF'] = '(?:\r\n)'; - self::$_grammar['FWS'] = '(?:(?:' . self::$_grammar['WSP'] . '*' . - self::$_grammar['CRLF'] . ')?' . self::$_grammar['WSP'] . ')'; + self::$_grammar['FWS'] = '(?:(?:'.self::$_grammar['WSP'].'*'. + self::$_grammar['CRLF'].')?'.self::$_grammar['WSP'].')'; self::$_grammar['text'] = '[\x00-\x08\x0B\x0C\x0E-\x7F]'; - self::$_grammar['quoted-pair'] = '(?:\\\\' . self::$_grammar['text'] . ')'; - self::$_grammar['ctext'] = '(?:' . self::$_grammar['NO-WS-CTL'] . + self::$_grammar['quoted-pair'] = '(?:\\\\'.self::$_grammar['text'].')'; + self::$_grammar['ctext'] = '(?:'.self::$_grammar['NO-WS-CTL']. '|[\x21-\x27\x2A-\x5B\x5D-\x7E])'; // Uses recursive PCRE (?1) -- could be a weak point?? - self::$_grammar['ccontent'] = '(?:' . self::$_grammar['ctext'] . '|' . - self::$_grammar['quoted-pair'] . '|(?1))'; - self::$_grammar['comment'] = '(\((?:' . self::$_grammar['FWS'] . '|' . - self::$_grammar['ccontent']. ')*' . self::$_grammar['FWS'] . '?\))'; - self::$_grammar['CFWS'] = '(?:(?:' . self::$_grammar['FWS'] . '?' . - self::$_grammar['comment'] . ')*(?:(?:' . self::$_grammar['FWS'] . '?' . - self::$_grammar['comment'] . ')|' . self::$_grammar['FWS'] . '))'; - self::$_grammar['qtext'] = '(?:' . self::$_grammar['NO-WS-CTL'] . + self::$_grammar['ccontent'] = '(?:'.self::$_grammar['ctext'].'|'. + self::$_grammar['quoted-pair'].'|(?1))'; + self::$_grammar['comment'] = '(\((?:'.self::$_grammar['FWS'].'|'. + self::$_grammar['ccontent'].')*'.self::$_grammar['FWS'].'?\))'; + self::$_grammar['CFWS'] = '(?:(?:'.self::$_grammar['FWS'].'?'. + self::$_grammar['comment'].')*(?:(?:'.self::$_grammar['FWS'].'?'. + self::$_grammar['comment'].')|'.self::$_grammar['FWS'].'))'; + self::$_grammar['qtext'] = '(?:'.self::$_grammar['NO-WS-CTL']. '|[\x21\x23-\x5B\x5D-\x7E])'; - self::$_grammar['qcontent'] = '(?:' . self::$_grammar['qtext'] . '|' . - self::$_grammar['quoted-pair'] . ')'; - self::$_grammar['quoted-string'] = '(?:' . self::$_grammar['CFWS'] . '?"' . - '(' . self::$_grammar['FWS'] . '?' . self::$_grammar['qcontent'] . ')*' . - self::$_grammar['FWS'] . '?"' . self::$_grammar['CFWS'] . '?)'; + self::$_grammar['qcontent'] = '(?:'.self::$_grammar['qtext'].'|'. + self::$_grammar['quoted-pair'].')'; + self::$_grammar['quoted-string'] = '(?:'.self::$_grammar['CFWS'].'?"'. + '('.self::$_grammar['FWS'].'?'.self::$_grammar['qcontent'].')*'. + self::$_grammar['FWS'].'?"'.self::$_grammar['CFWS'].'?)'; self::$_grammar['atext'] = '[a-zA-Z0-9!#\$%&\'\*\+\-\/=\?\^_`\{\}\|~]'; - self::$_grammar['atom'] = '(?:' . self::$_grammar['CFWS'] . '?' . - self::$_grammar['atext'] . '+' . self::$_grammar['CFWS'] . '?)'; - self::$_grammar['dot-atom-text'] = '(?:' . self::$_grammar['atext'] . '+' . - '(\.' . self::$_grammar['atext'] . '+)*)'; - self::$_grammar['dot-atom'] = '(?:' . self::$_grammar['CFWS'] . '?' . - self::$_grammar['dot-atom-text'] . '+' . self::$_grammar['CFWS'] . '?)'; - self::$_grammar['word'] = '(?:' . self::$_grammar['atom'] . '|' . - self::$_grammar['quoted-string'] . ')'; - self::$_grammar['phrase'] = '(?:' . self::$_grammar['word'] . '+?)'; - self::$_grammar['no-fold-quote'] = '(?:"(?:' . self::$_grammar['qtext'] . - '|' . self::$_grammar['quoted-pair'] . ')*")'; - self::$_grammar['dtext'] = '(?:' . self::$_grammar['NO-WS-CTL'] . + self::$_grammar['atom'] = '(?:'.self::$_grammar['CFWS'].'?'. + self::$_grammar['atext'].'+'.self::$_grammar['CFWS'].'?)'; + self::$_grammar['dot-atom-text'] = '(?:'.self::$_grammar['atext'].'+'. + '(\.'.self::$_grammar['atext'].'+)*)'; + self::$_grammar['dot-atom'] = '(?:'.self::$_grammar['CFWS'].'?'. + self::$_grammar['dot-atom-text'].'+'.self::$_grammar['CFWS'].'?)'; + self::$_grammar['word'] = '(?:'.self::$_grammar['atom'].'|'. + self::$_grammar['quoted-string'].')'; + self::$_grammar['phrase'] = '(?:'.self::$_grammar['word'].'+?)'; + self::$_grammar['no-fold-quote'] = '(?:"(?:'.self::$_grammar['qtext']. + '|'.self::$_grammar['quoted-pair'].')*")'; + self::$_grammar['dtext'] = '(?:'.self::$_grammar['NO-WS-CTL']. '|[\x21-\x5A\x5E-\x7E])'; - self::$_grammar['no-fold-literal'] = '(?:\[(?:' . self::$_grammar['dtext'] . - '|' . self::$_grammar['quoted-pair'] . ')*\])'; + self::$_grammar['no-fold-literal'] = '(?:\[(?:'.self::$_grammar['dtext']. + '|'.self::$_grammar['quoted-pair'].')*\])'; // Message IDs - self::$_grammar['id-left'] = '(?:' . self::$_grammar['dot-atom-text'] . '|' . - self::$_grammar['no-fold-quote'] . ')'; - self::$_grammar['id-right'] = '(?:' . self::$_grammar['dot-atom-text'] . '|' . - self::$_grammar['no-fold-literal'] . ')'; + self::$_grammar['id-left'] = '(?:'.self::$_grammar['dot-atom-text'].'|'. + self::$_grammar['no-fold-quote'].')'; + self::$_grammar['id-right'] = '(?:'.self::$_grammar['dot-atom-text'].'|'. + self::$_grammar['no-fold-literal'].')'; // Addresses, mailboxes and paths - self::$_grammar['local-part'] = '(?:' . self::$_grammar['dot-atom'] . '|' . - self::$_grammar['quoted-string'] . ')'; - self::$_grammar['dcontent'] = '(?:' . self::$_grammar['dtext'] . '|' . - self::$_grammar['quoted-pair'] . ')'; - self::$_grammar['domain-literal'] = '(?:' . self::$_grammar['CFWS'] . '?\[(' . - self::$_grammar['FWS'] . '?' . self::$_grammar['dcontent'] . ')*?' . - self::$_grammar['FWS'] . '?\]' . self::$_grammar['CFWS'] . '?)'; - self::$_grammar['domain'] = '(?:' . self::$_grammar['dot-atom'] . '|' . - self::$_grammar['domain-literal'] . ')'; - self::$_grammar['addr-spec'] = '(?:' . self::$_grammar['local-part'] . '@' . - self::$_grammar['domain'] . ')'; + self::$_grammar['local-part'] = '(?:'.self::$_grammar['dot-atom'].'|'. + self::$_grammar['quoted-string'].')'; + self::$_grammar['dcontent'] = '(?:'.self::$_grammar['dtext'].'|'. + self::$_grammar['quoted-pair'].')'; + self::$_grammar['domain-literal'] = '(?:'.self::$_grammar['CFWS'].'?\[('. + self::$_grammar['FWS'].'?'.self::$_grammar['dcontent'].')*?'. + self::$_grammar['FWS'].'?\]'.self::$_grammar['CFWS'].'?)'; + self::$_grammar['domain'] = '(?:'.self::$_grammar['dot-atom'].'|'. + self::$_grammar['domain-literal'].')'; + self::$_grammar['addr-spec'] = '(?:'.self::$_grammar['local-part'].'@'. + self::$_grammar['domain'].')'; } /** @@ -131,11 +129,11 @@ class Swift_Mime_Grammar { if (array_key_exists($name, self::$_grammar)) { return self::$_grammar[$name]; - } else { - throw new Swift_RfcComplianceException( - "No such grammar '" . $name . "' defined." - ); } + + throw new Swift_RfcComplianceException( + "No such grammar '".$name."' defined." + ); } /** @@ -170,7 +168,7 @@ class Swift_Mime_Grammar public function escapeSpecials($token, $include = array(), $exclude = array()) { foreach (array_merge(array('\\'), array_diff(self::$_specials, $exclude), $include) as $char) { - $token = str_replace($char, '\\' . $char, $token); + $token = str_replace($char, '\\'.$char, $token); } return $token; diff --git a/lib/swiftmailer/lib/classes/Swift/Mime/Header.php b/lib/swiftmailer/lib/classes/Swift/Mime/Header.php index 8a3d05f83..a8ddd2721 100644 --- a/lib/swiftmailer/lib/classes/Swift/Mime/Header.php +++ b/lib/swiftmailer/lib/classes/Swift/Mime/Header.php @@ -11,9 +11,7 @@ /** * A MIME Header. * - * @package Swift - * @subpackage Mime - * @author Chris Corbyn + * @author Chris Corbyn */ interface Swift_Mime_Header { diff --git a/lib/swiftmailer/lib/classes/Swift/Mime/HeaderEncoder.php b/lib/swiftmailer/lib/classes/Swift/Mime/HeaderEncoder.php index 4aff4dc95..08fd453d6 100644 --- a/lib/swiftmailer/lib/classes/Swift/Mime/HeaderEncoder.php +++ b/lib/swiftmailer/lib/classes/Swift/Mime/HeaderEncoder.php @@ -11,9 +11,7 @@ /** * Interface for all Header Encoding schemes. * - * @package Swift - * @subpackage Mime - * @author Chris Corbyn + * @author Chris Corbyn */ interface Swift_Mime_HeaderEncoder extends Swift_Encoder { diff --git a/lib/swiftmailer/lib/classes/Swift/Mime/HeaderEncoder/Base64HeaderEncoder.php b/lib/swiftmailer/lib/classes/Swift/Mime/HeaderEncoder/Base64HeaderEncoder.php index 7a57e3f74..83a4f2f3b 100644 --- a/lib/swiftmailer/lib/classes/Swift/Mime/HeaderEncoder/Base64HeaderEncoder.php +++ b/lib/swiftmailer/lib/classes/Swift/Mime/HeaderEncoder/Base64HeaderEncoder.php @@ -11,9 +11,7 @@ /** * Handles Base64 (B) Header Encoding in Swift Mailer. * - * @package Swift - * @subpackage Mime - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_Mime_HeaderEncoder_Base64HeaderEncoder extends Swift_Encoder_Base64Encoder implements Swift_Mime_HeaderEncoder { @@ -34,10 +32,10 @@ class Swift_Mime_HeaderEncoder_Base64HeaderEncoder extends Swift_Encoder_Base64E * 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/lib/swiftmailer/lib/classes/Swift/Mime/HeaderEncoder/QpHeaderEncoder.php b/lib/swiftmailer/lib/classes/Swift/Mime/HeaderEncoder/QpHeaderEncoder.php index 1527f4ff9..510dd6637 100644 --- a/lib/swiftmailer/lib/classes/Swift/Mime/HeaderEncoder/QpHeaderEncoder.php +++ b/lib/swiftmailer/lib/classes/Swift/Mime/HeaderEncoder/QpHeaderEncoder.php @@ -11,9 +11,7 @@ /** * Handles Quoted Printable (Q) Header Encoding in Swift Mailer. * - * @package Swift - * @subpackage Mime - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_Mime_HeaderEncoder_QpHeaderEncoder extends Swift_Encoder_QpEncoder implements Swift_Mime_HeaderEncoder { @@ -52,9 +50,9 @@ class Swift_Mime_HeaderEncoder_QpHeaderEncoder extends Swift_Encoder_QpEncoder i /** * 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/lib/swiftmailer/lib/classes/Swift/Mime/HeaderFactory.php b/lib/swiftmailer/lib/classes/Swift/Mime/HeaderFactory.php index 40a1e1739..c65f26d72 100644 --- a/lib/swiftmailer/lib/classes/Swift/Mime/HeaderFactory.php +++ b/lib/swiftmailer/lib/classes/Swift/Mime/HeaderFactory.php @@ -11,9 +11,7 @@ /** * Creates MIME headers. * - * @package Swift - * @subpackage Mime - * @author Chris Corbyn + * @author Chris Corbyn */ interface Swift_Mime_HeaderFactory extends Swift_Mime_CharsetObserver { @@ -30,8 +28,8 @@ interface Swift_Mime_HeaderFactory extends Swift_Mime_CharsetObserver /** * 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/lib/swiftmailer/lib/classes/Swift/Mime/HeaderSet.php b/lib/swiftmailer/lib/classes/Swift/Mime/HeaderSet.php index 309bcd861..1768709e9 100644 --- a/lib/swiftmailer/lib/classes/Swift/Mime/HeaderSet.php +++ b/lib/swiftmailer/lib/classes/Swift/Mime/HeaderSet.php @@ -11,9 +11,7 @@ /** * A collection of MIME headers. * - * @package Swift - * @subpackage Mime - * @author Chris Corbyn + * @author Chris Corbyn */ interface Swift_Mime_HeaderSet extends Swift_Mime_CharsetObserver { @@ -28,8 +26,8 @@ interface Swift_Mime_HeaderSet extends Swift_Mime_CharsetObserver /** * 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); @@ -71,8 +69,8 @@ interface Swift_Mime_HeaderSet extends Swift_Mime_CharsetObserver * * 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 */ @@ -97,8 +95,8 @@ interface Swift_Mime_HeaderSet extends Swift_Mime_CharsetObserver * 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 */ @@ -114,19 +112,19 @@ interface Swift_Mime_HeaderSet extends Swift_Mime_CharsetObserver public function getAll($name = null); /** - * Return the name of all Headers + * Return the name of all Headers. * * @return array */ 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); @@ -140,7 +138,7 @@ interface Swift_Mime_HeaderSet extends Swift_Mime_CharsetObserver /** * Create a new instance of this HeaderSet. * - * @return Swift_Mime_HeaderSet + * @return self */ public function newInstance(); diff --git a/lib/swiftmailer/lib/classes/Swift/Mime/Headers/AbstractHeader.php b/lib/swiftmailer/lib/classes/Swift/Mime/Headers/AbstractHeader.php index cdf79036a..3a6d7b39e 100644 --- a/lib/swiftmailer/lib/classes/Swift/Mime/Headers/AbstractHeader.php +++ b/lib/swiftmailer/lib/classes/Swift/Mime/Headers/AbstractHeader.php @@ -11,9 +11,7 @@ /** * An abstract base MIME Header. * - * @package Swift - * @subpackage Mime - * @author Chris Corbyn + * @author Chris Corbyn */ abstract class Swift_Mime_Headers_AbstractHeader implements Swift_Mime_Header { @@ -179,7 +177,7 @@ abstract class Swift_Mime_Headers_AbstractHeader implements Swift_Mime_Header /** * Set the maximum length of lines in the header (excluding EOL). * - * @param int $lineLength + * @param int $lineLength */ public function setMaxLineLength($lineLength) { @@ -200,9 +198,9 @@ abstract class Swift_Mime_Headers_AbstractHeader implements Swift_Mime_Header /** * Get this Header rendered as a RFC 2822 compliant string. * - * @return string - * * @throws Swift_RfcComplianceException + * + * @return string */ public function toString() { @@ -221,8 +219,6 @@ abstract class Swift_Mime_Headers_AbstractHeader implements Swift_Mime_Header return $this->toString(); } - // -- Points of extension - /** * Set the name of this Header field. * @@ -249,18 +245,19 @@ abstract class Swift_Mime_Headers_AbstractHeader implements Swift_Mime_Header // Treat token as exactly what was given $phraseStr = $string; // If it's not valid - if (!preg_match('/^' . $this->getGrammar()->getDefinition('phrase') . '$/D', $phraseStr)) { + if (!preg_match('/^'.$this->getGrammar()->getDefinition('phrase').'$/D', $phraseStr)) { // .. but it is just ascii text, try escaping some characters // and make it a quoted-string - if (preg_match('/^' . $this->getGrammar()->getDefinition('text') . '*$/D', $phraseStr)) { + if (preg_match('/^'.$this->getGrammar()->getDefinition('text').'*$/D', $phraseStr)) { $phraseStr = $this->getGrammar()->escapeSpecials( $phraseStr, array('"'), $this->getGrammar()->getSpecials() ); - $phraseStr = '"' . $phraseStr . '"'; - } else { // ... otherwise it needs encoding + $phraseStr = '"'.$phraseStr.'"'; + } else { + // ... otherwise it needs encoding // Determine space remaining on line if first line if ($shorten) { - $usedLength = strlen($header->getFieldName() . ': '); + $usedLength = strlen($header->getFieldName().': '); } else { $usedLength = 0; } @@ -299,7 +296,7 @@ abstract class Swift_Mime_Headers_AbstractHeader implements Swift_Mime_Header } if (-1 == $usedLength) { - $usedLength = strlen($header->getFieldName() . ': ') + strlen($value); + $usedLength = strlen($header->getFieldName().': ') + strlen($value); } $value .= $this->getTokenAsEncodedWord($token, $usedLength); @@ -358,8 +355,8 @@ abstract class Swift_Mime_Headers_AbstractHeader implements Swift_Mime_Header /** * 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 */ @@ -368,13 +365,14 @@ abstract class Swift_Mime_Headers_AbstractHeader implements Swift_Mime_Header // Adjust $firstLineOffset to account for space needed for syntax $charsetDecl = $this->_charset; if (isset($this->_lang)) { - $charsetDecl .= '*' . $this->_lang; + $charsetDecl .= '*'.$this->_lang; } $encodingWrapperLength = strlen( - '=?' . $charsetDecl . '?' . $this->_encoder->getName() . '??=' + '=?'.$charsetDecl.'?'.$this->_encoder->getName().'??=' ); - if ($firstLineOffset >= 75) { //Does this logic need to be here? + if ($firstLineOffset >= 75) { + //Does this logic need to be here? $firstLineOffset = 0; } @@ -384,11 +382,12 @@ abstract class Swift_Mime_Headers_AbstractHeader implements Swift_Mime_Header ) ); - if (strtolower($this->_charset) !== 'iso-2022-jp') { // special encoding for iso-2022-jp using mb_encode_mimeheader + if (strtolower($this->_charset) !== 'iso-2022-jp') { + // special encoding for iso-2022-jp using mb_encode_mimeheader foreach ($encodedTextLines as $lineNum => $line) { - $encodedTextLines[$lineNum] = '=?' . $charsetDecl . - '?' . $this->_encoder->getName() . - '?' . $line . '?='; + $encodedTextLines[$lineNum] = '=?'.$charsetDecl. + '?'.$this->_encoder->getName(). + '?'.$line.'?='; } } @@ -430,7 +429,7 @@ abstract class Swift_Mime_Headers_AbstractHeader implements Swift_Mime_Header /** * Clear the cached value if $condition is met. * - * @param bool $condition + * @param bool $condition */ protected function clearCachedValueIf($condition) { @@ -439,8 +438,6 @@ abstract class Swift_Mime_Headers_AbstractHeader implements Swift_Mime_Header } } - // -- Private methods - /** * Generate a list of all tokens in the final header. * @@ -450,7 +447,7 @@ abstract class Swift_Mime_Headers_AbstractHeader implements Swift_Mime_Header */ protected function toTokens($string = null) { - if (is_null($string)) { + if (null === $string) { $string = $this->getFieldBody(); } @@ -463,6 +460,7 @@ abstract class Swift_Mime_Headers_AbstractHeader implements Swift_Mime_Header $tokens[] = $newToken; } } + return $tokens; } @@ -478,18 +476,17 @@ abstract class Swift_Mime_Headers_AbstractHeader implements Swift_Mime_Header { $lineCount = 0; $headerLines = array(); - $headerLines[] = $this->_name . ': '; - $currentLine =& $headerLines[$lineCount++]; + $headerLines[] = $this->_name.': '; + $currentLine = &$headerLines[$lineCount++]; // Build all tokens back into compliant header foreach ($tokens as $i => $token) { // Line longer than specified maximum or token was just a new line if (("\r\n" == $token) || - ($i > 0 && strlen($currentLine . $token) > $this->_lineLength) - && 0 < strlen($currentLine)) - { + ($i > 0 && strlen($currentLine.$token) > $this->_lineLength) + && 0 < strlen($currentLine)) { $headerLines[] = ''; - $currentLine =& $headerLines[$lineCount++]; + $currentLine = &$headerLines[$lineCount++]; } // Append token to the line @@ -499,6 +496,6 @@ abstract class Swift_Mime_Headers_AbstractHeader implements Swift_Mime_Header } // Implode with FWS (RFC 2822, 2.2.3) - return implode("\r\n", $headerLines) . "\r\n"; + return implode("\r\n", $headerLines)."\r\n"; } } diff --git a/lib/swiftmailer/lib/classes/Swift/Mime/Headers/DateHeader.php b/lib/swiftmailer/lib/classes/Swift/Mime/Headers/DateHeader.php index 015bc4421..4075cbfa1 100644 --- a/lib/swiftmailer/lib/classes/Swift/Mime/Headers/DateHeader.php +++ b/lib/swiftmailer/lib/classes/Swift/Mime/Headers/DateHeader.php @@ -11,9 +11,7 @@ /** * A Date MIME Header for Swift Mailer. * - * @package Swift - * @subpackage Mime - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_Mime_Headers_DateHeader extends Swift_Mime_Headers_AbstractHeader { @@ -61,7 +59,7 @@ class Swift_Mime_Headers_DateHeader extends Swift_Mime_Headers_AbstractHeader * * This method takes a UNIX timestamp. * - * @param int $model + * @param int $model */ public function setFieldBodyModel($model) { @@ -93,11 +91,11 @@ class Swift_Mime_Headers_DateHeader extends Swift_Mime_Headers_AbstractHeader /** * Set the UNIX timestamp of the Date in this Header. * - * @param int $timestamp + * @param int $timestamp */ public function setTimestamp($timestamp) { - if (!is_null($timestamp)) { + if (null !== $timestamp) { $timestamp = (int) $timestamp; } $this->clearCachedValueIf($this->_timestamp != $timestamp); diff --git a/lib/swiftmailer/lib/classes/Swift/Mime/Headers/IdentificationHeader.php b/lib/swiftmailer/lib/classes/Swift/Mime/Headers/IdentificationHeader.php index 1d00015e8..b114506b4 100644 --- a/lib/swiftmailer/lib/classes/Swift/Mime/Headers/IdentificationHeader.php +++ b/lib/swiftmailer/lib/classes/Swift/Mime/Headers/IdentificationHeader.php @@ -11,9 +11,7 @@ /** * An ID MIME Header for something like Message-ID or Content-ID. * - * @package Swift - * @subpackage Mime - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_Mime_Headers_IdentificationHeader extends Swift_Mime_Headers_AbstractHeader { @@ -141,9 +139,9 @@ class Swift_Mime_Headers_IdentificationHeader extends Swift_Mime_Headers_Abstrac * * @see toString() * - * @return string - * * @throws Swift_RfcComplianceException + * + * @return string */ public function getFieldBody() { @@ -151,7 +149,7 @@ class Swift_Mime_Headers_IdentificationHeader extends Swift_Mime_Headers_Abstrac $angleAddrs = array(); foreach ($this->_ids as $id) { - $angleAddrs[] = '<' . $id . '>'; + $angleAddrs[] = '<'.$id.'>'; } $this->setCachedValue(implode(' ', $angleAddrs)); @@ -170,13 +168,12 @@ class Swift_Mime_Headers_IdentificationHeader extends Swift_Mime_Headers_Abstrac private function _assertValidId($id) { if (!preg_match( - '/^' . $this->getGrammar()->getDefinition('id-left') . '@' . - $this->getGrammar()->getDefinition('id-right') . '$/D', + '/^'.$this->getGrammar()->getDefinition('id-left').'@'. + $this->getGrammar()->getDefinition('id-right').'$/D', $id - )) - { + )) { throw new Swift_RfcComplianceException( - 'Invalid ID given <' . $id . '>' + 'Invalid ID given <'.$id.'>' ); } } diff --git a/lib/swiftmailer/lib/classes/Swift/Mime/Headers/MailboxHeader.php b/lib/swiftmailer/lib/classes/Swift/Mime/Headers/MailboxHeader.php index 766d6a18d..e4567fc80 100644 --- a/lib/swiftmailer/lib/classes/Swift/Mime/Headers/MailboxHeader.php +++ b/lib/swiftmailer/lib/classes/Swift/Mime/Headers/MailboxHeader.php @@ -11,9 +11,7 @@ /** * A Mailbox Address MIME Header for something like From or Sender. * - * @package Swift - * @subpackage Mime - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_Mime_Headers_MailboxHeader extends Swift_Mime_Headers_AbstractHeader { @@ -70,9 +68,9 @@ class Swift_Mime_Headers_MailboxHeader extends Swift_Mime_Headers_AbstractHeader * * This method returns an associative array like {@link getNameAddresses()} * - * @return array - * * @throws Swift_RfcComplianceException + * + * @return array */ public function getFieldBodyModel() { @@ -130,9 +128,9 @@ class Swift_Mime_Headers_MailboxHeader extends Swift_Mime_Headers_AbstractHeader * @see getNameAddresses() * @see toString() * - * @return string[] - * * @throws Swift_RfcComplianceException + * + * @return string[] */ public function getNameAddressStrings() { @@ -226,22 +224,20 @@ class Swift_Mime_Headers_MailboxHeader extends Swift_Mime_Headers_AbstractHeader * * @see toString() * - * @return string - * * @throws Swift_RfcComplianceException + * + * @return string */ public function getFieldBody() { // Compute the string value of the header only if needed - if (is_null($this->getCachedValue())) { + if (null === $this->getCachedValue()) { $this->setCachedValue($this->createMailboxListString($this->_mailboxes)); } return $this->getCachedValue(); } - // -- Points of extension - /** * Normalizes a user-input list of mailboxes into consistent key=>value pairs. * @@ -254,7 +250,8 @@ class Swift_Mime_Headers_MailboxHeader extends Swift_Mime_Headers_AbstractHeader $actualMailboxes = array(); foreach ($mailboxes as $key => $value) { - if (is_string($key)) { //key is email addr + if (is_string($key)) { + //key is email addr $address = $key; $name = $value; } else { @@ -271,16 +268,14 @@ class Swift_Mime_Headers_MailboxHeader extends Swift_Mime_Headers_AbstractHeader /** * 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); } /** @@ -288,9 +283,9 @@ class Swift_Mime_Headers_MailboxHeader extends Swift_Mime_Headers_AbstractHeader * * @param string[] $mailboxes * - * @return string - * * @throws Swift_RfcComplianceException + * + * @return string */ protected function createMailboxListString(array $mailboxes) { @@ -300,8 +295,9 @@ class Swift_Mime_Headers_MailboxHeader extends Swift_Mime_Headers_AbstractHeader /** * Redefine the encoding requirements for mailboxes. * - * Commas and semicolons are used to separate - * multiple addresses, and should therefore be encoded + * All "specials" must be encoded as the full header value will not be quoted + * + * @see RFC 2822 3.2.1 * * @param string $token * @@ -309,11 +305,9 @@ class Swift_Mime_Headers_MailboxHeader extends Swift_Mime_Headers_AbstractHeader */ protected function tokenNeedsEncoding($token) { - return preg_match('/[,;]/', $token) || parent::tokenNeedsEncoding($token); + return preg_match('/[()<>\[\]:;@\,."]/', $token) || parent::tokenNeedsEncoding($token); } - // -- Private methods - /** * Return an array of strings conforming the the name-addr spec of RFC 2822. * @@ -327,9 +321,9 @@ class Swift_Mime_Headers_MailboxHeader extends Swift_Mime_Headers_AbstractHeader foreach ($mailboxes as $email => $name) { $mailboxStr = $email; - if (!is_null($name)) { + if (null !== $name) { $nameStr = $this->createDisplayNameString($name, empty($strings)); - $mailboxStr = $nameStr . ' <' . $mailboxStr . '>'; + $mailboxStr = $nameStr.' <'.$mailboxStr.'>'; } $strings[] = $mailboxStr; } @@ -346,11 +340,10 @@ class Swift_Mime_Headers_MailboxHeader extends Swift_Mime_Headers_AbstractHeader */ private function _assertValidAddress($address) { - if (!preg_match('/^' . $this->getGrammar()->getDefinition('addr-spec') . '$/D', - $address)) - { + if (!preg_match('/^'.$this->getGrammar()->getDefinition('addr-spec').'$/D', + $address)) { throw new Swift_RfcComplianceException( - 'Address in mailbox given [' . $address . + 'Address in mailbox given ['.$address. '] does not comply with RFC 2822, 3.6.2.' ); } diff --git a/lib/swiftmailer/lib/classes/Swift/Mime/Headers/OpenDKIMHeader.php b/lib/swiftmailer/lib/classes/Swift/Mime/Headers/OpenDKIMHeader.php index ecab7380b..d74955007 100644 --- a/lib/swiftmailer/lib/classes/Swift/Mime/Headers/OpenDKIMHeader.php +++ b/lib/swiftmailer/lib/classes/Swift/Mime/Headers/OpenDKIMHeader.php @@ -9,11 +9,9 @@ */ /** - * An OpenDKIM Specific Header using only raw header datas without encoding + * An OpenDKIM Specific Header using only raw header datas without encoding. * - * @package Swift - * @subpackage Mime - * @author De Cock Xavier + * @author De Cock Xavier */ class Swift_Mime_Headers_OpenDKIMHeader implements Swift_Mime_Header { @@ -23,19 +21,16 @@ class Swift_Mime_Headers_OpenDKIMHeader implements Swift_Mime_Header * @var string */ 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) { @@ -108,7 +103,7 @@ class Swift_Mime_Headers_OpenDKIMHeader implements Swift_Mime_Header { return $this->_value; } - + /** * Get this Header rendered as a RFC 2822 compliant string. * @@ -116,24 +111,23 @@ class Swift_Mime_Headers_OpenDKIMHeader implements Swift_Mime_Header */ public function toString() { - return $this->_fieldName.': '.$this->_value; + return $this->_fieldName.': '.$this->_value; } - + /** - * Set the Header FieldName - * @see Swift_Mime_Header::getFieldName() - */ - public function getFieldName() - { + * Set the Header FieldName. + * + * @see Swift_Mime_Header::getFieldName() + */ + public function getFieldName() + { return $this->_fieldName; } - /** - * Ignored + /** + * Ignored. */ - public function setCharset($charset) + public function setCharset($charset) { - } - } diff --git a/lib/swiftmailer/lib/classes/Swift/Mime/Headers/ParameterizedHeader.php b/lib/swiftmailer/lib/classes/Swift/Mime/Headers/ParameterizedHeader.php index 7f52857e1..c1777d333 100644 --- a/lib/swiftmailer/lib/classes/Swift/Mime/Headers/ParameterizedHeader.php +++ b/lib/swiftmailer/lib/classes/Swift/Mime/Headers/ParameterizedHeader.php @@ -11,9 +11,7 @@ /** * An abstract base MIME Header. * - * @package Swift - * @subpackage Mime - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_Mime_Headers_ParameterizedHeader extends Swift_Mime_Headers_UnstructuredHeader implements Swift_Mime_ParameterizedHeader { @@ -100,9 +98,7 @@ class Swift_Mime_Headers_ParameterizedHeader extends Swift_Mime_Headers_Unstruct { $params = $this->getParameters(); - return array_key_exists($parameter, $params) - ? $params[$parameter] - : null; + return array_key_exists($parameter, $params) ? $params[$parameter] : null; } /** @@ -135,17 +131,15 @@ class Swift_Mime_Headers_ParameterizedHeader extends Swift_Mime_Headers_Unstruct { $body = parent::getFieldBody(); foreach ($this->_params as $name => $value) { - if (!is_null($value)) { + if (null !== $value) { // Add the parameter - $body .= '; ' . $this->_createParameter($name, $value); + $body .= '; '.$this->_createParameter($name, $value); } } return $body; } - // -- Protected methods - /** * Generate a list of all tokens in the final header. * @@ -162,11 +156,11 @@ class Swift_Mime_Headers_ParameterizedHeader extends Swift_Mime_Headers_Unstruct // Try creating any parameters foreach ($this->_params as $name => $value) { - if (!is_null($value)) { + if (null !== $value) { // Add the semi-colon separator - $tokens[count($tokens)-1] .= ';'; + $tokens[count($tokens) - 1] .= ';'; $tokens = array_merge($tokens, $this->generateTokenLines( - ' ' . $this->_createParameter($name, $value) + ' '.$this->_createParameter($name, $value) )); } } @@ -174,8 +168,6 @@ class Swift_Mime_Headers_ParameterizedHeader extends Swift_Mime_Headers_Unstruct return $tokens; } - // -- Private methods - /** * Render a RFC 2047 compliant header parameter from the $name and $value. * @@ -190,19 +182,19 @@ class Swift_Mime_Headers_ParameterizedHeader extends Swift_Mime_Headers_Unstruct $encoded = false; // Allow room for parameter name, indices, "=" and DQUOTEs - $maxValueLength = $this->getMaxLineLength() - strlen($name . '=*N"";') - 1; + $maxValueLength = $this->getMaxLineLength() - strlen($name.'=*N"";') - 1; $firstLineOffset = 0; // If it's not already a valid parameter value... - if (!preg_match('/^' . self::TOKEN_REGEX . '$/D', $value)) { + if (!preg_match('/^'.self::TOKEN_REGEX.'$/D', $value)) { // TODO: text, or something else?? // ... and it's not ascii - if (!preg_match('/^' . $this->getGrammar()->getDefinition('text') . '*$/D', $value)) { + if (!preg_match('/^'.$this->getGrammar()->getDefinition('text').'*$/D', $value)) { $encoded = true; // Allow space for the indices, charset and language - $maxValueLength = $this->getMaxLineLength() - strlen($name . '*N*="";') - 1; + $maxValueLength = $this->getMaxLineLength() - strlen($name.'*N*="";') - 1; $firstLineOffset = strlen( - $this->getCharset() . "'" . $this->getLanguage() . "'" + $this->getCharset()."'".$this->getLanguage()."'" ); } } @@ -213,7 +205,8 @@ class Swift_Mime_Headers_ParameterizedHeader extends Swift_Mime_Headers_Unstruct $value = $this->_paramEncoder->encodeString( $origValue, $firstLineOffset, $maxValueLength, $this->getCharset() ); - } else { // We have to go against RFC 2183/2231 in some areas for interoperability + } else { + // We have to go against RFC 2183/2231 in some areas for interoperability $value = $this->getTokenAsEncodedWord($origValue); $encoded = false; } @@ -225,13 +218,13 @@ class Swift_Mime_Headers_ParameterizedHeader extends Swift_Mime_Headers_Unstruct if (count($valueLines) > 1) { $paramLines = array(); foreach ($valueLines as $i => $line) { - $paramLines[] = $name . '*' . $i . + $paramLines[] = $name.'*'.$i. $this->_getEndOfParameterValue($line, true, $i == 0); } return implode(";\r\n ", $paramLines); } else { - return $name . $this->_getEndOfParameterValue( + return $name.$this->_getEndOfParameterValue( $valueLines[0], $encoded, true ); } @@ -240,26 +233,26 @@ class Swift_Mime_Headers_ParameterizedHeader extends Swift_Mime_Headers_Unstruct /** * 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 */ private function _getEndOfParameterValue($value, $encoded = false, $firstLine = false) { - if (!preg_match('/^' . self::TOKEN_REGEX . '$/D', $value)) { - $value = '"' . $value . '"'; + if (!preg_match('/^'.self::TOKEN_REGEX.'$/D', $value)) { + $value = '"'.$value.'"'; } $prepend = '='; if ($encoded) { $prepend = '*='; if ($firstLine) { - $prepend = '*=' . $this->getCharset() . "'" . $this->getLanguage() . + $prepend = '*='.$this->getCharset()."'".$this->getLanguage(). "'"; } } - return $prepend . $value; + return $prepend.$value; } } diff --git a/lib/swiftmailer/lib/classes/Swift/Mime/Headers/PathHeader.php b/lib/swiftmailer/lib/classes/Swift/Mime/Headers/PathHeader.php index bfecf3f47..4a814b122 100644 --- a/lib/swiftmailer/lib/classes/Swift/Mime/Headers/PathHeader.php +++ b/lib/swiftmailer/lib/classes/Swift/Mime/Headers/PathHeader.php @@ -11,9 +11,7 @@ /** * A Path Header in Swift Mailer, such a Return-Path. * - * @package Swift - * @subpackage Mime - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_Mime_Headers_PathHeader extends Swift_Mime_Headers_AbstractHeader { @@ -82,7 +80,7 @@ class Swift_Mime_Headers_PathHeader extends Swift_Mime_Headers_AbstractHeader */ public function setAddress($address) { - if (is_null($address)) { + if (null === $address) { $this->_address = null; } elseif ('' == $address) { $this->_address = ''; @@ -119,7 +117,7 @@ class Swift_Mime_Headers_PathHeader extends Swift_Mime_Headers_AbstractHeader { if (!$this->getCachedValue()) { if (isset($this->_address)) { - $this->setCachedValue('<' . $this->_address . '>'); + $this->setCachedValue('<'.$this->_address.'>'); } } @@ -135,9 +133,8 @@ class Swift_Mime_Headers_PathHeader extends Swift_Mime_Headers_AbstractHeader */ private function _assertValidAddress($address) { - if (!preg_match('/^' . $this->getGrammar()->getDefinition('addr-spec') . '$/D', - $address)) - { + if (!preg_match('/^'.$this->getGrammar()->getDefinition('addr-spec').'$/D', + $address)) { throw new Swift_RfcComplianceException( 'Address set in PathHeader does not comply with addr-spec of RFC 2822.' ); diff --git a/lib/swiftmailer/lib/classes/Swift/Mime/Headers/UnstructuredHeader.php b/lib/swiftmailer/lib/classes/Swift/Mime/Headers/UnstructuredHeader.php index 2de49b4d0..86177f14a 100644 --- a/lib/swiftmailer/lib/classes/Swift/Mime/Headers/UnstructuredHeader.php +++ b/lib/swiftmailer/lib/classes/Swift/Mime/Headers/UnstructuredHeader.php @@ -11,9 +11,7 @@ /** * A Simple MIME Header. * - * @package Swift - * @subpackage Mime - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_Mime_Headers_UnstructuredHeader extends Swift_Mime_Headers_AbstractHeader { diff --git a/lib/swiftmailer/lib/classes/Swift/Mime/Message.php b/lib/swiftmailer/lib/classes/Swift/Mime/Message.php index 59df2f2e9..9b36d2162 100644 --- a/lib/swiftmailer/lib/classes/Swift/Mime/Message.php +++ b/lib/swiftmailer/lib/classes/Swift/Mime/Message.php @@ -11,9 +11,7 @@ /** * A Message (RFC 2822) object. * - * @package Swift - * @subpackage Mime - * @author Chris Corbyn + * @author Chris Corbyn */ interface Swift_Mime_Message extends Swift_Mime_MimeEntity { @@ -41,7 +39,7 @@ interface Swift_Mime_Message extends Swift_Mime_MimeEntity /** * Set the origination date of the message as a UNIX timestamp. * - * @param int $date + * @param int $date */ public function setDate($date); diff --git a/lib/swiftmailer/lib/classes/Swift/Mime/MimeEntity.php b/lib/swiftmailer/lib/classes/Swift/Mime/MimeEntity.php index bc9f2ad37..30f460cdc 100644 --- a/lib/swiftmailer/lib/classes/Swift/Mime/MimeEntity.php +++ b/lib/swiftmailer/lib/classes/Swift/Mime/MimeEntity.php @@ -11,9 +11,7 @@ /** * A MIME entity, such as an attachment. * - * @package Swift - * @subpackage Mime - * @author Chris Corbyn + * @author Chris Corbyn */ interface Swift_Mime_MimeEntity extends Swift_Mime_CharsetObserver, Swift_Mime_EncodingObserver { @@ -33,6 +31,7 @@ interface Swift_Mime_MimeEntity extends Swift_Mime_CharsetObserver, Swift_Mime_E * Get the level at which this entity shall be nested in final document. * * The lower the value, the more outermost the entity will be nested. + * * @see LEVEL_TOP, LEVEL_MIXED, LEVEL_RELATED, LEVEL_ALTERNATIVE * * @return int @@ -41,6 +40,7 @@ interface Swift_Mime_MimeEntity extends Swift_Mime_CharsetObserver, Swift_Mime_E /** * Get the qualified content-type of this mime entity. + * * @return string */ public function getContentType(); @@ -80,7 +80,7 @@ interface Swift_Mime_MimeEntity extends Swift_Mime_CharsetObserver, Swift_Mime_E /** * Get the collection of Headers in this Mime entity. * - * @return Swift_Mime_Header[] + * @return Swift_Mime_HeaderSet */ public function getHeaders(); diff --git a/lib/swiftmailer/lib/classes/Swift/Mime/MimePart.php b/lib/swiftmailer/lib/classes/Swift/Mime/MimePart.php index 1efcc8cd7..4564fef6f 100644 --- a/lib/swiftmailer/lib/classes/Swift/Mime/MimePart.php +++ b/lib/swiftmailer/lib/classes/Swift/Mime/MimePart.php @@ -11,9 +11,7 @@ /** * A MIME part, in a multipart message. * - * @package Swift - * @subpackage Mime - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_Mime_MimePart extends Swift_Mime_SimpleMimeEntity { @@ -42,7 +40,7 @@ class Swift_Mime_MimePart extends Swift_Mime_SimpleMimeEntity { parent::__construct($headers, $encoder, $cache, $grammar); $this->setContentType('text/plain'); - if (!is_null($charset)) { + if (null !== $charset) { $this->setCharset($charset); } } @@ -55,7 +53,7 @@ class Swift_Mime_MimePart extends Swift_Mime_SimpleMimeEntity * @param string $contentType optional * @param string $charset optional * - * @return Swift_Mime_MimePart + * @return $this */ public function setBody($body, $contentType = null, $charset = null) { @@ -84,7 +82,7 @@ class Swift_Mime_MimePart extends Swift_Mime_SimpleMimeEntity * * @param string $charset * - * @return Swift_Mime_MimePart + * @return $this */ public function setCharset($charset) { @@ -113,7 +111,7 @@ class Swift_Mime_MimePart extends Swift_Mime_SimpleMimeEntity * * @param string $format * - * @return Swift_Mime_MimePart + * @return $this */ public function setFormat($format) { @@ -130,17 +128,15 @@ class Swift_Mime_MimePart extends Swift_Mime_SimpleMimeEntity */ public function getDelSp() { - return ($this->_getHeaderParameter('Content-Type', 'delsp') == 'yes') - ? true - : false; + return 'yes' == $this->_getHeaderParameter('Content-Type', 'delsp') ? true : false; } /** * Turn delsp on or off for this entity. * - * @param bool $delsp + * @param bool $delsp * - * @return Swift_Mime_MimePart + * @return $this */ public function setDelSp($delsp = true) { @@ -173,8 +169,6 @@ class Swift_Mime_MimePart extends Swift_Mime_SimpleMimeEntity $this->setCharset($charset); } - // -- Protected methods - /** Fix the content-type and encoding of this entity */ protected function _fixHeaders() { @@ -200,12 +194,12 @@ class Swift_Mime_MimePart extends Swift_Mime_SimpleMimeEntity protected function _convertString($string) { $charset = strtolower($this->getCharset()); - if (!in_array($charset, array('utf-8', 'iso-8859-1', ''))) { + if (!in_array($charset, array('utf-8', 'iso-8859-1', 'iso-8859-15', ''))) { // mb_convert_encoding must be the first one to check, since iconv cannot convert some words. if (function_exists('mb_convert_encoding')) { - $string = mb_convert_encoding($string, 'utf-8', $charset); + $string = mb_convert_encoding($string, $charset, 'utf-8'); } elseif (function_exists('iconv')) { - $string = iconv($charset, 'utf-8//TRANSLIT//IGNORE', $string); + $string = iconv('utf-8//TRANSLIT//IGNORE', $charset, $string); } else { throw new Swift_SwiftException('No suitable convert encoding function (use UTF-8 as your charset or install the mbstring or iconv extension).'); } diff --git a/lib/swiftmailer/lib/classes/Swift/Mime/ParameterizedHeader.php b/lib/swiftmailer/lib/classes/Swift/Mime/ParameterizedHeader.php index 95172ec40..e15c6ef95 100644 --- a/lib/swiftmailer/lib/classes/Swift/Mime/ParameterizedHeader.php +++ b/lib/swiftmailer/lib/classes/Swift/Mime/ParameterizedHeader.php @@ -11,9 +11,7 @@ /** * A MIME Header with parameters. * - * @package Swift - * @subpackage Mime - * @author Chris Corbyn + * @author Chris Corbyn */ interface Swift_Mime_ParameterizedHeader extends Swift_Mime_Header { diff --git a/lib/swiftmailer/lib/classes/Swift/Mime/SimpleHeaderFactory.php b/lib/swiftmailer/lib/classes/Swift/Mime/SimpleHeaderFactory.php index b82e33b4d..1ca504e75 100644 --- a/lib/swiftmailer/lib/classes/Swift/Mime/SimpleHeaderFactory.php +++ b/lib/swiftmailer/lib/classes/Swift/Mime/SimpleHeaderFactory.php @@ -11,9 +11,7 @@ /** * Creates MIME headers. * - * @package Swift - * @subpackage Mime - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_Mime_SimpleHeaderFactory implements Swift_Mime_HeaderFactory { @@ -66,8 +64,9 @@ class Swift_Mime_SimpleHeaderFactory implements Swift_Mime_HeaderFactory /** * 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 */ @@ -113,12 +112,7 @@ class Swift_Mime_SimpleHeaderFactory implements Swift_Mime_HeaderFactory public function createParameterizedHeader($name, $value = null, $params = array()) { - $header = new Swift_Mime_Headers_ParameterizedHeader($name, - $this->_encoder, (strtolower($name) == 'content-disposition') - ? $this->_paramEncoder - : null, - $this->_grammar - ); + $header = new Swift_Mime_Headers_ParameterizedHeader($name, $this->_encoder, strtolower($name) == 'content-disposition' ? $this->_paramEncoder : null, $this->_grammar); if (isset($value)) { $header->setFieldBodyModel($value); } @@ -180,7 +174,14 @@ class Swift_Mime_SimpleHeaderFactory implements Swift_Mime_HeaderFactory $this->_paramEncoder->charsetChanged($charset); } - // -- Private methods + /** + * Make a deep copy of object. + */ + public function __clone() + { + $this->_encoder = clone $this->_encoder; + $this->_paramEncoder = clone $this->_paramEncoder; + } /** Apply the charset to the Header */ private function _setHeaderCharset(Swift_Mime_Header $header) diff --git a/lib/swiftmailer/lib/classes/Swift/Mime/SimpleHeaderSet.php b/lib/swiftmailer/lib/classes/Swift/Mime/SimpleHeaderSet.php index bd6ed6bcd..a06ce7247 100644 --- a/lib/swiftmailer/lib/classes/Swift/Mime/SimpleHeaderSet.php +++ b/lib/swiftmailer/lib/classes/Swift/Mime/SimpleHeaderSet.php @@ -11,9 +11,7 @@ /** * A collection of MIME headers. * - * @package Swift - * @subpackage Mime - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_Mime_SimpleHeaderSet implements Swift_Mime_HeaderSet { @@ -73,8 +71,8 @@ class Swift_Mime_SimpleHeaderSet implements Swift_Mime_HeaderSet /** * 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) { @@ -133,8 +131,8 @@ class Swift_Mime_SimpleHeaderSet implements Swift_Mime_HeaderSet * * 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 */ @@ -142,7 +140,16 @@ class Swift_Mime_SimpleHeaderSet implements Swift_Mime_HeaderSet { $lowerName = strtolower($name); - return array_key_exists($lowerName, $this->_headers) && array_key_exists($index, $this->_headers[$lowerName]); + if (!array_key_exists($lowerName, $this->_headers)) { + return false; + } + + if (func_num_args() < 2) { + // index was not specified, so we only need to check that there is at least one header value set + return (bool) count($this->_headers[$lowerName]); + } + + return array_key_exists($index, $this->_headers[$lowerName]); } /** @@ -168,17 +175,25 @@ class Swift_Mime_SimpleHeaderSet implements Swift_Mime_HeaderSet * 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); - return $this->_headers[$lowerName][$index]; + if (func_num_args() < 2) { + if ($this->has($name)) { + $values = array_values($this->_headers[$name]); + + return array_shift($values); + } + } else { + if ($this->has($name, $index)) { + return $this->_headers[$name][$index]; + } } } @@ -209,7 +224,7 @@ class Swift_Mime_SimpleHeaderSet implements Swift_Mime_HeaderSet } /** - * Return the name of all Headers + * Return the name of all Headers. * * @return array */ @@ -223,13 +238,13 @@ class Swift_Mime_SimpleHeaderSet implements Swift_Mime_HeaderSet 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) { @@ -251,7 +266,7 @@ class Swift_Mime_SimpleHeaderSet implements Swift_Mime_HeaderSet /** * Create a new instance of this HeaderSet. * - * @return Swift_Mime_HeaderSet + * @return self */ public function newInstance() { @@ -327,8 +342,6 @@ class Swift_Mime_SimpleHeaderSet implements Swift_Mime_HeaderSet return $this->toString(); } - // -- Private methods - /** Save a Header to the internal collection */ private function _storeHeader($name, Swift_Mime_Header $header, $offset = null) { @@ -353,12 +366,13 @@ class Swift_Mime_SimpleHeaderSet implements Swift_Mime_HeaderSet { $lowerA = strtolower($a); $lowerB = strtolower($b); - $aPos = array_key_exists($lowerA, $this->_order) - ? $this->_order[$lowerA] - : -1; - $bPos = array_key_exists($lowerB, $this->_order) - ? $this->_order[$lowerB] - : -1; + $aPos = array_key_exists($lowerA, $this->_order) ? $this->_order[$lowerA] : -1; + $bPos = array_key_exists($lowerB, $this->_order) ? $this->_order[$lowerB] : -1; + + if (-1 === $aPos && -1 === $bPos) { + // just be sure to be determinist here + return $a > $b ? -1 : 1; + } if ($aPos == -1) { return 1; @@ -366,7 +380,7 @@ class Swift_Mime_SimpleHeaderSet implements Swift_Mime_HeaderSet return -1; } - return ($aPos < $bPos) ? -1 : 1; + return $aPos < $bPos ? -1 : 1; } /** Test if the given Header is always displayed */ @@ -384,4 +398,17 @@ class Swift_Mime_SimpleHeaderSet implements Swift_Mime_HeaderSet } } } + + /** + * Make a deep copy of object. + */ + public function __clone() + { + $this->_factory = clone $this->_factory; + foreach ($this->_headers as $groupKey => $headerGroup) { + foreach ($headerGroup as $key => $header) { + $this->_headers[$groupKey][$key] = clone $header; + } + } + } } diff --git a/lib/swiftmailer/lib/classes/Swift/Mime/SimpleMessage.php b/lib/swiftmailer/lib/classes/Swift/Mime/SimpleMessage.php index 4b2c88b4d..72d40cee0 100644 --- a/lib/swiftmailer/lib/classes/Swift/Mime/SimpleMessage.php +++ b/lib/swiftmailer/lib/classes/Swift/Mime/SimpleMessage.php @@ -11,12 +11,16 @@ /** * The default email message class. * - * @package Swift - * @subpackage Mime - * @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. * @@ -45,7 +49,7 @@ class Swift_Mime_SimpleMessage extends Swift_Mime_MimePart implements Swift_Mime 'Bcc', 'MIME-Version', 'Content-Type', - 'Content-Transfer-Encoding' + 'Content-Transfer-Encoding', )); $this->getHeaders()->setAlwaysDisplayed(array('Date', 'Message-ID', 'From')); $this->getHeaders()->addTextHeader('MIME-Version', '1.0'); @@ -69,7 +73,7 @@ class Swift_Mime_SimpleMessage extends Swift_Mime_MimePart implements Swift_Mime * * @param string $subject * - * @return Swift_Mime_SimpleMessage + * @return $this */ public function setSubject($subject) { @@ -93,9 +97,9 @@ class Swift_Mime_SimpleMessage extends Swift_Mime_MimePart implements Swift_Mime /** * 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) { @@ -121,7 +125,7 @@ class Swift_Mime_SimpleMessage extends Swift_Mime_MimePart implements Swift_Mime * * @param string $address * - * @return Swift_Mime_SimpleMessage + * @return $this */ public function setReturnPath($address) { @@ -150,7 +154,7 @@ class Swift_Mime_SimpleMessage extends Swift_Mime_MimePart implements Swift_Mime * @param string $address * @param string $name optional * - * @return Swift_Mime_SimpleMessage + * @return $this */ public function setSender($address, $name = null) { @@ -183,7 +187,7 @@ class Swift_Mime_SimpleMessage extends Swift_Mime_MimePart implements Swift_Mime * @param string $address * @param string $name optional * - * @return Swift_Mime_SimpleMessage + * @return $this */ public function addFrom($address, $name = null) { @@ -201,10 +205,10 @@ class Swift_Mime_SimpleMessage extends Swift_Mime_MimePart implements Swift_Mime * If $name is passed and the first parameter is a string, this name will be * associated with the address. * - * @param string $addresses - * @param string $name optional + * @param string|array $addresses + * @param string $name optional * - * @return Swift_Mime_SimpleMessage + * @return $this */ public function setFrom($addresses, $name = null) { @@ -222,7 +226,7 @@ class Swift_Mime_SimpleMessage extends Swift_Mime_MimePart implements Swift_Mime /** * Get the from address of this message. * - * @return string + * @return mixed */ public function getFrom() { @@ -237,7 +241,7 @@ class Swift_Mime_SimpleMessage extends Swift_Mime_MimePart implements Swift_Mime * @param string $address * @param string $name optional * - * @return Swift_Mime_SimpleMessage + * @return $this */ public function addReplyTo($address, $name = null) { @@ -255,10 +259,10 @@ class Swift_Mime_SimpleMessage extends Swift_Mime_MimePart implements Swift_Mime * If $name is passed and the first parameter is a string, this name will be * associated with the address. * - * @param string $addresses + * @param mixed $addresses * @param string $name optional * - * @return Swift_Mime_SimpleMessage + * @return $this */ public function setReplyTo($addresses, $name = null) { @@ -291,7 +295,7 @@ class Swift_Mime_SimpleMessage extends Swift_Mime_MimePart implements Swift_Mime * @param string $address * @param string $name optional * - * @return Swift_Mime_SimpleMessage + * @return $this */ public function addTo($address, $name = null) { @@ -313,7 +317,7 @@ class Swift_Mime_SimpleMessage extends Swift_Mime_MimePart implements Swift_Mime * @param mixed $addresses * @param string $name optional * - * @return Swift_Mime_SimpleMessage + * @return $this */ public function setTo($addresses, $name = null) { @@ -346,7 +350,7 @@ class Swift_Mime_SimpleMessage extends Swift_Mime_MimePart implements Swift_Mime * @param string $address * @param string $name optional * - * @return Swift_Mime_SimpleMessage + * @return $this */ public function addCc($address, $name = null) { @@ -365,7 +369,7 @@ class Swift_Mime_SimpleMessage extends Swift_Mime_MimePart implements Swift_Mime * @param mixed $addresses * @param string $name optional * - * @return Swift_Mime_SimpleMessage + * @return $this */ public function setCc($addresses, $name = null) { @@ -398,7 +402,7 @@ class Swift_Mime_SimpleMessage extends Swift_Mime_MimePart implements Swift_Mime * @param string $address * @param string $name optional * - * @return Swift_Mime_SimpleMessage + * @return $this */ public function addBcc($address, $name = null) { @@ -417,7 +421,7 @@ class Swift_Mime_SimpleMessage extends Swift_Mime_MimePart implements Swift_Mime * @param mixed $addresses * @param string $name optional * - * @return Swift_Mime_SimpleMessage + * @return $this */ public function setBcc($addresses, $name = null) { @@ -447,18 +451,18 @@ class Swift_Mime_SimpleMessage extends Swift_Mime_MimePart implements Swift_Mime * * 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)) { @@ -467,8 +471,7 @@ class Swift_Mime_SimpleMessage extends Swift_Mime_MimePart implements Swift_Mime $priority = min($pMapKeys); } if (!$this->_setHeaderFieldModel('X-Priority', - sprintf('%d (%s)', $priority, $priorityMap[$priority]))) - { + sprintf('%d (%s)', $priority, $priorityMap[$priority]))) { $this->getHeaders()->addTextHeader('X-Priority', sprintf('%d (%s)', $priority, $priorityMap[$priority])); } @@ -494,11 +497,11 @@ class Swift_Mime_SimpleMessage extends Swift_Mime_MimePart implements Swift_Mime } /** - * Ask for a delivery receipt from the recipient to be sent to $addresses + * Ask for a delivery receipt from the recipient to be sent to $addresses. * * @param array $addresses * - * @return Swift_Mime_SimpleMessage + * @return $this */ public function setReadReceiptTo($addresses) { @@ -525,7 +528,7 @@ class Swift_Mime_SimpleMessage extends Swift_Mime_MimePart implements Swift_Mime * * @param Swift_Mime_MimeEntity $entity * - * @return Swift_Mime_SimpleMessage + * @return $this */ public function attach(Swift_Mime_MimeEntity $entity) { @@ -539,7 +542,7 @@ class Swift_Mime_SimpleMessage extends Swift_Mime_MimePart implements Swift_Mime * * @param Swift_Mime_MimeEntity $entity * - * @return Swift_Mime_SimpleMessage + * @return $this */ public function detach(Swift_Mime_MimeEntity $entity) { @@ -566,7 +569,7 @@ class Swift_Mime_SimpleMessage extends Swift_Mime_MimePart implements Swift_Mime { $this->attach($entity); - return 'cid:' . $entity->getId(); + return 'cid:'.$entity->getId(); } /** @@ -615,8 +618,6 @@ class Swift_Mime_SimpleMessage extends Swift_Mime_MimePart implements Swift_Mime } } - // -- Protected methods - /** @see Swift_Mime_SimpleMimeEntity::_getIdField() */ protected function _getIdField() { @@ -638,8 +639,6 @@ class Swift_Mime_SimpleMessage extends Swift_Mime_MimePart implements Swift_Mime return $part; } - // -- Private methods - /** Get the highest nesting level nested inside this message */ private function _getTopNestingLevel() { diff --git a/lib/swiftmailer/lib/classes/Swift/Mime/SimpleMimeEntity.php b/lib/swiftmailer/lib/classes/Swift/Mime/SimpleMimeEntity.php index dbbb8c177..a13f1b23d 100644 --- a/lib/swiftmailer/lib/classes/Swift/Mime/SimpleMimeEntity.php +++ b/lib/swiftmailer/lib/classes/Swift/Mime/SimpleMimeEntity.php @@ -11,9 +11,7 @@ /** * A MIME entity, in a multipart message. * - * @package Swift - * @subpackage Mime - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_Mime_SimpleMimeEntity implements Swift_Mime_MimeEntity { @@ -36,7 +34,7 @@ class Swift_Mime_SimpleMimeEntity implements Swift_Mime_MimeEntity private $_compositeRanges = array( 'multipart/mixed' => array(self::LEVEL_TOP, self::LEVEL_MIXED), 'multipart/alternative' => array(self::LEVEL_MIXED, self::LEVEL_ALTERNATIVE), - 'multipart/related' => array(self::LEVEL_ALTERNATIVE, self::LEVEL_RELATED) + 'multipart/related' => array(self::LEVEL_ALTERNATIVE, self::LEVEL_RELATED), ); /** A set of filter rules to define what level an entity should be nested at */ @@ -61,7 +59,7 @@ class Swift_Mime_SimpleMimeEntity implements Swift_Mime_MimeEntity private $_alternativePartOrder = array( 'text/plain' => 1, 'text/html' => 2, - 'multipart/related' => 3 + 'multipart/related' => 3, ); /** The CID of this entity */ @@ -106,9 +104,9 @@ class Swift_Mime_SimpleMimeEntity implements Swift_Mime_MimeEntity (self::LEVEL_ALTERNATIVE + self::LEVEL_RELATED) => array( self::LEVEL_ALTERNATIVE => array( 'text/plain' => self::LEVEL_ALTERNATIVE, - 'text/html' => self::LEVEL_RELATED - ) - ) + 'text/html' => self::LEVEL_RELATED, + ), + ), ); $this->_id = $this->getRandomId(); @@ -163,7 +161,7 @@ class Swift_Mime_SimpleMimeEntity implements Swift_Mime_MimeEntity * * @param string $type * - * @return Swift_Mime_SimpleMimeEntity + * @return $this */ public function setContentType($type) { @@ -194,7 +192,7 @@ class Swift_Mime_SimpleMimeEntity implements Swift_Mime_MimeEntity * * @param string $id * - * @return Swift_Mime_SimpleMimeEntity + * @return $this */ public function setId($id) { @@ -225,7 +223,7 @@ class Swift_Mime_SimpleMimeEntity implements Swift_Mime_MimeEntity * * @param string $description * - * @return Swift_Mime_SimpleMimeEntity + * @return $this */ public function setDescription($description) { @@ -251,9 +249,9 @@ class Swift_Mime_SimpleMimeEntity implements Swift_Mime_MimeEntity * * 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) { @@ -265,7 +263,7 @@ class Swift_Mime_SimpleMimeEntity implements Swift_Mime_MimeEntity /** * Get all children added to this entity. * - * @return array of Swift_Mime_Entity + * @return Swift_Mime_MimeEntity[] */ public function getChildren() { @@ -275,27 +273,24 @@ class Swift_Mime_SimpleMimeEntity implements Swift_Mime_MimeEntity /** * Set all children of this entity. * - * @param array $children Swift_Mime_Entity instances - * @param int $compoundLevel For internal use only + * @param Swift_Mime_MimeEntity[] $children + * @param int $compoundLevel For internal use only * - * @return Swift_Mime_SimpleMimeEntity + * @return $this */ public function setChildren(array $children, $compoundLevel = null) { // TODO: Try to refactor this logic - $compoundLevel = isset($compoundLevel) - ? $compoundLevel - : $this->_getCompoundLevel($children) - ; - + $compoundLevel = isset($compoundLevel) ? $compoundLevel : $this->_getCompoundLevel($children); $immediateChildren = array(); $grandchildren = array(); $newContentType = $this->_userContentType; foreach ($children as $child) { $level = $this->_getNeededChildLevel($child, $compoundLevel); - if (empty($immediateChildren)) { //first iteration + if (empty($immediateChildren)) { + //first iteration $immediateChildren = array($child); } else { $nextLevel = $this->_getNeededChildLevel($immediateChildren[0], $compoundLevel); @@ -312,16 +307,15 @@ class Swift_Mime_SimpleMimeEntity implements Swift_Mime_MimeEntity } } - if (!empty($immediateChildren)) { + if ($immediateChildren) { $lowestLevel = $this->_getNeededChildLevel($immediateChildren[0], $compoundLevel); // Determine which composite media type is needed to accommodate the // immediate children foreach ($this->_compositeRanges as $mediaType => $range) { - if ($lowestLevel > $range[0] - && $lowestLevel <= $range[1]) - { + if ($lowestLevel > $range[0] && $lowestLevel <= $range[1]) { $newContentType = $mediaType; + break; } } @@ -351,9 +345,7 @@ class Swift_Mime_SimpleMimeEntity implements Swift_Mime_MimeEntity */ public function getBody() { - return ($this->_body instanceof Swift_OutputByteStream) - ? $this->_readStream($this->_body) - : $this->_body; + return $this->_body instanceof Swift_OutputByteStream ? $this->_readStream($this->_body) : $this->_body; } /** @@ -363,7 +355,7 @@ class Swift_Mime_SimpleMimeEntity implements Swift_Mime_MimeEntity * @param mixed $body * @param string $contentType optional * - * @return Swift_Mime_SimpleMimeEntity + * @return $this */ public function setBody($body, $contentType = null) { @@ -394,7 +386,7 @@ class Swift_Mime_SimpleMimeEntity implements Swift_Mime_MimeEntity * * @param Swift_Mime_ContentEncoder $encoder * - * @return Swift_Mime_SimpleMimeEntity + * @return $this */ public function setEncoder(Swift_Mime_ContentEncoder $encoder) { @@ -417,7 +409,7 @@ class Swift_Mime_SimpleMimeEntity implements Swift_Mime_MimeEntity public function getBoundary() { if (!isset($this->_boundary)) { - $this->_boundary = '_=_swift_v4_' . time() . '_' . md5(getmypid().mt_rand().uniqid('', true)) . '_=_'; + $this->_boundary = '_=_swift_v4_'.time().'_'.md5(getmypid().mt_rand().uniqid('', true)).'_=_'; } return $this->_boundary; @@ -428,9 +420,9 @@ class Swift_Mime_SimpleMimeEntity implements Swift_Mime_MimeEntity * * @param string $boundary * - * @return Swift_Mime_SimpleMimeEntity - * * @throws Swift_RfcComplianceException + * + * @return $this */ public function setBoundary($boundary) { @@ -488,22 +480,18 @@ class Swift_Mime_SimpleMimeEntity implements Swift_Mime_MimeEntity if ($this->_cache->hasKey($this->_cacheKey, 'body')) { $body = $this->_cache->getString($this->_cacheKey, 'body'); } else { - $body = "\r\n" . $this->_encoder->encodeString($this->getBody(), 0, - $this->getMaxLineLength() - ); - $this->_cache->setString($this->_cacheKey, 'body', $body, - Swift_KeyCache::MODE_WRITE - ); + $body = "\r\n".$this->_encoder->encodeString($this->getBody(), 0, $this->getMaxLineLength()); + $this->_cache->setString($this->_cacheKey, 'body', $body, Swift_KeyCache::MODE_WRITE); } $string .= $body; } if (!empty($this->_immediateChildren)) { foreach ($this->_immediateChildren as $child) { - $string .= "\r\n\r\n--" . $this->getBoundary() . "\r\n"; + $string .= "\r\n\r\n--".$this->getBoundary()."\r\n"; $string .= $child->toString(); } - $string .= "\r\n\r\n--" . $this->getBoundary() . "--\r\n"; + $string .= "\r\n\r\n--".$this->getBoundary()."--\r\n"; } return $string; @@ -570,17 +558,15 @@ class Swift_Mime_SimpleMimeEntity implements Swift_Mime_MimeEntity if (!empty($this->_immediateChildren)) { foreach ($this->_immediateChildren as $child) { - $is->write("\r\n\r\n--" . $this->getBoundary() . "\r\n"); + $is->write("\r\n\r\n--".$this->getBoundary()."\r\n"); $child->toByteStream($is); } - $is->write("\r\n\r\n--" . $this->getBoundary() . "--\r\n"); + $is->write("\r\n\r\n--".$this->getBoundary()."--\r\n"); } } - // -- Protected methods - /** - * Get the name of the header that provides the ID of this entity + * Get the name of the header that provides the ID of this entity. */ protected function _getIdField() { @@ -595,7 +581,6 @@ class Swift_Mime_SimpleMimeEntity implements Swift_Mime_MimeEntity if ($this->_headers->has($field)) { return $this->_headers->get($field)->getFieldBodyModel(); } - return null; // Returning null is equivalent to no return, but is easier to read!! } /** @@ -607,9 +592,9 @@ class Swift_Mime_SimpleMimeEntity implements Swift_Mime_MimeEntity $this->_headers->get($field)->setFieldBodyModel($model); return true; - } else { - return false; } + + return false; } /** @@ -631,9 +616,9 @@ class Swift_Mime_SimpleMimeEntity implements Swift_Mime_MimeEntity $this->_headers->get($field)->setParameter($parameter, $value); return true; - } else { - return false; } + + return false; } /** @@ -687,21 +672,19 @@ class Swift_Mime_SimpleMimeEntity implements Swift_Mime_MimeEntity */ protected function getRandomId() { - $idLeft = md5(getmypid() . '.' . time() . '.' . uniqid(mt_rand(), true)); + $idLeft = md5(getmypid().'.'.time().'.'.uniqid(mt_rand(), true)); $idRight = !empty($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : 'swift.generated'; - $id = $idLeft . '@' . $idRight; + $id = $idLeft.'@'.$idRight; try { $this->_assertValidId($id); } catch (Swift_RfcComplianceException $e) { - $id = $idLeft . '@swift.generated'; + $id = $idLeft.'@swift.generated'; } return $id; } - // -- Private methods - private function _readStream(Swift_OutputByteStream $os) { $string = ''; @@ -709,6 +692,8 @@ class Swift_Mime_SimpleMimeEntity implements Swift_Mime_MimeEntity $string .= $bytes; } + $os->setReadPointer(0); + return $string; } @@ -721,10 +706,7 @@ class Swift_Mime_SimpleMimeEntity implements Swift_Mime_MimeEntity private function _assertValidBoundary($boundary) { - if (!preg_match( - '/^[a-z0-9\'\(\)\+_\-,\.\/:=\?\ ]{0,69}[a-z0-9\'\(\)\+_\-,\.\/:=\?]$/Di', - $boundary)) - { + if (!preg_match('/^[a-z0-9\'\(\)\+_\-,\.\/:=\?\ ]{0,69}[a-z0-9\'\(\)\+_\-,\.\/:=\?]$/Di', $boundary)) { throw new Swift_RfcComplianceException('Mime boundary set is not RFC 2046 compliant.'); } } @@ -763,19 +745,16 @@ class Swift_Mime_SimpleMimeEntity implements Swift_Mime_MimeEntity $realLevel = $child->getNestingLevel(); $lowercaseType = strtolower($child->getContentType()); - if (isset($filter[$realLevel]) - && isset($filter[$realLevel][$lowercaseType])) - { + if (isset($filter[$realLevel]) && isset($filter[$realLevel][$lowercaseType])) { return $filter[$realLevel][$lowercaseType]; - } else { - return $realLevel; } + + return $realLevel; } private function _createChild() { - return new self($this->_headers->newInstance(), - $this->_encoder, $this->_cache, $this->_grammar); + return new self($this->_headers->newInstance(), $this->_encoder, $this->_cache, $this->_grammar); } private function _notifyEncoderChanged(Swift_Mime_ContentEncoder $encoder) @@ -807,34 +786,33 @@ class Swift_Mime_SimpleMimeEntity implements Swift_Mime_MimeEntity // Sort in order of preference, if there is one if ($shouldSort) { - usort($this->_immediateChildren, array($this, '_childSortAlgorithm')); + // Group the messages by order of preference + $sorted = array(); + foreach ($this->_immediateChildren as $child) { + $type = $child->getContentType(); + $level = array_key_exists($type, $this->_alternativePartOrder) ? $this->_alternativePartOrder[$type] : max($this->_alternativePartOrder) + 1; + + if (empty($sorted[$level])) { + $sorted[$level] = array(); + } + + $sorted[$level][] = $child; + } + + ksort($sorted); + + $this->_immediateChildren = array_reduce($sorted, 'array_merge', array()); } } - private function _childSortAlgorithm($a, $b) - { - $typePrefs = array(); - $types = array( - strtolower($a->getContentType()), - strtolower($b->getContentType()) - ); - foreach ($types as $type) { - $typePrefs[] = (array_key_exists($type, $this->_alternativePartOrder)) - ? $this->_alternativePartOrder[$type] - : (max($this->_alternativePartOrder) + 1); - } - - return ($typePrefs[0] >= $typePrefs[1]) ? 1 : -1; - } - - // -- Destructor - /** * Empties it's own contents from the cache. */ public function __destruct() { - $this->_cache->clearAll($this->_cacheKey); + if ($this->_cache instanceof Swift_KeyCache) { + $this->_cache->clearAll($this->_cacheKey); + } } /** @@ -846,15 +824,23 @@ class Swift_Mime_SimpleMimeEntity implements Swift_Mime_MimeEntity */ private function _assertValidId($id) { - if (!preg_match( - '/^' . $this->_grammar->getDefinition('id-left') . '@' . - $this->_grammar->getDefinition('id-right') . '$/D', - $id - )) - { - 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. + */ + public function __clone() + { + $this->_headers = clone $this->_headers; + $this->_encoder = clone $this->_encoder; + $this->_cacheKey = md5(uniqid(getmypid().mt_rand(), true)); + $children = array(); + foreach ($this->_children as $pos => $child) { + $children[$pos] = clone $child; + } + $this->setChildren($children); + } } diff --git a/lib/swiftmailer/lib/classes/Swift/MimePart.php b/lib/swiftmailer/lib/classes/Swift/MimePart.php index 10a4f3c86..525b7ec8e 100644 --- a/lib/swiftmailer/lib/classes/Swift/MimePart.php +++ b/lib/swiftmailer/lib/classes/Swift/MimePart.php @@ -11,9 +11,7 @@ /** * A MIME part, in a multipart message. * - * @package Swift - * @subpackage Mime - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_MimePart extends Swift_Mime_MimePart { @@ -52,7 +50,7 @@ class Swift_MimePart extends Swift_Mime_MimePart * @param string $contentType * @param string $charset * - * @return Swift_Mime_MimePart + * @return self */ public static function newInstance($body = null, $contentType = null, $charset = null) { diff --git a/lib/swiftmailer/lib/classes/Swift/NullTransport.php b/lib/swiftmailer/lib/classes/Swift/NullTransport.php index 335c47934..ddde335c5 100644 --- a/lib/swiftmailer/lib/classes/Swift/NullTransport.php +++ b/lib/swiftmailer/lib/classes/Swift/NullTransport.php @@ -11,14 +11,10 @@ /** * Pretends messages have been sent, but just ignores them. * - * @package Swift - * @author Fabien Potencier + * @author Fabien Potencier */ class Swift_NullTransport extends Swift_Transport_NullTransport { - /** - * Create a new NullTransport. - */ public function __construct() { call_user_func_array( @@ -31,7 +27,7 @@ class Swift_NullTransport extends Swift_Transport_NullTransport /** * Create a new NullTransport instance. * - * @return Swift_NullTransport + * @return self */ public static function newInstance() { diff --git a/lib/swiftmailer/lib/classes/Swift/OutputByteStream.php b/lib/swiftmailer/lib/classes/Swift/OutputByteStream.php index 47faa73af..1f26f9be5 100644 --- a/lib/swiftmailer/lib/classes/Swift/OutputByteStream.php +++ b/lib/swiftmailer/lib/classes/Swift/OutputByteStream.php @@ -14,9 +14,7 @@ * Classes implementing this interface may use a subsystem which requires less * memory than working with large strings of data. * - * @package Swift - * @subpackage ByteStream - * @author Chris Corbyn + * @author Chris Corbyn */ interface Swift_OutputByteStream { @@ -27,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/lib/swiftmailer/lib/classes/Swift/Plugins/AntiFloodPlugin.php b/lib/swiftmailer/lib/classes/Swift/Plugins/AntiFloodPlugin.php index 307da9d77..a2ec2abcd 100644 --- a/lib/swiftmailer/lib/classes/Swift/Plugins/AntiFloodPlugin.php +++ b/lib/swiftmailer/lib/classes/Swift/Plugins/AntiFloodPlugin.php @@ -11,9 +11,7 @@ /** * Reduces network flooding when sending large amounts of mail. * - * @package Swift - * @subpackage Plugins - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_Plugins_AntiFloodPlugin implements Swift_Events_SendListener, Swift_Plugins_Sleeper { @@ -62,7 +60,7 @@ class Swift_Plugins_AntiFloodPlugin implements Swift_Events_SendListener, Swift_ /** * Set the number of emails to send before restarting. * - * @param int $threshold + * @param int $threshold */ public function setThreshold($threshold) { @@ -82,7 +80,7 @@ class Swift_Plugins_AntiFloodPlugin implements Swift_Events_SendListener, Swift_ /** * Set the number of seconds to sleep for during a restart. * - * @param int $sleep time + * @param int $sleep time */ public function setSleepTime($sleep) { @@ -130,7 +128,7 @@ class Swift_Plugins_AntiFloodPlugin implements Swift_Events_SendListener, Swift_ /** * Sleep for $seconds. * - * @param int $seconds + * @param int $seconds */ public function sleep($seconds) { diff --git a/lib/swiftmailer/lib/classes/Swift/Plugins/BandwidthMonitorPlugin.php b/lib/swiftmailer/lib/classes/Swift/Plugins/BandwidthMonitorPlugin.php index 8794aacf0..f7e18d0eb 100644 --- a/lib/swiftmailer/lib/classes/Swift/Plugins/BandwidthMonitorPlugin.php +++ b/lib/swiftmailer/lib/classes/Swift/Plugins/BandwidthMonitorPlugin.php @@ -11,9 +11,7 @@ /** * Reduces network flooding when sending large amounts of mail. * - * @package Swift - * @subpackage Plugins - * @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/lib/swiftmailer/lib/classes/Swift/Plugins/Decorator/Replacements.php b/lib/swiftmailer/lib/classes/Swift/Plugins/Decorator/Replacements.php index 3269c6982..9f9f08b56 100644 --- a/lib/swiftmailer/lib/classes/Swift/Plugins/Decorator/Replacements.php +++ b/lib/swiftmailer/lib/classes/Swift/Plugins/Decorator/Replacements.php @@ -11,9 +11,7 @@ /** * Allows customization of Messages on-the-fly. * - * @package Swift - * @subpackage Plugins - * @author Chris Corbyn + * @author Chris Corbyn */ interface Swift_Plugins_Decorator_Replacements { diff --git a/lib/swiftmailer/lib/classes/Swift/Plugins/DecoratorPlugin.php b/lib/swiftmailer/lib/classes/Swift/Plugins/DecoratorPlugin.php index 84f70709e..0762b36d2 100644 --- a/lib/swiftmailer/lib/classes/Swift/Plugins/DecoratorPlugin.php +++ b/lib/swiftmailer/lib/classes/Swift/Plugins/DecoratorPlugin.php @@ -11,10 +11,8 @@ /** * Allows customization of Messages on-the-fly. * - * @package Swift - * @subpackage Plugins - * @author Chris Corbyn - * @author Fabien Potencier + * @author Chris Corbyn + * @author Fabien Potencier */ class Swift_Plugins_DecoratorPlugin implements Swift_Events_SendListener, Swift_Plugins_Decorator_Replacements { @@ -125,7 +123,7 @@ class Swift_Plugins_DecoratorPlugin implements Swift_Events_SendListener, Swift_ $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( @@ -159,12 +157,9 @@ class Swift_Plugins_DecoratorPlugin implements Swift_Events_SendListener, Swift_ { 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; } /** @@ -177,8 +172,6 @@ class Swift_Plugins_DecoratorPlugin implements Swift_Events_SendListener, Swift_ $this->_restoreMessage($evt->getMessage()); } - // -- Private methods - /** Restore a changed message back to its original state */ private function _restoreMessage(Swift_Mime_Message $message) { diff --git a/lib/swiftmailer/lib/classes/Swift/Plugins/ImpersonatePlugin.php b/lib/swiftmailer/lib/classes/Swift/Plugins/ImpersonatePlugin.php index 1f1e4430c..583444053 100644 --- a/lib/swiftmailer/lib/classes/Swift/Plugins/ImpersonatePlugin.php +++ b/lib/swiftmailer/lib/classes/Swift/Plugins/ImpersonatePlugin.php @@ -1,4 +1,5 @@ getHeaders(); if ($headers->has('X-Swift-Return-Path')) { - $message->setReturnPath($headers->get('X-Swift-Return-Path')->getAddress()); - $headers->removeAll('X-Swift-Return-Path'); + $message->setReturnPath($headers->get('X-Swift-Return-Path')->getAddress()); + $headers->removeAll('X-Swift-Return-Path'); } } } diff --git a/lib/swiftmailer/lib/classes/Swift/Plugins/Logger.php b/lib/swiftmailer/lib/classes/Swift/Plugins/Logger.php index 81c1d9bb8..d9bce8935 100644 --- a/lib/swiftmailer/lib/classes/Swift/Plugins/Logger.php +++ b/lib/swiftmailer/lib/classes/Swift/Plugins/Logger.php @@ -11,9 +11,7 @@ /** * Logs events in the Transport system. * - * @package Swift - * @subpackage Transport - * @author Chris Corbyn + * @author Chris Corbyn */ interface Swift_Plugins_Logger { diff --git a/lib/swiftmailer/lib/classes/Swift/Plugins/LoggerPlugin.php b/lib/swiftmailer/lib/classes/Swift/Plugins/LoggerPlugin.php index cfe9ca134..64db43846 100644 --- a/lib/swiftmailer/lib/classes/Swift/Plugins/LoggerPlugin.php +++ b/lib/swiftmailer/lib/classes/Swift/Plugins/LoggerPlugin.php @@ -11,9 +11,7 @@ /** * Does real time logging of Transport level information. * - * @package Swift - * @subpackage Plugins - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_Plugins_LoggerPlugin implements Swift_Events_CommandListener, Swift_Events_ResponseListener, Swift_Events_TransportChangeListener, Swift_Events_TransportExceptionListener, Swift_Plugins_Logger { @@ -66,7 +64,7 @@ class Swift_Plugins_LoggerPlugin implements Swift_Events_CommandListener, Swift_ public function commandSent(Swift_Events_CommandEvent $evt) { $command = $evt->getCommand(); - $this->_logger->add(sprintf(">> %s", $command)); + $this->_logger->add(sprintf('>> %s', $command)); } /** @@ -77,7 +75,7 @@ class Swift_Plugins_LoggerPlugin implements Swift_Events_CommandListener, Swift_ public function responseReceived(Swift_Events_ResponseEvent $evt) { $response = $evt->getResponse(); - $this->_logger->add(sprintf("<< %s", $response)); + $this->_logger->add(sprintf('<< %s', $response)); } /** @@ -88,7 +86,7 @@ class Swift_Plugins_LoggerPlugin implements Swift_Events_CommandListener, Swift_ 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)); } /** @@ -99,7 +97,7 @@ class Swift_Plugins_LoggerPlugin implements Swift_Events_CommandListener, Swift_ 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)); } /** @@ -110,7 +108,7 @@ class Swift_Plugins_LoggerPlugin implements Swift_Events_CommandListener, Swift_ 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)); } /** @@ -121,7 +119,7 @@ class Swift_Plugins_LoggerPlugin implements Swift_Events_CommandListener, Swift_ 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)); } /** @@ -133,11 +131,12 @@ class Swift_Plugins_LoggerPlugin implements Swift_Events_CommandListener, Swift_ { $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 .= '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/lib/swiftmailer/lib/classes/Swift/Plugins/Loggers/ArrayLogger.php b/lib/swiftmailer/lib/classes/Swift/Plugins/Loggers/ArrayLogger.php index eb362ef83..865bb0aa3 100644 --- a/lib/swiftmailer/lib/classes/Swift/Plugins/Loggers/ArrayLogger.php +++ b/lib/swiftmailer/lib/classes/Swift/Plugins/Loggers/ArrayLogger.php @@ -11,9 +11,7 @@ /** * Logs to an Array backend. * - * @package Swift - * @subpackage Transport - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_Plugins_Loggers_ArrayLogger implements Swift_Plugins_Logger { @@ -34,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/lib/swiftmailer/lib/classes/Swift/Plugins/Loggers/EchoLogger.php b/lib/swiftmailer/lib/classes/Swift/Plugins/Loggers/EchoLogger.php index 73b95545b..3583297ab 100644 --- a/lib/swiftmailer/lib/classes/Swift/Plugins/Loggers/EchoLogger.php +++ b/lib/swiftmailer/lib/classes/Swift/Plugins/Loggers/EchoLogger.php @@ -11,9 +11,7 @@ /** * Prints all log messages in real time. * - * @package Swift - * @subpackage Transport - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_Plugins_Loggers_EchoLogger implements Swift_Plugins_Logger { @@ -23,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/lib/swiftmailer/lib/classes/Swift/Plugins/MessageLogger.php b/lib/swiftmailer/lib/classes/Swift/Plugins/MessageLogger.php index b5dfa8b13..5ff1d9321 100644 --- a/lib/swiftmailer/lib/classes/Swift/Plugins/MessageLogger.php +++ b/lib/swiftmailer/lib/classes/Swift/Plugins/MessageLogger.php @@ -11,14 +11,12 @@ /** * Stores all sent emails for further usage. * - * @package Swift - * @subpackage Plugins - * @author Fabien Potencier + * @author Fabien Potencier */ class Swift_Plugins_MessageLogger implements Swift_Events_SendListener { /** - * @var array + * @var Swift_Mime_Message[] */ private $messages; @@ -28,9 +26,9 @@ class Swift_Plugins_MessageLogger implements Swift_Events_SendListener } /** - * Get the message list + * Get the message list. * - * @return array + * @return Swift_Mime_Message[] */ public function getMessages() { @@ -38,9 +36,9 @@ class Swift_Plugins_MessageLogger implements Swift_Events_SendListener } /** - * Get the message count + * Get the message count. * - * @return int count + * @return int count */ public function countMessages() { @@ -48,8 +46,7 @@ class Swift_Plugins_MessageLogger implements Swift_Events_SendListener } /** - * Empty the message list - * + * Empty the message list. */ public function clear() { diff --git a/lib/swiftmailer/lib/classes/Swift/Plugins/Pop/Pop3Connection.php b/lib/swiftmailer/lib/classes/Swift/Plugins/Pop/Pop3Connection.php index d24172152..fb99e4c94 100644 --- a/lib/swiftmailer/lib/classes/Swift/Plugins/Pop/Pop3Connection.php +++ b/lib/swiftmailer/lib/classes/Swift/Plugins/Pop/Pop3Connection.php @@ -11,9 +11,7 @@ /** * Pop3Connection interface for connecting and disconnecting to a POP3 host. * - * @package Swift - * @subpackage Plugins - * @author Chris Corbyn + * @author Chris Corbyn */ interface Swift_Plugins_Pop_Pop3Connection { diff --git a/lib/swiftmailer/lib/classes/Swift/Plugins/Pop/Pop3Exception.php b/lib/swiftmailer/lib/classes/Swift/Plugins/Pop/Pop3Exception.php index 02d421e70..dc7be0c4e 100644 --- a/lib/swiftmailer/lib/classes/Swift/Plugins/Pop/Pop3Exception.php +++ b/lib/swiftmailer/lib/classes/Swift/Plugins/Pop/Pop3Exception.php @@ -11,9 +11,7 @@ /** * Pop3Exception thrown when an error occurs connecting to a POP3 host. * - * @package Swift - * @subpackage Transport - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_Plugins_Pop_Pop3Exception extends Swift_IoException { diff --git a/lib/swiftmailer/lib/classes/Swift/Plugins/PopBeforeSmtpPlugin.php b/lib/swiftmailer/lib/classes/Swift/Plugins/PopBeforeSmtpPlugin.php index 379c45141..31461526c 100644 --- a/lib/swiftmailer/lib/classes/Swift/Plugins/PopBeforeSmtpPlugin.php +++ b/lib/swiftmailer/lib/classes/Swift/Plugins/PopBeforeSmtpPlugin.php @@ -11,9 +11,7 @@ /** * Makes sure a connection to a POP3 host has been established prior to connecting to SMTP. * - * @package Swift - * @subpackage Plugins - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_Plugins_PopBeforeSmtpPlugin implements Swift_Events_TransportChangeListener, Swift_Plugins_Pop_Pop3Connection { @@ -47,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) { @@ -61,11 +59,11 @@ 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" * - * @return Swift_Plugins_PopBeforeSmtpPlugin + * @return self */ public static function newInstance($host, $port = 110, $crypto = null) { @@ -77,7 +75,7 @@ class Swift_Plugins_PopBeforeSmtpPlugin implements Swift_Events_TransportChangeL * * @param Swift_Plugins_Pop_Pop3Connection $connection * - * @return Swift_Plugins_PopBeforeSmtpPlugin + * @return $this */ public function setConnection(Swift_Plugins_Pop_Pop3Connection $connection) { @@ -99,9 +97,9 @@ class Swift_Plugins_PopBeforeSmtpPlugin implements Swift_Events_TransportChangeL /** * Set the connection timeout in seconds (default 10). * - * @param int $timeout + * @param int $timeout * - * @return Swift_Plugins_PopBeforeSmtpPlugin + * @return $this */ public function setTimeout($timeout) { @@ -115,7 +113,7 @@ class Swift_Plugins_PopBeforeSmtpPlugin implements Swift_Events_TransportChangeL * * @param string $username * - * @return Swift_Plugins_PopBeforeSmtpPlugin + * @return $this */ public function setUsername($username) { @@ -129,7 +127,7 @@ class Swift_Plugins_PopBeforeSmtpPlugin implements Swift_Events_TransportChangeL * * @param string $password * - * @return Swift_Plugins_PopBeforeSmtpPlugin + * @return $this */ public function setPassword($password) { @@ -150,8 +148,7 @@ class Swift_Plugins_PopBeforeSmtpPlugin implements Swift_Events_TransportChangeL } else { if (!isset($this->_socket)) { if (!$socket = fsockopen( - $this->_getHostString(), $this->_port, $errno, $errstr, $this->_timeout)) - { + $this->_getHostString(), $this->_port, $errno, $errstr, $this->_timeout)) { throw new Swift_Plugins_Pop_Pop3Exception( sprintf('Failed to connect to POP3 host [%s]: %s', $this->_host, $errstr) ); @@ -230,8 +227,6 @@ class Swift_Plugins_PopBeforeSmtpPlugin implements Swift_Events_TransportChangeL { } - // -- Private Methods - private function _command($command) { if (!fwrite($this->_socket, $command)) { @@ -265,11 +260,11 @@ class Swift_Plugins_PopBeforeSmtpPlugin implements Swift_Events_TransportChangeL $host = $this->_host; switch (strtolower($this->_crypto)) { case 'ssl': - $host = 'ssl://' . $host; + $host = 'ssl://'.$host; break; case 'tls': - $host = 'tls://' . $host; + $host = 'tls://'.$host; break; } diff --git a/lib/swiftmailer/lib/classes/Swift/Plugins/RedirectingPlugin.php b/lib/swiftmailer/lib/classes/Swift/Plugins/RedirectingPlugin.php index 3b006b67a..c3a1f8685 100644 --- a/lib/swiftmailer/lib/classes/Swift/Plugins/RedirectingPlugin.php +++ b/lib/swiftmailer/lib/classes/Swift/Plugins/RedirectingPlugin.php @@ -11,9 +11,7 @@ /** * Redirects all email to a single recipient. * - * @package Swift - * @subpackage Plugins - * @author Fabien Potencier + * @author Fabien Potencier */ class Swift_Plugins_RedirectingPlugin implements Swift_Events_SendListener { @@ -25,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 */ @@ -35,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()) { @@ -64,7 +62,7 @@ class Swift_Plugins_RedirectingPlugin implements Swift_Events_SendListener } /** - * Set a list of regular expressions to whitelist certain recipients + * Set a list of regular expressions to whitelist certain recipients. * * @param array $whitelist */ @@ -74,7 +72,7 @@ class Swift_Plugins_RedirectingPlugin implements Swift_Events_SendListener } /** - * Get the whitelist + * Get the whitelist. * * @return array */ @@ -113,19 +111,23 @@ class Swift_Plugins_RedirectingPlugin implements Swift_Events_SendListener $this->_filterHeaderSet($headers, 'Bcc'); // Add each hard coded recipient - foreach ( (array) $this->_recipient as $recipient) { - if (!array_key_exists($recipient, $message->getTo())) { + $to = $message->getTo(); + if (null === $to) { + $to = array(); + } + + foreach ((array) $this->_recipient as $recipient) { + if (!array_key_exists($recipient, $to)) { $message->addTo($recipient); } } - } /** - * 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) { @@ -135,9 +137,10 @@ class Swift_Plugins_RedirectingPlugin implements Swift_Events_SendListener } /** - * Filtered list of addresses => name pairs + * Filtered list of addresses => name pairs. * * @param array $recipients + * * @return array */ private function _filterNameAddresses(array $recipients) @@ -154,9 +157,10 @@ class Swift_Plugins_RedirectingPlugin implements Swift_Events_SendListener } /** - * Matches address against whitelist of regular expressions + * Matches address against whitelist of regular expressions. * * @param $recipient + * * @return bool */ protected function _isWhitelisted($recipient) @@ -184,8 +188,6 @@ class Swift_Plugins_RedirectingPlugin implements Swift_Events_SendListener $this->_restoreMessage($evt->getMessage()); } - // -- Private methods - private function _restoreMessage(Swift_Mime_Message $message) { // restore original headers @@ -194,6 +196,8 @@ class Swift_Plugins_RedirectingPlugin implements Swift_Events_SendListener if ($headers->has('X-Swift-To')) { $message->setTo($headers->get('X-Swift-To')->getNameAddresses()); $headers->removeAll('X-Swift-To'); + } else { + $message->setTo(null); } if ($headers->has('X-Swift-Cc')) { diff --git a/lib/swiftmailer/lib/classes/Swift/Plugins/Reporter.php b/lib/swiftmailer/lib/classes/Swift/Plugins/Reporter.php index 504c0c888..0f21b7d60 100644 --- a/lib/swiftmailer/lib/classes/Swift/Plugins/Reporter.php +++ b/lib/swiftmailer/lib/classes/Swift/Plugins/Reporter.php @@ -11,9 +11,7 @@ /** * The Reporter plugin sends pass/fail notification to a Reporter. * - * @package Swift - * @subpackage Plugins - * @author Chris Corbyn + * @author Chris Corbyn */ interface Swift_Plugins_Reporter { diff --git a/lib/swiftmailer/lib/classes/Swift/Plugins/ReporterPlugin.php b/lib/swiftmailer/lib/classes/Swift/Plugins/ReporterPlugin.php index e79c6bbff..a37901ff0 100644 --- a/lib/swiftmailer/lib/classes/Swift/Plugins/ReporterPlugin.php +++ b/lib/swiftmailer/lib/classes/Swift/Plugins/ReporterPlugin.php @@ -11,16 +11,14 @@ /** * Does real time reporting of pass/fail for each recipient. * - * @package Swift - * @subpackage Plugins - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_Plugins_ReporterPlugin implements Swift_Events_SendListener { /** * The reporter backend which takes notifications. * - * @var Swift_Plugin_Reporter + * @var Swift_Plugins_Reporter */ private $_reporter; @@ -51,25 +49,13 @@ class Swift_Plugins_ReporterPlugin implements Swift_Events_SendListener $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/lib/swiftmailer/lib/classes/Swift/Plugins/Reporters/HitReporter.php b/lib/swiftmailer/lib/classes/Swift/Plugins/Reporters/HitReporter.php index 5890eea91..cad9d168e 100644 --- a/lib/swiftmailer/lib/classes/Swift/Plugins/Reporters/HitReporter.php +++ b/lib/swiftmailer/lib/classes/Swift/Plugins/Reporters/HitReporter.php @@ -11,9 +11,7 @@ /** * A reporter which "collects" failures for the Reporter plugin. * - * @package Swift - * @subpackage Plugins - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_Plugins_Reporters_HitReporter implements Swift_Plugins_Reporter { diff --git a/lib/swiftmailer/lib/classes/Swift/Plugins/Reporters/HtmlReporter.php b/lib/swiftmailer/lib/classes/Swift/Plugins/Reporters/HtmlReporter.php index cd3b98425..c62593557 100644 --- a/lib/swiftmailer/lib/classes/Swift/Plugins/Reporters/HtmlReporter.php +++ b/lib/swiftmailer/lib/classes/Swift/Plugins/Reporters/HtmlReporter.php @@ -11,9 +11,7 @@ /** * A HTML output reporter for the Reporter plugin. * - * @package Swift - * @subpackage Plugins - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_Plugins_Reporters_HtmlReporter implements Swift_Plugins_Reporter { @@ -27,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/lib/swiftmailer/lib/classes/Swift/Plugins/Sleeper.php b/lib/swiftmailer/lib/classes/Swift/Plugins/Sleeper.php index 35a63b4fb..595c0f603 100644 --- a/lib/swiftmailer/lib/classes/Swift/Plugins/Sleeper.php +++ b/lib/swiftmailer/lib/classes/Swift/Plugins/Sleeper.php @@ -11,16 +11,14 @@ /** * Sleeps for a duration of time. * - * @package Swift - * @subpackage Plugins - * @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/lib/swiftmailer/lib/classes/Swift/Plugins/ThrottlerPlugin.php b/lib/swiftmailer/lib/classes/Swift/Plugins/ThrottlerPlugin.php index 933104e08..2f4b9a75e 100644 --- a/lib/swiftmailer/lib/classes/Swift/Plugins/ThrottlerPlugin.php +++ b/lib/swiftmailer/lib/classes/Swift/Plugins/ThrottlerPlugin.php @@ -11,9 +11,7 @@ /** * Throttles the rate at which emails are sent. * - * @package Swift - * @subpackage Plugins - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_Plugins_ThrottlerPlugin extends Swift_Plugins_BandwidthMonitorPlugin implements Swift_Plugins_Sleeper, Swift_Plugins_Timer { @@ -99,17 +97,17 @@ class Swift_Plugins_ThrottlerPlugin extends Swift_Plugins_BandwidthMonitorPlugin } $duration = $time - $this->_start; - switch($this->_mode) { - case self::BYTES_PER_MINUTE : + switch ($this->_mode) { + 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; } @@ -133,7 +131,7 @@ class Swift_Plugins_ThrottlerPlugin extends Swift_Plugins_BandwidthMonitorPlugin /** * Sleep for $seconds. * - * @param int $seconds + * @param int $seconds */ public function sleep($seconds) { @@ -153,17 +151,15 @@ class Swift_Plugins_ThrottlerPlugin extends Swift_Plugins_BandwidthMonitorPlugin { if (isset($this->_timer)) { return $this->_timer->getTimestamp(); - } else { - return time(); } - } - // -- Private methods + return time(); + } /** * Get a number of seconds to sleep for. * - * @param int $timePassed + * @param int $timePassed * * @return int */ @@ -191,7 +187,7 @@ class Swift_Plugins_ThrottlerPlugin extends Swift_Plugins_BandwidthMonitorPlugin /** * Get a number of seconds to sleep for. * - * @param int $timePassed + * @param int $timePassed * * @return int */ diff --git a/lib/swiftmailer/lib/classes/Swift/Plugins/Timer.php b/lib/swiftmailer/lib/classes/Swift/Plugins/Timer.php index 12dd09b8b..9c8deb38a 100644 --- a/lib/swiftmailer/lib/classes/Swift/Plugins/Timer.php +++ b/lib/swiftmailer/lib/classes/Swift/Plugins/Timer.php @@ -11,9 +11,7 @@ /** * Provides timestamp data. * - * @package Swift - * @subpackage Plugins - * @author Chris Corbyn + * @author Chris Corbyn */ interface Swift_Plugins_Timer { diff --git a/lib/swiftmailer/lib/classes/Swift/Preferences.php b/lib/swiftmailer/lib/classes/Swift/Preferences.php index 629436f57..83cbddcd2 100644 --- a/lib/swiftmailer/lib/classes/Swift/Preferences.php +++ b/lib/swiftmailer/lib/classes/Swift/Preferences.php @@ -11,8 +11,7 @@ /** * Changes some global preference settings in Swift Mailer. * - * @package Swift - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_Preferences { @@ -27,7 +26,7 @@ class Swift_Preferences /** * Gets the instance of Preferences. * - * @return Swift_Preferences + * @return self */ public static function getInstance() { @@ -43,12 +42,11 @@ class Swift_Preferences * * @param string $charset * - * @return Swift_Preferences + * @return $this */ public function setCharset($charset) { - Swift_DependencyContainer::getInstance() - ->register('properties.charset')->asValue($charset); + Swift_DependencyContainer::getInstance()->register('properties.charset')->asValue($charset); return $this; } @@ -58,12 +56,11 @@ class Swift_Preferences * * @param string $dir * - * @return Swift_Preferences + * @return $this */ public function setTempDir($dir) { - Swift_DependencyContainer::getInstance() - ->register('tempdir')->asValue($dir); + Swift_DependencyContainer::getInstance()->register('tempdir')->asValue($dir); return $this; } @@ -73,12 +70,11 @@ class Swift_Preferences * * @param string $type * - * @return Swift_Preferences + * @return $this */ public function setCacheType($type) { - Swift_DependencyContainer::getInstance() - ->register('cache')->asAliasOf(sprintf('cache.%s', $type)); + Swift_DependencyContainer::getInstance()->register('cache')->asAliasOf(sprintf('cache.%s', $type)); return $this; } @@ -86,9 +82,9 @@ class Swift_Preferences /** * Set the QuotedPrintable dot escaper preference. * - * @param bool $dotEscape + * @param bool $dotEscape * - * @return Swift_Preferences + * @return $this */ public function setQPDotEscape($dotEscape) { diff --git a/lib/swiftmailer/lib/classes/Swift/ReplacementFilterFactory.php b/lib/swiftmailer/lib/classes/Swift/ReplacementFilterFactory.php index 4b6eed584..2897474e7 100644 --- a/lib/swiftmailer/lib/classes/Swift/ReplacementFilterFactory.php +++ b/lib/swiftmailer/lib/classes/Swift/ReplacementFilterFactory.php @@ -11,8 +11,7 @@ /** * Creates StreamFilters. * - * @package Swift - * @author Chris Corbyn + * @author Chris Corbyn */ interface Swift_ReplacementFilterFactory { diff --git a/lib/swiftmailer/lib/classes/Swift/RfcComplianceException.php b/lib/swiftmailer/lib/classes/Swift/RfcComplianceException.php index 6a2a49b87..81bc4031e 100644 --- a/lib/swiftmailer/lib/classes/Swift/RfcComplianceException.php +++ b/lib/swiftmailer/lib/classes/Swift/RfcComplianceException.php @@ -11,8 +11,7 @@ /** * RFC Compliance Exception class. * - * @package Swift - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_RfcComplianceException extends Swift_SwiftException { diff --git a/lib/swiftmailer/lib/classes/Swift/SendmailTransport.php b/lib/swiftmailer/lib/classes/Swift/SendmailTransport.php index d5fc72d7f..47ae7a591 100644 --- a/lib/swiftmailer/lib/classes/Swift/SendmailTransport.php +++ b/lib/swiftmailer/lib/classes/Swift/SendmailTransport.php @@ -11,9 +11,7 @@ /** * SendmailTransport for sending mail through a Sendmail/Postfix (etc..) binary. * - * @package Swift - * @subpackage Transport - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_SendmailTransport extends Swift_Transport_SendmailTransport { @@ -38,7 +36,7 @@ class Swift_SendmailTransport extends Swift_Transport_SendmailTransport * * @param string $command * - * @return Swift_SendmailTransport + * @return self */ public static function newInstance($command = '/usr/sbin/sendmail -bs') { diff --git a/lib/swiftmailer/lib/classes/Swift/SignedMessage.php b/lib/swiftmailer/lib/classes/Swift/SignedMessage.php index c4fb2c73c..2e7a8726d 100644 --- a/lib/swiftmailer/lib/classes/Swift/SignedMessage.php +++ b/lib/swiftmailer/lib/classes/Swift/SignedMessage.php @@ -10,16 +10,14 @@ /** * Signed Message, message that can be signed using a signer. - * + * * This class is only kept for compatibility * - * @package Swift - * @subpackage Signed * * @author Xavier De Cock + * * @deprecated */ class Swift_SignedMessage extends Swift_Message { - } diff --git a/lib/swiftmailer/lib/classes/Swift/Signer.php b/lib/swiftmailer/lib/classes/Swift/Signer.php index 865f557e0..2d8176d90 100644 --- a/lib/swiftmailer/lib/classes/Swift/Signer.php +++ b/lib/swiftmailer/lib/classes/Swift/Signer.php @@ -11,10 +11,8 @@ /** * Base Class of Signer Infrastructure. * - * @package Swift - * @subpackage Signatures * - * @author Xavier De Cock + * @author Xavier De Cock */ interface Swift_Signer { diff --git a/lib/swiftmailer/lib/classes/Swift/Signers/BodySigner.php b/lib/swiftmailer/lib/classes/Swift/Signers/BodySigner.php index 1d700fb17..8e66e18f4 100644 --- a/lib/swiftmailer/lib/classes/Swift/Signers/BodySigner.php +++ b/lib/swiftmailer/lib/classes/Swift/Signers/BodySigner.php @@ -9,11 +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. * - * @package Swift - * @subpackage Signatures - * @author Xavier De Cock + * @author Xavier De Cock */ interface Swift_Signers_BodySigner extends Swift_Signer { @@ -22,12 +20,12 @@ interface Swift_Signers_BodySigner extends Swift_Signer * * @param Swift_Message $message * - * @return Swift_Signers_BodySigner + * @return self */ 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/lib/swiftmailer/lib/classes/Swift/Signers/DKIMSigner.php b/lib/swiftmailer/lib/classes/Swift/Signers/DKIMSigner.php index f2a25149f..454e84b47 100644 --- a/lib/swiftmailer/lib/classes/Swift/Signers/DKIMSigner.php +++ b/lib/swiftmailer/lib/classes/Swift/Signers/DKIMSigner.php @@ -9,93 +9,93 @@ */ /** - * DKIM Signer used to apply DKIM Signature to a message + * DKIM Signer used to apply DKIM Signature to a message. * - * @package Swift - * @subpackage Signatures - * @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. + * + * @see RFC6376 3.3: Signers MUST implement and SHOULD sign using rsa-sha256. * * @var string */ - protected $_hashAlgorithm = 'rsa-sha1'; + protected $_hashAlgorithm = 'rsa-sha256'; /** - * 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 */ @@ -103,7 +103,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, otherwise it's absolute. * * @var int */ @@ -118,40 +118,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 debugData 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; @@ -171,7 +164,7 @@ class Swift_Signers_DKIMSigner implements Swift_Signers_HeaderSigner private $_bound = array(); /** - * Constructor + * Constructor. * * @param string $privateKey * @param string $domainName @@ -181,38 +174,43 @@ class Swift_Signers_DKIMSigner implements Swift_Signers_HeaderSigner { $this->_privateKey = $privateKey; $this->_domainName = $domainName; - $this->_signerIdentity = '@' . $domainName; + $this->_signerIdentity = '@'.$domainName; $this->_selector = $selector; + + // keep fallback hash algorithm sha1 if php version is lower than 5.4.8 + if (PHP_VERSION_ID < 50408) { + $this->_hashAlgorithm = 'rsa-sha1'; + } } /** - * Instanciate DKIMSigner - * + * Instanciate DKIMSigner. + * * @param string $privateKey * @param string $domainName * @param string $selector - * @return Swift_Signers_DKIMSigner + * + * @return self */ - public static function newInstance($privateKey, $domainName, $selector) + public static function newInstance($privateKey, $domainName, $selector) { return new static($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; $this->_bodyCanonEmptyCounter = 0; - $this->_bodyCanonLastChar = NULL; + $this->_bodyCanonLastChar = null; $this->_bodyCanonSpace = false; } @@ -227,9 +225,12 @@ class Swift_Signers_DKIMSigner implements Swift_Signers_HeaderSigner * second, etc etc). * * @param string $bytes - * @return int + * * @throws Swift_IoException + * + * @return int */ + // TODO fix return public function write($bytes) { $this->_canonicalizeBody($bytes); @@ -241,8 +242,6 @@ class Swift_Signers_DKIMSigner implements Swift_Signers_HeaderSigner /** * For any bytes that are currently buffered inside the stream, force them * off the buffer. - * - * @throws Swift_IoException */ public function commit() { @@ -279,11 +278,10 @@ class Swift_Signers_DKIMSigner implements Swift_Signers_HeaderSigner foreach ($this->_bound as $k => $stream) { if ($stream === $is) { unset($this->_bound[$k]); + return; } } - - return; } /** @@ -298,28 +296,39 @@ class Swift_Signers_DKIMSigner implements Swift_Signers_HeaderSigner } /** - * 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. * - * @param string $hash - * @return Swift_Signers_DKIMSigner + * @param string $hash 'rsa-sha1' or 'rsa-sha256' + * + * @throws Swift_SwiftException + * + * @return $this */ public function setHashAlgorithm($hash) { - // Unable to sign with rsa-sha256 - if ($hash == 'rsa-sha1') { - $this->_hashAlgorithm = 'rsa-sha1'; - } else { - $this->_hashAlgorithm = 'rsa-sha256'; + switch ($hash) { + case 'rsa-sha1': + $this->_hashAlgorithm = 'rsa-sha1'; + break; + case 'rsa-sha256': + $this->_hashAlgorithm = 'rsa-sha256'; + if (!defined('OPENSSL_ALGO_SHA256')) { + throw new Swift_SwiftException('Unable to set sha256 as it is not supported by OpenSSL.'); + } + break; + default: + throw new Swift_SwiftException('Unable to set the hash algorithm, must be one of rsa-sha1 or rsa-sha256 (%s given).', $hash); } return $this; } /** - * Set the body canonicalization algorithm + * Set the body canonicalization algorithm. * * @param string $canon - * @return Swift_Signers_DKIMSigner + * + * @return $this */ public function setBodyCanon($canon) { @@ -333,10 +342,11 @@ class Swift_Signers_DKIMSigner implements Swift_Signers_HeaderSigner } /** - * Set the header canonicalization algorithm + * Set the header canonicalization algorithm. * * @param string $canon - * @return Swift_Signers_DKIMSigner + * + * @return $this */ public function setHeaderCanon($canon) { @@ -350,10 +360,11 @@ class Swift_Signers_DKIMSigner implements Swift_Signers_HeaderSigner } /** - * Set the signer identity + * Set the signer identity. * * @param string $identity - * @return Swift_Signers_DKIMSigner + * + * @return $this */ public function setSignerIdentity($identity) { @@ -363,10 +374,11 @@ class Swift_Signers_DKIMSigner implements Swift_Signers_HeaderSigner } /** - * 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 + * + * @return $this */ public function setBodySignedLen($len) { @@ -374,7 +386,7 @@ class Swift_Signers_DKIMSigner implements Swift_Signers_HeaderSigner $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; @@ -385,10 +397,11 @@ class Swift_Signers_DKIMSigner implements Swift_Signers_HeaderSigner } /** - * Set the signature timestamp + * Set the signature timestamp. * - * @param timestamp $time - * @return Swift_Signers_DKIMSigner + * @param int $time A timestamp + * + * @return $this */ public function setSignatureTimestamp($time) { @@ -398,10 +411,11 @@ class Swift_Signers_DKIMSigner implements Swift_Signers_HeaderSigner } /** - * Set the signature expiration timestamp + * Set the signature expiration timestamp. * - * @param timestamp $time - * @return Swift_Signers_DKIMSigner + * @param int $time A timestamp + * + * @return $this */ public function setSignatureExpiration($time) { @@ -411,9 +425,10 @@ class Swift_Signers_DKIMSigner implements Swift_Signers_HeaderSigner } /** - * Enable / disable the DebugHeaders + * Enable / disable the DebugHeaders. + * + * @param bool $debug * - * @param bool $debug * @return Swift_Signers_DKIMSigner */ public function setDebugHeaders($debug) @@ -424,17 +439,16 @@ class Swift_Signers_DKIMSigner implements Swift_Signers_HeaderSigner } /** - * 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; } @@ -442,8 +456,7 @@ class Swift_Signers_DKIMSigner implements Swift_Signers_HeaderSigner } /** - * End Body - * + * End Body. */ public function endBody() { @@ -451,7 +464,7 @@ class Swift_Signers_DKIMSigner implements Swift_Signers_HeaderSigner } /** - * Returns the list of Headers Tampered by this plugin + * Returns the list of Headers Tampered by this plugin. * * @return array */ @@ -465,9 +478,10 @@ class Swift_Signers_DKIMSigner implements Swift_Signers_HeaderSigner } /** - * Adds an ignored Header + * Adds an ignored Header. * * @param string $header_name + * * @return Swift_Signers_DKIMSigner */ public function ignoreHeader($header_name) @@ -478,9 +492,10 @@ class Swift_Signers_DKIMSigner implements Swift_Signers_HeaderSigner } /** - * 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) @@ -490,7 +505,7 @@ class Swift_Signers_DKIMSigner implements Swift_Signers_HeaderSigner $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) { @@ -507,9 +522,10 @@ class Swift_Signers_DKIMSigner implements Swift_Signers_HeaderSigner } /** - * 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) @@ -517,7 +533,7 @@ class Swift_Signers_DKIMSigner implements Swift_Signers_HeaderSigner // Prepare the DKIM-Signature $params = array('v' => '1', 'a' => $this->_hashAlgorithm, 'bh' => base64_encode($this->_bodyHash), 'd' => $this->_domainName, 'h' => implode(': ', $this->_signedHeaders), 'i' => $this->_signerIdentity, 's' => $this->_selector); if ($this->_bodyCanon != 'simple') { - $params['c'] = $this->_headerCanon . '/' . $this->_bodyCanon; + $params['c'] = $this->_headerCanon.'/'.$this->_bodyCanon; } elseif ($this->_headerCanon != 'simple') { $params['c'] = $this->_headerCanon; } @@ -542,19 +558,19 @@ class Swift_Signers_DKIMSigner implements Swift_Signers_HeaderSigner } $string = ''; foreach ($params as $k => $v) { - $string .= $k . '=' . $v . '; '; + $string .= $k.'='.$v.'; '; } $string = trim($string); $headers->addTextHeader('DKIM-Signature', $string); // Add the last DKIM-Signature $tmp = $headers->getAll('DKIM-Signature'); $this->_dkimHeader = end($tmp); - $this->_addHeader(trim($this->_dkimHeader->toString()) . "\r\n b=", true); + $this->_addHeader(trim($this->_dkimHeader->toString())."\r\n b=", true); $this->_endOfHeaders(); 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; } @@ -564,39 +580,43 @@ class Swift_Signers_DKIMSigner implements Swift_Signers_HeaderSigner 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 overridden 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; @@ -612,13 +632,13 @@ class Swift_Signers_DKIMSigner implements Swift_Signers_HeaderSigner // 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; @@ -665,11 +685,13 @@ class Swift_Signers_DKIMSigner implements Swift_Signers_HeaderSigner /** * @throws Swift_SwiftException + * * @return string */ private function _getEncryptedHash() { $signature = ''; + switch ($this->_hashAlgorithm) { case 'rsa-sha1': $algorithm = OPENSSL_ALGO_SHA1; @@ -678,7 +700,7 @@ class Swift_Signers_DKIMSigner implements Swift_Signers_HeaderSigner $algorithm = OPENSSL_ALGO_SHA256; break; } - $pkeyId=openssl_get_privatekey($this->_privateKey); + $pkeyId = openssl_get_privatekey($this->_privateKey); if (!$pkeyId) { throw new Swift_SwiftException('Unable to load DKIM Private Key ['.openssl_error_string().']'); } diff --git a/lib/swiftmailer/lib/classes/Swift/Signers/DomainKeySigner.php b/lib/swiftmailer/lib/classes/Swift/Signers/DomainKeySigner.php index d6d728fcc..0365363c8 100644 --- a/lib/swiftmailer/lib/classes/Swift/Signers/DomainKeySigner.php +++ b/lib/swiftmailer/lib/classes/Swift/Signers/DomainKeySigner.php @@ -9,60 +9,58 @@ */ /** - * DomainKey Signer used to apply DomainKeys Signature to a message + * DomainKey Signer used to apply DomainKeys Signature to a message. * - * @package Swift - * @subpackage Signatures - * @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 unknown_type + * @var string */ protected $_signerIdentity; @@ -75,30 +73,23 @@ 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(); /** - * If debugHeaders is set store debugDatas here - * - * @var string - */ - private $_debugHeadersData = ''; - - /** - * Stores the signature header + * Stores the signature header. * * @var Swift_Mime_Headers_ParameterizedHeader */ protected $_domainKeyHeader; /** - * Hash Handler + * Hash Handler. * - * @var hash_ressource + * @var resource|null */ private $_hashHandler; @@ -119,7 +110,7 @@ class Swift_Signers_DomainKeySigner implements Swift_Signers_HeaderSigner private $_bound = array(); /** - * Constructor + * Constructor. * * @param string $privateKey * @param string $domainName @@ -129,26 +120,28 @@ class Swift_Signers_DomainKeySigner implements Swift_Signers_HeaderSigner { $this->_privateKey = $privateKey; $this->_domainName = $domainName; - $this->_signerIdentity = '@' . $domainName; + $this->_signerIdentity = '@'.$domainName; $this->_selector = $selector; } /** - * Instanciate DomainKeySigner + * Instanciate DomainKeySigner. * * @param string $privateKey * @param string $domainName * @param string $selector - * @return Swift_Signers_DomainKeySigner + * + * @return self */ - public static function newInstance($privateKey, $domainName, $selector) { + public static function newInstance($privateKey, $domainName, $selector) + { return new static($privateKey, $domainName, $selector); } - + /** - * Resets internal states + * Resets internal states. * - * @return Swift_Signers_DomainKeysSigner + * @return $this */ public function reset() { @@ -156,7 +149,7 @@ class Swift_Signers_DomainKeySigner implements Swift_Signers_HeaderSigner $this->_hashHandler = null; $this->_bodyCanonIgnoreStart = 2; $this->_bodyCanonEmptyCounter = 0; - $this->_bodyCanonLastChar = NULL; + $this->_bodyCanonLastChar = null; $this->_bodyCanonSpace = false; return $this; @@ -173,9 +166,10 @@ class Swift_Signers_DomainKeySigner implements Swift_Signers_HeaderSigner * second, etc etc). * * @param string $bytes - * @return int + * * @throws Swift_IoException - * @return Swift_Signers_DomainKeysSigner + * + * @return $this */ public function write($bytes) { @@ -192,7 +186,8 @@ class Swift_Signers_DomainKeySigner implements Swift_Signers_HeaderSigner * off the buffer. * * @throws Swift_IoException - * @return Swift_Signers_DomainKeysSigner + * + * @return $this */ public function commit() { @@ -206,7 +201,8 @@ class Swift_Signers_DomainKeySigner implements Swift_Signers_HeaderSigner * All {@link write()} and {@link flushBuffers()} operations will be mirrored. * * @param Swift_InputByteStream $is - * @return Swift_Signers_DomainKeysSigner + * + * @return $this */ public function bind(Swift_InputByteStream $is) { @@ -223,7 +219,8 @@ class Swift_Signers_DomainKeySigner implements Swift_Signers_HeaderSigner * before unbinding occurs. * * @param Swift_InputByteStream $is - * @return Swift_Signers_DomainKeysSigner + * + * @return $this */ public function unbind(Swift_InputByteStream $is) { @@ -232,7 +229,7 @@ class Swift_Signers_DomainKeySigner implements Swift_Signers_HeaderSigner if ($stream === $is) { unset($this->_bound[$k]); - return; + break; } } @@ -244,7 +241,8 @@ class Swift_Signers_DomainKeySigner implements Swift_Signers_HeaderSigner * to the beginning. * * @throws Swift_IoException - * @return Swift_Signers_DomainKeysSigner + * + * @return $this */ public function flushBuffers() { @@ -254,10 +252,11 @@ class Swift_Signers_DomainKeySigner implements Swift_Signers_HeaderSigner } /** - * 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 $this */ public function setHashAlgorithm($hash) { @@ -267,10 +266,11 @@ class Swift_Signers_DomainKeySigner implements Swift_Signers_HeaderSigner } /** - * Set the canonicalization algorithm + * Set the canonicalization algorithm. * * @param string $canon simple | nofws defaults to simple - * @return Swift_Signers_DomainKeysSigner + * + * @return $this */ public function setCanon($canon) { @@ -284,10 +284,11 @@ class Swift_Signers_DomainKeySigner implements Swift_Signers_HeaderSigner } /** - * Set the signer identity + * Set the signer identity. * * @param string $identity - * @return Swift_Signers_DomainKeySigner + * + * @return $this */ public function setSignerIdentity($identity) { @@ -297,10 +298,11 @@ class Swift_Signers_DomainKeySigner implements Swift_Signers_HeaderSigner } /** - * Enable / disable the DebugHeaders + * Enable / disable the DebugHeaders. * - * @param bool $debug - * @return Swift_Signers_DomainKeySigner + * @param bool $debug + * + * @return $this */ public function setDebugHeaders($debug) { @@ -310,16 +312,14 @@ class Swift_Signers_DomainKeySigner implements Swift_Signers_HeaderSigner } /** - * Start Body - * + * Start Body. */ public function startBody() { } /** - * End Body - * + * End Body. */ public function endBody() { @@ -327,7 +327,7 @@ class Swift_Signers_DomainKeySigner implements Swift_Signers_HeaderSigner } /** - * Returns the list of Headers Tampered by this plugin + * Returns the list of Headers Tampered by this plugin. * * @return array */ @@ -335,16 +335,17 @@ class Swift_Signers_DomainKeySigner implements Swift_Signers_HeaderSigner { 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 + * + * @return $this */ public function ignoreHeader($header_name) { @@ -354,10 +355,11 @@ class Swift_Signers_DomainKeySigner implements Swift_Signers_HeaderSigner } /** - * Set the headers to sign + * Set the headers to sign. * * @param Swift_Mime_HeaderSet $headers - * @return Swift_Signers_DomainKeySigner + * + * @return $this */ public function setHeaders(Swift_Mime_HeaderSet $headers) { @@ -367,7 +369,7 @@ class Swift_Signers_DomainKeySigner implements Swift_Signers_HeaderSigner $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) { @@ -385,18 +387,19 @@ class Swift_Signers_DomainKeySigner implements Swift_Signers_HeaderSigner } /** - * Add the signature to the given Headers + * Add the signature to the given Headers. * * @param Swift_Mime_HeaderSet $headers - * @return Swift_Signers_DomainKeySigner + * + * @return $this */ 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 . '; '; + $string .= $k.'='.$v.'; '; } $string = trim($string); $headers->addTextHeader('DomainKey-Signature', $string); @@ -409,14 +412,14 @@ class Swift_Signers_DomainKeySigner implements Swift_Signers_HeaderSigner 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); @@ -431,17 +434,17 @@ class Swift_Signers_DomainKeySigner implements Swift_Signers_HeaderSigner { $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; @@ -457,14 +460,14 @@ class Swift_Signers_DomainKeySigner implements Swift_Signers_HeaderSigner 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; @@ -494,21 +497,22 @@ class Swift_Signers_DomainKeySigner implements Swift_Signers_HeaderSigner { // 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() { $signature = ''; - $pkeyId=openssl_get_privatekey($this->_privateKey); + $pkeyId = openssl_get_privatekey($this->_privateKey); if (!$pkeyId) { throw new Swift_SwiftException('Unable to load DomainKey Private Key ['.openssl_error_string().']'); } diff --git a/lib/swiftmailer/lib/classes/Swift/Signers/HeaderSigner.php b/lib/swiftmailer/lib/classes/Swift/Signers/HeaderSigner.php index 944deac6f..ef8832fdf 100644 --- a/lib/swiftmailer/lib/classes/Swift/Signers/HeaderSigner.php +++ b/lib/swiftmailer/lib/classes/Swift/Signers/HeaderSigner.php @@ -9,57 +9,55 @@ */ /** - * Header Signer Interface used to apply Header-Based Signature to a message + * Header Signer Interface used to apply Header-Based Signature to a message. * - * @package Swift - * @subpackage Signatures - * @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 * - * @return Swift_Signers_HeaderSigner + * @return self */ 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 + * @return self */ 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 + * @return self */ public function endBody(); /** - * Give the headers already given + * Give the headers already given. * * @param Swift_Mime_SimpleHeaderSet $headers * - * @return Swift_Signers_HeaderSigner + * @return self */ 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 * - * @return Swift_Signers_HeaderSigner + * @return self */ 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/lib/swiftmailer/lib/classes/Swift/Signers/OpenDKIMSigner.php b/lib/swiftmailer/lib/classes/Swift/Signers/OpenDKIMSigner.php index 22b57cb8b..8fdbaa43b 100644 --- a/lib/swiftmailer/lib/classes/Swift/Signers/OpenDKIMSigner.php +++ b/lib/swiftmailer/lib/classes/Swift/Signers/OpenDKIMSigner.php @@ -8,14 +8,11 @@ * file that was distributed with this source code. */ - /** * DKIM Signer used to apply DKIM Signature to a message - * Takes advantage of pecl extension + * Takes advantage of pecl extension. * - * @package Swift - * @subpackage Signatures - * @author Xavier De Cock + * @author Xavier De Cock */ class Swift_Signers_OpenDKIMSigner extends Swift_Signers_DKIMSigner { @@ -32,14 +29,15 @@ class Swift_Signers_OpenDKIMSigner extends Swift_Signers_DKIMSigner public function __construct($privateKey, $domainName, $selector) { - if (extension_loaded('opendkim')) { - $this->_peclLoaded = true; - } else { - throw new Swift_SwiftException('php-opendkim extension not found'); + if (!extension_loaded('opendkim')) { + throw new Swift_SwiftException('php-opendkim extension not found'); } + + $this->_peclLoaded = true; + parent::__construct($privateKey, $domainName, $selector); } - + public static function newInstance($privateKey, $domainName, $selector) { return new static($privateKey, $domainName, $selector); @@ -48,7 +46,7 @@ class Swift_Signers_OpenDKIMSigner extends Swift_Signers_DKIMSigner public function addSignature(Swift_Mime_HeaderSet $headers) { $header = new Swift_Mime_Headers_OpenDKIMHeader('DKIM-Signature'); - $headerVal=$this->_dkimHandler->getSignatureHeader(); + $headerVal = $this->_dkimHandler->getSignatureHeader(); if (!$headerVal) { throw new Swift_SwiftException('OpenDKIM Error: '.$this->_dkimHandler->getError()); } @@ -62,34 +60,34 @@ class Swift_Signers_OpenDKIMSigner extends Swift_Signers_DKIMSigner { $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); - + if (!is_numeric($this->_signatureTimestamp)) { - OpenDKIM::setOption(OpenDKIM::OPTS_FIXEDTIME, time()); + OpenDKIM::setOption(OpenDKIM::OPTS_FIXEDTIME, time()); } else { - if (!OpenDKIM::setOption(OpenDKIM::OPTS_FIXEDTIME, $this->_signatureTimestamp)) { - throw new Swift_SwiftException('Unable to force signature timestamp ['.openssl_error_string().']'); - } - } + if (!OpenDKIM::setOption(OpenDKIM::OPTS_FIXEDTIME, $this->_signatureTimestamp)) { + throw new Swift_SwiftException('Unable to force signature timestamp ['.openssl_error_string().']'); + } + } if (isset($this->_signerIdentity)) { $this->_dkimHandler->setSigner($this->_signerIdentity); } $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) { if ($header->getFieldBody() != '') { - $htosign = $header->toString(); + $htosign = $header->toString(); $this->_dkimHandler->header($htosign); $this->_signedHeaders[] = $header->getFieldName(); } @@ -97,25 +95,28 @@ class Swift_Signers_OpenDKIMSigner extends Swift_Signers_DKIMSigner } } } + return $this; } public function startBody() { - if (! $this->_peclLoaded) { + if (!$this->_peclLoaded) { return parent::startBody(); } $this->dropFirstLF = true; $this->_dkimHandler->eoh(); + return $this; } public function endBody() { - if (! $this->_peclLoaded) { - return parent::endBody(); + if (!$this->_peclLoaded) { + return parent::endBody(); } $this->_dkimHandler->eom(); + return $this; } @@ -123,39 +124,44 @@ class Swift_Signers_OpenDKIMSigner extends Swift_Signers_DKIMSigner { $this->_dkimHandler = null; parent::reset(); + return $this; } /** - * Set the signature timestamp + * Set the signature timestamp. * - * @param timestamp $time - * @return Swift_Signers_DKIMSigner + * @param int $time + * + * @return $this */ public function setSignatureTimestamp($time) { - $this->_signatureTimestamp = $time; - return $this; + $this->_signatureTimestamp = $time; + + return $this; } - + /** - * Set the signature expiration timestamp + * Set the signature expiration timestamp. * - * @param timestamp $time - * @return Swift_Signers_DKIMSigner + * @param int $time + * + * @return $this */ public function setSignatureExpiration($time) { - $this->_signatureExpiration = $time; - - return $this; + $this->_signatureExpiration = $time; + + return $this; } - + /** - * Enable / disable the DebugHeaders + * Enable / disable the DebugHeaders. * - * @param bool $debug - * @return Swift_Signers_DKIMSigner + * @param bool $debug + * + * @return $this */ public function setDebugHeaders($debug) { @@ -163,22 +169,22 @@ class Swift_Signers_OpenDKIMSigner extends Swift_Signers_DKIMSigner return $this; } - + // Protected protected function _canonicalizeBody($string) { - if (! $this->_peclLoaded) { + if (!$this->_peclLoaded) { return parent::_canonicalizeBody($string); } if (false && $this->dropFirstLF === true) { - if ($string[0]=="\r" && $string[1]=="\n") { - $string=substr($string, 2); + if ($string[0] == "\r" && $string[1] == "\n") { + $string = substr($string, 2); } } $this->dropFirstLF = false; if (strlen($string)) { - $this->_dkimHandler->body($string); + $this->_dkimHandler->body($string); } } } diff --git a/lib/swiftmailer/lib/classes/Swift/Signers/SMimeSigner.php b/lib/swiftmailer/lib/classes/Swift/Signers/SMimeSigner.php index 5b75e9bcb..d13c02e4c 100644 --- a/lib/swiftmailer/lib/classes/Swift/Signers/SMimeSigner.php +++ b/lib/swiftmailer/lib/classes/Swift/Signers/SMimeSigner.php @@ -11,11 +11,9 @@ /** * MIME Message Signer used to apply S/MIME Signature/Encryption to a message. * - * @package Swift - * @subpackage Signatures * - * @author Romain-Geissler - * @author Sebastiaan Stok + * @author Romain-Geissler + * @author Sebastiaan Stok */ class Swift_Signers_SMimeSigner implements Swift_Signers_BodySigner { @@ -28,6 +26,7 @@ class Swift_Signers_SMimeSigner implements Swift_Signers_BodySigner protected $signOptions; protected $encryptOptions; protected $encryptCipher; + protected $extraCerts = null; /** * @var Swift_StreamFilters_StringReplacementFilterFactory @@ -42,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) { @@ -75,7 +74,7 @@ class Swift_Signers_SMimeSigner implements Swift_Signers_BodySigner * @param string $certificate * @param string $privateKey * - * @return Swift_Signers_SMimeSigner + * @return self */ public static function newInstance($certificate = null, $privateKey = null) { @@ -85,28 +84,32 @@ class Swift_Signers_SMimeSigner implements Swift_Signers_BodySigner /** * Set the certificate location to use for signing. * - * @link http://www.php.net/manual/en/openssl.pkcs7.flags.php + * @see http://www.php.net/manual/en/openssl.pkcs7.flags.php * * @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 + * @return $this */ - 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)); + $this->signCertificate = 'file://'.str_replace('\\', '/', realpath($certificate)); if (null !== $privateKey) { if (is_array($privateKey)) { $this->signPrivateKey = $privateKey; - $this->signPrivateKey[0] = 'file://' . str_replace('\\', '/', realpath($privateKey[0])); + $this->signPrivateKey[0] = 'file://'.str_replace('\\', '/', realpath($privateKey[0])); } else { - $this->signPrivateKey = 'file://' . str_replace('\\', '/', realpath($privateKey)); + $this->signPrivateKey = 'file://'.str_replace('\\', '/', realpath($privateKey)); } } $this->signOptions = $signOptions; + if (null !== $extraCerts) { + $this->extraCerts = str_replace('\\', '/', realpath($extraCerts)); + } return $this; } @@ -114,13 +117,13 @@ class Swift_Signers_SMimeSigner implements Swift_Signers_BodySigner /** * Set the certificate location to use for encryption. * - * @link http://www.php.net/manual/en/openssl.pkcs7.flags.php - * @link http://nl3.php.net/manual/en/openssl.ciphers.php + * @see http://www.php.net/manual/en/openssl.pkcs7.flags.php + * @see http://nl3.php.net/manual/en/openssl.ciphers.php * * @param string|array $recipientCerts Either an single X.509 certificate, or an assoc array of X.509 certificates. * @param int $cipher * - * @return Swift_Signers_SMimeSigner + * @return $this */ public function setEncryptCertificate($recipientCerts, $cipher = null) { @@ -128,10 +131,10 @@ class Swift_Signers_SMimeSigner implements Swift_Signers_BodySigner $this->encryptCert = array(); foreach ($recipientCerts as $cert) { - $this->encryptCert[] = 'file://' . str_replace('\\', '/', realpath($cert)); + $this->encryptCert[] = 'file://'.str_replace('\\', '/', realpath($cert)); } } else { - $this->encryptCert = 'file://' . str_replace('\\', '/', realpath($recipientCerts)); + $this->encryptCert = 'file://'.str_replace('\\', '/', realpath($recipientCerts)); } if (null !== $cipher) { @@ -164,9 +167,9 @@ class Swift_Signers_SMimeSigner implements Swift_Signers_BodySigner * 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 + * @return $this */ public function setSignThenEncrypt($signThenEncrypt = true) { @@ -186,7 +189,7 @@ class Swift_Signers_SMimeSigner implements Swift_Signers_BodySigner /** * Resets internal states. * - * @return Swift_Signers_SMimeSigner + * @return $this */ public function reset() { @@ -198,7 +201,7 @@ class Swift_Signers_SMimeSigner implements Swift_Signers_BodySigner * * @param Swift_Message $message * - * @return Swift_Signers_SMimeSigner + * @return $this */ public function signMessage(Swift_Message $message) { @@ -217,7 +220,6 @@ class Swift_Signers_SMimeSigner implements Swift_Signers_BodySigner $message->setChildren(array()); $this->streamToMime($messageStream, $message); - } /** @@ -232,7 +234,7 @@ class Swift_Signers_SMimeSigner implements Swift_Signers_BodySigner /** * @param Swift_InputByteStream $inputStream - * @param Swift_Message $mimeEntity + * @param Swift_Message $mimeEntity */ protected function toSMimeByteStream(Swift_InputByteStream $inputStream, Swift_Message $message) { @@ -290,7 +292,12 @@ class Swift_Signers_SMimeSigner implements Swift_Signers_BodySigner { $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())); } @@ -371,7 +378,7 @@ class Swift_Signers_SMimeSigner implements Swift_Signers_BodySigner foreach ($headerLines as $headerLine) { // Line separated if (ctype_space($headerLines[0]) || false === strpos($headerLine, ':')) { - $headers[$currentHeaderName] .= ' ' . trim($headerLine); + $headers[$currentHeaderName] .= ' '.trim($headerLine); continue; } @@ -393,7 +400,6 @@ class Swift_Signers_SMimeSigner implements Swift_Signers_BodySigner } $boundary = trim($contentTypeData['1'], '"'); - $boundaryLen = strlen($boundary); // Skip the header and CRLF CRLF $fromStream->setReadPointer($headersPosEnd + 4); diff --git a/lib/swiftmailer/lib/classes/Swift/SmtpTransport.php b/lib/swiftmailer/lib/classes/Swift/SmtpTransport.php index b369f0451..b97f01e7c 100644 --- a/lib/swiftmailer/lib/classes/Swift/SmtpTransport.php +++ b/lib/swiftmailer/lib/classes/Swift/SmtpTransport.php @@ -11,9 +11,8 @@ /** * Sends Messages over SMTP with ESMTP support. * - * @package Swift - * @subpackage Transport - * @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. @@ -26,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) { @@ -46,11 +45,11 @@ class Swift_SmtpTransport extends Swift_Transport_EsmtpTransport /** * 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 + * @return self */ public static function newInstance($host = 'localhost', $port = 25, $security = null) { diff --git a/lib/swiftmailer/lib/classes/Swift/Spool.php b/lib/swiftmailer/lib/classes/Swift/Spool.php index 670be25bd..c16ab4b38 100644 --- a/lib/swiftmailer/lib/classes/Swift/Spool.php +++ b/lib/swiftmailer/lib/classes/Swift/Spool.php @@ -11,8 +11,7 @@ /** * Interface for spools. * - * @package Swift - * @author Fabien Potencier + * @author Fabien Potencier */ interface Swift_Spool { @@ -38,7 +37,7 @@ interface Swift_Spool * * @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); @@ -48,7 +47,7 @@ interface Swift_Spool * @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/lib/swiftmailer/lib/classes/Swift/SpoolTransport.php b/lib/swiftmailer/lib/classes/Swift/SpoolTransport.php index 8a135d4ca..79c9b1f03 100644 --- a/lib/swiftmailer/lib/classes/Swift/SpoolTransport.php +++ b/lib/swiftmailer/lib/classes/Swift/SpoolTransport.php @@ -11,8 +11,7 @@ /** * Stores Messages in a queue. * - * @package Swift - * @author Fabien Potencier + * @author Fabien Potencier */ class Swift_SpoolTransport extends Swift_Transport_SpoolTransport { @@ -39,7 +38,7 @@ class Swift_SpoolTransport extends Swift_Transport_SpoolTransport * * @param Swift_Spool $spool * - * @return Swift_SpoolTransport + * @return self */ public static function newInstance(Swift_Spool $spool) { diff --git a/lib/swiftmailer/lib/classes/Swift/StreamFilter.php b/lib/swiftmailer/lib/classes/Swift/StreamFilter.php index b62e75159..362be2e8d 100644 --- a/lib/swiftmailer/lib/classes/Swift/StreamFilter.php +++ b/lib/swiftmailer/lib/classes/Swift/StreamFilter.php @@ -11,8 +11,7 @@ /** * Processes bytes as they pass through a stream and performs filtering. * - * @package Swift - * @author Chris Corbyn + * @author Chris Corbyn */ interface Swift_StreamFilter { diff --git a/lib/swiftmailer/lib/classes/Swift/StreamFilters/ByteArrayReplacementFilter.php b/lib/swiftmailer/lib/classes/Swift/StreamFilters/ByteArrayReplacementFilter.php index 8cedcbeef..9412b1dc7 100644 --- a/lib/swiftmailer/lib/classes/Swift/StreamFilters/ByteArrayReplacementFilter.php +++ b/lib/swiftmailer/lib/classes/Swift/StreamFilters/ByteArrayReplacementFilter.php @@ -13,8 +13,7 @@ * * This stream filter deals with Byte arrays rather than simple strings. * - * @package Swift - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_StreamFilters_ByteArrayReplacementFilter implements Swift_StreamFilter { @@ -54,11 +53,11 @@ class Swift_StreamFilters_ByteArrayReplacementFilter implements Swift_StreamFilt $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])) { @@ -66,7 +65,7 @@ class Swift_StreamFilters_ByteArrayReplacementFilter implements Swift_StreamFilt } $tree = &$tree[$char]; } - $last_size = $k+1; + $last_size = $k + 1; $size = max($size, $last_size); } else { $last_size = 1; @@ -79,13 +78,13 @@ class Swift_StreamFilters_ByteArrayReplacementFilter implements Swift_StreamFilt } } 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; } @@ -106,14 +105,14 @@ class Swift_StreamFilters_ByteArrayReplacementFilter implements Swift_StreamFilt { $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 */ @@ -125,18 +124,18 @@ class Swift_StreamFilters_ByteArrayReplacementFilter implements Swift_StreamFilt $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 - && $search_pos[-1] > $_minReplaces) - { + 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/lib/swiftmailer/lib/classes/Swift/StreamFilters/StringReplacementFilter.php b/lib/swiftmailer/lib/classes/Swift/StreamFilters/StringReplacementFilter.php index 4075d08a8..f64144af2 100644 --- a/lib/swiftmailer/lib/classes/Swift/StreamFilters/StringReplacementFilter.php +++ b/lib/swiftmailer/lib/classes/Swift/StreamFilters/StringReplacementFilter.php @@ -11,8 +11,7 @@ /** * Processes bytes as they pass through a buffer and replaces sequences in it. * - * @package Swift - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_StreamFilters_StringReplacementFilter implements Swift_StreamFilter { @@ -43,6 +42,10 @@ class Swift_StreamFilters_StringReplacementFilter implements Swift_StreamFilter */ public function shouldBuffer($buffer) { + if ('' === $buffer) { + return false; + } + $endOfBuffer = substr($buffer, -1); foreach ((array) $this->_search as $needle) { if (false !== strpos($needle, $endOfBuffer)) { diff --git a/lib/swiftmailer/lib/classes/Swift/StreamFilters/StringReplacementFilterFactory.php b/lib/swiftmailer/lib/classes/Swift/StreamFilters/StringReplacementFilterFactory.php index bb4af7785..e98240b5b 100644 --- a/lib/swiftmailer/lib/classes/Swift/StreamFilters/StringReplacementFilterFactory.php +++ b/lib/swiftmailer/lib/classes/Swift/StreamFilters/StringReplacementFilterFactory.php @@ -11,8 +11,7 @@ /** * Creates filters for replacing needles in a string buffer. * - * @package Swift - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_StreamFilters_StringReplacementFilterFactory implements Swift_ReplacementFilterFactory { diff --git a/lib/swiftmailer/lib/classes/Swift/SwiftException.php b/lib/swiftmailer/lib/classes/Swift/SwiftException.php index f3bcbed90..db3d31093 100644 --- a/lib/swiftmailer/lib/classes/Swift/SwiftException.php +++ b/lib/swiftmailer/lib/classes/Swift/SwiftException.php @@ -11,18 +11,19 @@ /** * Base Exception class. * - * @package Swift - * @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/lib/swiftmailer/lib/classes/Swift/Transport.php b/lib/swiftmailer/lib/classes/Swift/Transport.php index 69eec54f7..6535eadf2 100644 --- a/lib/swiftmailer/lib/classes/Swift/Transport.php +++ b/lib/swiftmailer/lib/classes/Swift/Transport.php @@ -11,9 +11,7 @@ /** * Sends Messages via an abstract Transport subsystem. * - * @package Swift - * @subpackage Transport - * @author Chris Corbyn + * @author Chris Corbyn */ interface Swift_Transport { diff --git a/lib/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php b/lib/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php index d140f4b3e..60233f968 100644 --- a/lib/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php +++ b/lib/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php @@ -11,9 +11,7 @@ /** * Sends Messages over SMTP. * - * @package Swift - * @subpackage Transport - * @author Chris Corbyn + * @author Chris Corbyn */ abstract class Swift_Transport_AbstractSmtpTransport implements Swift_Transport { @@ -59,7 +57,7 @@ abstract class Swift_Transport_AbstractSmtpTransport implements Swift_Transport * * @param string $domain * - * @return Swift_Transport_AbstractSmtpTransport + * @return $this */ public function setLocalDomain($domain) { @@ -85,11 +83,11 @@ abstract class Swift_Transport_AbstractSmtpTransport implements Swift_Transport */ public function setSourceIp($source) { - $this->_sourceIp=$source; + $this->_sourceIp = $source; } /** - * Returns the IP used to connect to the destination + * Returns the IP used to connect to the destination. * * @return string */ @@ -161,20 +159,21 @@ abstract class Swift_Transport_AbstractSmtpTransport implements Swift_Transport } if (!$reversePath = $this->_getReversePath($message)) { - throw new Swift_TransportException( + $this->_throwException(new Swift_TransportException( 'Cannot send message without a sender address' - ); + ) + ); } $to = (array) $message->getTo(); $cc = (array) $message->getCc(); + $tos = array_merge($to, $cc); $bcc = (array) $message->getBcc(); $message->setBcc(array()); try { - $sent += $this->_sendTo($message, $reversePath, $to, $failedRecipients); - $sent += $this->_sendCc($message, $reversePath, $cc, $failedRecipients); + $sent += $this->_sendTo($message, $reversePath, $tos, $failedRecipients); $sent += $this->_sendBcc($message, $reversePath, $bcc, $failedRecipients); } catch (Exception $e) { $message->setBcc($bcc); @@ -215,7 +214,8 @@ abstract class Swift_Transport_AbstractSmtpTransport implements Swift_Transport try { $this->executeCommand("QUIT\r\n", array(221)); - } catch (Swift_TransportException $e) {} + } catch (Swift_TransportException $e) { + } try { $this->_buffer->terminate(); @@ -283,8 +283,6 @@ abstract class Swift_Transport_AbstractSmtpTransport implements Swift_Transport return $response; } - // -- Protected methods - /** Read the opening SMTP greeting */ protected function _readGreeting() { @@ -303,7 +301,7 @@ abstract class Swift_Transport_AbstractSmtpTransport implements Swift_Transport protected function _doMailFromCommand($address) { $this->executeCommand( - sprintf("MAIL FROM: <%s>\r\n", $address), array(250) + sprintf("MAIL FROM:<%s>\r\n", $address), array(250) ); } @@ -311,7 +309,7 @@ abstract class Swift_Transport_AbstractSmtpTransport implements Swift_Transport 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) ); } @@ -376,16 +374,15 @@ abstract class Swift_Transport_AbstractSmtpTransport implements Swift_Transport $valid = (empty($wanted) || in_array($code, $wanted)); if ($evt = $this->_eventDispatcher->createResponseEvent($this, $response, - $valid)) - { + $valid)) { $this->_eventDispatcher->dispatchEvent($evt, 'responseReceived'); } if (!$valid) { $this->_throwException( new Swift_TransportException( - 'Expected response code ' . implode('/', $wanted) . ' but got code ' . - '"' . $code . '", with message "' . $response . '"', + 'Expected response code '.implode('/', $wanted).' but got code '. + '"'.$code.'", with message "'.$response.'"', $code) ); } @@ -399,21 +396,19 @@ abstract class Swift_Transport_AbstractSmtpTransport implements Swift_Transport do { $line = $this->_buffer->readLine($seq); $response .= $line; - } while (null !== $line && false !== $line && ' ' != $line{3}); + } while (null !== $line && false !== $line && ' ' != $line[3]); + } catch (Swift_TransportException $e) { + $this->_throwException($e); } catch (Swift_IoException $e) { $this->_throwException( new Swift_TransportException( $e->getMessage()) ); - } catch (Swift_TransportException $e) { - $this->_throwException($e); } return $response; } - // -- Private methods - /** Send an email to the given recipients from the given reverse path */ private function _doMailTransaction($message, $reversePath, array $recipients, array &$failedRecipients) { @@ -422,7 +417,7 @@ abstract class Swift_Transport_AbstractSmtpTransport implements Swift_Transport foreach ($recipients as $forwardPath) { try { $this->_doRcptToCommand($forwardPath); - $sent++; + ++$sent; } catch (Swift_TransportException $e) { $failedRecipients[] = $forwardPath; } @@ -449,17 +444,6 @@ abstract class Swift_Transport_AbstractSmtpTransport implements Swift_Transport $failedRecipients); } - /** Send a message to the given Cc: recipients */ - private function _sendCc(Swift_Mime_Message $message, $reversePath, array $cc, array &$failedRecipients) - { - if (empty($cc)) { - return 0; - } - - return $this->_doMailTransaction($message, $reversePath, array_keys($cc), - $failedRecipients); - } - /** Send a message to all Bcc: recipients */ private function _sendBcc(Swift_Mime_Message $message, $reversePath, array $bcc, array &$failedRecipients) { @@ -477,12 +461,17 @@ abstract class Swift_Transport_AbstractSmtpTransport implements Swift_Transport /** 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']); } } @@ -492,9 +481,9 @@ abstract class Swift_Transport_AbstractSmtpTransport implements Swift_Transport // 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; } /** @@ -502,6 +491,9 @@ abstract class Swift_Transport_AbstractSmtpTransport implements Swift_Transport */ public function __destruct() { - $this->stop(); + try { + $this->stop(); + } catch (Exception $e) { + } } } diff --git a/lib/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/CramMd5Authenticator.php b/lib/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/CramMd5Authenticator.php index 5c26e4b8b..53f721d03 100644 --- a/lib/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/CramMd5Authenticator.php +++ b/lib/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/CramMd5Authenticator.php @@ -11,9 +11,7 @@ /** * Handles CRAM-MD5 authentication. * - * @package Swift - * @subpackage Transport - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_Transport_Esmtp_Auth_CramMd5Authenticator implements Swift_Transport_Esmtp_Authenticator { @@ -42,7 +40,7 @@ class Swift_Transport_Esmtp_Auth_CramMd5Authenticator implements Swift_Transport $challenge = $agent->executeCommand("AUTH CRAM-MD5\r\n", array(334)); $challenge = base64_decode(substr($challenge, 4)); $message = base64_encode( - $username . ' ' . $this->_getResponse($password, $challenge) + $username.' '.$this->_getResponse($password, $challenge) ); $agent->executeCommand(sprintf("%s\r\n", $message), array(235)); @@ -75,8 +73,8 @@ class Swift_Transport_Esmtp_Auth_CramMd5Authenticator implements Swift_Transport $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)); - $digest = md5($k_opad . $inner); + $inner = pack('H32', md5($k_ipad.$challenge)); + $digest = md5($k_opad.$inner); return $digest; } diff --git a/lib/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/LoginAuthenticator.php b/lib/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/LoginAuthenticator.php index 8ff7dee86..6ab6e3337 100644 --- a/lib/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/LoginAuthenticator.php +++ b/lib/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/LoginAuthenticator.php @@ -11,9 +11,7 @@ /** * Handles LOGIN authentication. * - * @package Swift - * @subpackage Transport - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_Transport_Esmtp_Auth_LoginAuthenticator implements Swift_Transport_Esmtp_Authenticator { diff --git a/lib/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/NTLMAuthenticator.php b/lib/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/NTLMAuthenticator.php index 62eacdd7b..839265857 100644 --- a/lib/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/NTLMAuthenticator.php +++ b/lib/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/NTLMAuthenticator.php @@ -13,14 +13,12 @@ /** * Handles NTLM authentication. * - * @package Swift - * @subpackage Transport - * @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. @@ -36,23 +34,19 @@ class Swift_Transport_Esmtp_Auth_NTLMAuthenticator implements Swift_Transport_Es * 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 { @@ -61,7 +55,7 @@ class Swift_Transport_Esmtp_Auth_NTLMAuthenticator implements Swift_Transport_Es $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 @@ -85,14 +79,15 @@ class Swift_Transport_Esmtp_Auth_NTLMAuthenticator implements Swift_Transport_Es // 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 + } else { + // negative $si = -$si - pow(2, $bits); $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; } } } @@ -101,9 +96,10 @@ class Swift_Transport_Esmtp_Auth_NTLMAuthenticator implements Swift_Transport_Es } /** - * 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) @@ -114,9 +110,10 @@ class Swift_Transport_Esmtp_Auth_NTLMAuthenticator implements Swift_Transport_Es } /** - * 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) @@ -142,14 +139,15 @@ class Swift_Transport_Esmtp_Auth_NTLMAuthenticator implements Swift_Transport_Es $DNSDomainName, $DNSServerName, $this->hex2bin($targetInfoBlock), - $terminatorByte + $terminatorByte, ); } /** - * Read the blob information in from message2 + * Read the blob information in from message2. * * @param $block + * * @return array */ protected function readSubBlock($block) @@ -178,15 +176,16 @@ class Swift_Transport_Esmtp_Auth_NTLMAuthenticator implements Swift_Transport_Es } /** - * 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) @@ -213,25 +212,26 @@ class Swift_Transport_Esmtp_Auth_NTLMAuthenticator implements Swift_Transport_Es } /** - * Create our message 1 + * Create our message 1. * * @return string */ protected function createMessage1() { return self::NTLMSIG - . $this->createByte('01') // Message 1 - . $this->createByte('0702'); // Flags + .$this->createByte('01') // Message 1 +.$this->createByte('0702'); // Flags } /** - * 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) @@ -248,44 +248,46 @@ class Swift_Transport_Esmtp_Auth_NTLMAuthenticator implements Swift_Transport_Es $ntlmSec = $this->createSecurityBuffer($ntlmResponse, ($lmInfo[0] + $lmInfo[1]) / 2, true); return self::NTLMSIG - . $this->createByte('03') // TYPE 3 message - . $lmSec // LM response header - . $ntlmSec // NTLM response header - . $domainSec // Domain header - . $userSec // User header - . $workSec // Workstation header - . $this->createByte("000000009a", 8) // session key header (empty) - . $this->createByte('01020000') // FLAGS - . $this->convertTo16bit($domain) // domain name - . $this->convertTo16bit($username) // username - . $this->convertTo16bit($workstation) // workstation - . $lmResponse - . $ntlmResponse; + .$this->createByte('03') // TYPE 3 message +.$lmSec // LM response header +.$ntlmSec // NTLM response header +.$domainSec // Domain header +.$userSec // User header +.$workSec // Workstation header +.$this->createByte('000000009a', 8) // session key header (empty) +.$this->createByte('01020000') // FLAGS +.$this->convertTo16bit($domain) // domain name +.$this->convertTo16bit($username) // username +.$this->convertTo16bit($workstation) // workstation +.$lmResponse + .$ntlmResponse; } /** - * @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) { return $this->createByte('0101') - . $this->createByte('00') - . $timestamp - . $client - . $this->createByte('00') - . $targetInfo - . $this->createByte('00'); + .$this->createByte('00') + .$timestamp + .$client + .$this->createByte('00') + .$targetInfo + .$this->createByte('00'); } /** - * 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) @@ -294,16 +296,22 @@ class Swift_Transport_Esmtp_Auth_NTLMAuthenticator implements Swift_Transport_Es return explode('\\', $name); } - list($user, $domain) = explode('@', $name); + if (false !== strpos($name, '@')) { + list($user, $domain) = explode('@', $name); - return array($domain, $user); + return array($domain, $user); + } + + // no domain passed + return array('', $name); } /** - * Create LMv1 response + * Create LMv1 response. * * @param string $password * @param string $challenge + * * @return string */ protected function createLMPassword($password, $challenge) @@ -315,7 +323,7 @@ class Swift_Transport_Esmtp_Auth_NTLMAuthenticator implements Swift_Transport_Es $desKey1 = $this->createDesKey($key1); $desKey2 = $this->createDesKey($key2); - $constantDecrypt = $this->createByte($this->desEncrypt(self::DESCONST, $desKey1) . $this->desEncrypt(self::DESCONST, $desKey2), 21, false); + $constantDecrypt = $this->createByte($this->desEncrypt(self::DESCONST, $desKey1).$this->desEncrypt(self::DESCONST, $desKey2), 21, false); // SECOND PART list($key1, $key2, $key3) = str_split($constantDecrypt, 7); @@ -324,14 +332,15 @@ class Swift_Transport_Esmtp_Auth_NTLMAuthenticator implements Swift_Transport_Es $desKey2 = $this->createDesKey($key2); $desKey3 = $this->createDesKey($key3); - return $this->desEncrypt($challenge, $desKey1) . $this->desEncrypt($challenge, $desKey2) . $this->desEncrypt($challenge, $desKey3); + return $this->desEncrypt($challenge, $desKey1).$this->desEncrypt($challenge, $desKey2).$this->desEncrypt($challenge, $desKey3); } /** - * Create NTLMv1 response + * Create NTLMv1 response. * * @param string $password * @param string $challenge + * * @return string */ protected function createNTLMPassword($password, $challenge) @@ -344,27 +353,26 @@ class Swift_Transport_Esmtp_Auth_NTLMAuthenticator implements Swift_Transport_Es $desKey2 = $this->createDesKey($key2); $desKey3 = $this->createDesKey($key3); - return $this->desEncrypt($challenge, $desKey1) . $this->desEncrypt($challenge, $desKey2) . $this->desEncrypt($challenge, $desKey3); + return $this->desEncrypt($challenge, $desKey1).$this->desEncrypt($challenge, $desKey2).$this->desEncrypt($challenge, $desKey3); } /** - * 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) { // Get our timestamp (tricky!) - bcscale(0); - $time = number_format($time, 0, '.', ''); // save microtime to string - $time = bcadd($time, "11644473600000"); // add epoch time - $time = bcmul($time, 10000); // tenths of a microsecond. + $time = bcadd($time, '11644473600000', 0); // add epoch time + $time = bcmul($time, 10000, 0); // 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))); } @@ -372,13 +380,14 @@ class Swift_Transport_Esmtp_Auth_NTLMAuthenticator implements Swift_Transport_Es } /** - * 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) @@ -387,47 +396,49 @@ class Swift_Transport_Esmtp_Auth_NTLMAuthenticator implements Swift_Transport_Es // if $password > 15 than we can't use this method if (strlen($password) <= 15) { $ntlmHash = $this->md4Encrypt($password); - $ntml2Hash = $this->md5Encrypt($ntlmHash, $this->convertTo16bit(strtoupper($username) . $domain)); + $ntml2Hash = $this->md5Encrypt($ntlmHash, $this->convertTo16bit(strtoupper($username).$domain)); - $lmPass = bin2hex($this->md5Encrypt($ntml2Hash, $challenge . $client) . $client); + $lmPass = bin2hex($this->md5Encrypt($ntml2Hash, $challenge.$client).$client); } return $this->createByte($lmPass, 24); } /** - * 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) { $ntlmHash = $this->md4Encrypt($password); - $ntml2Hash = $this->md5Encrypt($ntlmHash, $this->convertTo16bit(strtoupper($username) . $domain)); + $ntml2Hash = $this->md5Encrypt($ntlmHash, $this->convertTo16bit(strtoupper($username).$domain)); // create blob $blob = $this->createBlob($timestamp, $client, $targetInfo); - $ntlmv2Response = $this->md5Encrypt($ntml2Hash, $challenge . $blob); + $ntlmv2Response = $this->md5Encrypt($ntml2Hash, $challenge.$blob); - return $ntlmv2Response . $blob; + return $ntlmv2Response.$blob; } 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)); + $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 } $material[] = str_pad(substr(dechex($this->castToByte(ord($key[6]) << 1)), -2), 2, '0'); @@ -441,9 +452,9 @@ class Swift_Transport_Esmtp_Auth_NTLMAuthenticator implements Swift_Transport_Es list($high, $low) = str_split($v); if ($needsParity) { - $material[$k] = dechex(hexdec($high) | 0x0) . dechex(hexdec($low) | 0x1); + $material[$k] = dechex(hexdec($high) | 0x0).dechex(hexdec($low) | 0x1); } else { - $material[$k] = dechex(hexdec($high) & 0xf) . dechex(hexdec($low) & 0xe); + $material[$k] = dechex(hexdec($high) & 0xf).dechex(hexdec($low) & 0xe); } } @@ -451,12 +462,14 @@ class Swift_Transport_Esmtp_Auth_NTLMAuthenticator implements Swift_Transport_Es } /** 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) @@ -465,13 +478,14 @@ class Swift_Transport_Esmtp_Auth_NTLMAuthenticator implements Swift_Transport_Es $length = $is16 ? $length / 2 : $length; $length = $this->createByte(str_pad(dechex($length), 2, '0', STR_PAD_LEFT), 2); - return $length . $length . $this->createByte(dechex($offset), 4); + return $length.$length.$this->createByte(dechex($offset), 4); } /** - * 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) @@ -483,9 +497,10 @@ class Swift_Transport_Esmtp_Auth_NTLMAuthenticator implements Swift_Transport_Es } /** - * Cast to byte java equivalent to (byte) + * Cast to byte java equivalent to (byte). * * @param int $v + * * @return int */ protected function castToByte($v) @@ -495,10 +510,11 @@ class Swift_Transport_Esmtp_Auth_NTLMAuthenticator implements Swift_Transport_Es /** * Java unsigned right bitwise - * $a >>> $b + * $a >>> $b. * * @param int $a * @param int $b + * * @return int */ protected function uRShift($a, $b) @@ -511,11 +527,12 @@ class Swift_Transport_Esmtp_Auth_NTLMAuthenticator implements Swift_Transport_Es } /** - * 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) @@ -530,9 +547,10 @@ class Swift_Transport_Esmtp_Auth_NTLMAuthenticator implements Swift_Transport_Es } /** - * Create random bytes + * Create random bytes. * * @param $length + * * @return string */ protected function getRandomBytes($length) @@ -547,26 +565,27 @@ class Swift_Transport_Esmtp_Auth_NTLMAuthenticator implements Swift_Transport_Es } /** 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) @@ -580,14 +599,16 @@ class Swift_Transport_Esmtp_Auth_NTLMAuthenticator implements Swift_Transport_Es $ipadk = $key ^ str_repeat("\x36", $blocksize); $opadk = $key ^ str_repeat("\x5c", $blocksize); - return pack('H*', md5($opadk . pack('H*', md5($ipadk . $msg)))); + return pack('H*', md5($opadk.pack('H*', md5($ipadk.$msg)))); } /** - * MD4 Encryption + * MD4 Encryption. * * @param string $input + * * @return string + * * @see http://php.net/manual/en/ref.hash.php */ protected function md4Encrypt($input) @@ -598,9 +619,10 @@ class Swift_Transport_Esmtp_Auth_NTLMAuthenticator implements Swift_Transport_Es } /** - * Convert UTF-8 to UTF-16 + * Convert UTF-8 to UTF-16. * * @param string $input + * * @return string */ protected function convertTo16bit($input) @@ -609,8 +631,10 @@ class Swift_Transport_Esmtp_Auth_NTLMAuthenticator implements Swift_Transport_Es } /** - * Hex2bin replacement for < PHP 5.4 + * Hex2bin replacement for < PHP 5.4. + * * @param string $hex + * * @return string Binary */ protected function hex2bin($hex) @@ -629,10 +653,10 @@ class Swift_Transport_Esmtp_Auth_NTLMAuthenticator implements Swift_Transport_Es { $message = bin2hex($message); $messageId = substr($message, 16, 8); - echo substr($message, 0, 16) . " NTLMSSP Signature
\n"; - echo $messageId . " Type Indicator
\n"; + echo substr($message, 0, 16)." NTLMSSP Signature
\n"; + echo $messageId." Type Indicator
\n"; - if ($messageId == "02000000") { + if ($messageId == '02000000') { $map = array( 'Challenge', 'Context', @@ -649,9 +673,9 @@ class Swift_Transport_Esmtp_Auth_NTLMAuthenticator implements Swift_Transport_Es $data = $this->parseMessage2($this->hex2bin($message)); foreach ($map as $key => $value) { - echo bin2hex($data[$key]) . ' - ' . $data[$key] . ' ||| ' . $value . "
\n"; + 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]); @@ -692,10 +716,10 @@ class Swift_Transport_Esmtp_Auth_NTLMAuthenticator implements Swift_Transport_Es ); foreach ($map as $key => $value) { - echo $data[$key] . ' - ' . $this->hex2bin($data[$key]) . ' ||| ' . $value . "
\n"; + echo $data[$key].' - '.$this->hex2bin($data[$key]).' ||| '.$value."
\n"; } } - echo "

"; + echo '

'; } } diff --git a/lib/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/PlainAuthenticator.php b/lib/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/PlainAuthenticator.php index 6b5a9db2b..43219f934 100644 --- a/lib/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/PlainAuthenticator.php +++ b/lib/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/PlainAuthenticator.php @@ -11,9 +11,7 @@ /** * Handles PLAIN authentication. * - * @package Swift - * @subpackage Transport - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_Transport_Esmtp_Auth_PlainAuthenticator implements Swift_Transport_Esmtp_Authenticator { @@ -39,7 +37,7 @@ class Swift_Transport_Esmtp_Auth_PlainAuthenticator implements Swift_Transport_E public function authenticate(Swift_Transport_SmtpAgent $agent, $username, $password) { try { - $message = base64_encode($username . chr(0) . $username . chr(0) . $password); + $message = base64_encode($username.chr(0).$username.chr(0).$password); $agent->executeCommand(sprintf("AUTH PLAIN %s\r\n", $message), array(235)); return true; diff --git a/lib/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/XOAuth2Authenticator.php b/lib/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/XOAuth2Authenticator.php index de19fc1ba..ca35e7b83 100644 --- a/lib/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/XOAuth2Authenticator.php +++ b/lib/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/XOAuth2Authenticator.php @@ -18,10 +18,9 @@ * ->setUsername('YOUR_EMAIL_ADDRESS') * ->setPassword('YOUR_ACCESS_TOKEN'); * - * - * @package Swift - * @subpackage Transport - * @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 @@ -49,7 +48,7 @@ class Swift_Transport_Esmtp_Auth_XOAuth2Authenticator implements Swift_Transport { 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,12 +57,12 @@ class Swift_Transport_Esmtp_Auth_XOAuth2Authenticator implements Swift_Transport return false; } } - + /** - * Construct the auth parameter + * Construct the auth parameter. * * @see https://developers.google.com/google-apps/gmail/xoauth2_protocol#the_sasl_xoauth2_mechanism - */ + */ protected function constructXOAuth2Params($email, $token) { return base64_encode("user=$email\1auth=Bearer $token\1\1"); diff --git a/lib/swiftmailer/lib/classes/Swift/Transport/Esmtp/AuthHandler.php b/lib/swiftmailer/lib/classes/Swift/Transport/Esmtp/AuthHandler.php index 452ab8204..cb36133c9 100644 --- a/lib/swiftmailer/lib/classes/Swift/Transport/Esmtp/AuthHandler.php +++ b/lib/swiftmailer/lib/classes/Swift/Transport/Esmtp/AuthHandler.php @@ -11,9 +11,7 @@ /** * An ESMTP handler for AUTH support. * - * @package Swift - * @subpackage Transport - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_Transport_Esmtp_AuthHandler implements Swift_Transport_EsmtpHandler { @@ -173,17 +171,16 @@ class Swift_Transport_Esmtp_AuthHandler implements Swift_Transport_EsmtpHandler $count = 0; foreach ($this->_getAuthenticatorsForAgent() as $authenticator) { if (in_array(strtolower($authenticator->getAuthKeyword()), - array_map('strtolower', $this->_esmtpParams))) - { - $count++; + array_map('strtolower', $this->_esmtpParams))) { + ++$count; if ($authenticator->authenticate($agent, $this->_username, $this->_password)) { return; } } } throw new Swift_TransportException( - 'Failed to authenticate on SMTP server with username "' . - $this->_username . '" using ' . $count . ' possible authenticators' + 'Failed to authenticate on SMTP server with username "'. + $this->_username.'" using '.$count.' possible authenticators' ); } } @@ -242,8 +239,6 @@ class Swift_Transport_Esmtp_AuthHandler implements Swift_Transport_EsmtpHandler { } - // -- Protected methods - /** * Returns the authenticator list for the given agent. * diff --git a/lib/swiftmailer/lib/classes/Swift/Transport/Esmtp/Authenticator.php b/lib/swiftmailer/lib/classes/Swift/Transport/Esmtp/Authenticator.php index c1d4a0470..12a9abf81 100644 --- a/lib/swiftmailer/lib/classes/Swift/Transport/Esmtp/Authenticator.php +++ b/lib/swiftmailer/lib/classes/Swift/Transport/Esmtp/Authenticator.php @@ -11,9 +11,7 @@ /** * An Authentication mechanism. * - * @package Swift - * @subpackage Transport - * @author Chris Corbyn + * @author Chris Corbyn */ interface Swift_Transport_Esmtp_Authenticator { diff --git a/lib/swiftmailer/lib/classes/Swift/Transport/EsmtpHandler.php b/lib/swiftmailer/lib/classes/Swift/Transport/EsmtpHandler.php index 83fb71b1e..c17ef8feb 100644 --- a/lib/swiftmailer/lib/classes/Swift/Transport/EsmtpHandler.php +++ b/lib/swiftmailer/lib/classes/Swift/Transport/EsmtpHandler.php @@ -11,9 +11,7 @@ /** * An ESMTP handler. * - * @package Swift - * @subpackage Transport - * @author Chris Corbyn + * @author Chris Corbyn */ interface Swift_Transport_EsmtpHandler { diff --git a/lib/swiftmailer/lib/classes/Swift/Transport/EsmtpTransport.php b/lib/swiftmailer/lib/classes/Swift/Transport/EsmtpTransport.php index 6ad5b098a..156e2cf5b 100644 --- a/lib/swiftmailer/lib/classes/Swift/Transport/EsmtpTransport.php +++ b/lib/swiftmailer/lib/classes/Swift/Transport/EsmtpTransport.php @@ -11,9 +11,7 @@ /** * Sends Messages over SMTP with ESMTP support. * - * @package Swift - * @subpackage Transport - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_Transport_EsmtpTransport extends Swift_Transport_AbstractSmtpTransport implements Swift_Transport_SmtpAgent { @@ -43,7 +41,8 @@ class Swift_Transport_EsmtpTransport extends Swift_Transport_AbstractSmtpTranspo 'timeout' => 30, 'blocking' => 1, 'tls' => false, - 'type' => Swift_Transport_IoBuffer::TYPE_SOCKET + 'type' => Swift_Transport_IoBuffer::TYPE_SOCKET, + 'stream_context_options' => array(), ); /** @@ -64,7 +63,7 @@ class Swift_Transport_EsmtpTransport extends Swift_Transport_AbstractSmtpTranspo * * @param string $host * - * @return Swift_Transport_EsmtpTransport + * @return $this */ public function setHost($host) { @@ -86,9 +85,9 @@ class Swift_Transport_EsmtpTransport extends Swift_Transport_AbstractSmtpTranspo /** * Set the port to connect to. * - * @param int $port + * @param int $port * - * @return Swift_Transport_EsmtpTransport + * @return $this */ public function setPort($port) { @@ -110,9 +109,9 @@ class Swift_Transport_EsmtpTransport extends Swift_Transport_AbstractSmtpTranspo /** * Set the connection timeout. * - * @param int $timeout seconds + * @param int $timeout seconds * - * @return Swift_Transport_EsmtpTransport + * @return $this */ public function setTimeout($timeout) { @@ -133,14 +132,15 @@ class Swift_Transport_EsmtpTransport extends Swift_Transport_AbstractSmtpTranspo } /** - * Set the encryption type (tls or ssl) + * Set the encryption type (tls or ssl). * * @param string $encryption * - * @return Swift_Transport_EsmtpTransport + * @return $this */ public function setEncryption($encryption) { + $encryption = strtolower($encryption); if ('tls' == $encryption) { $this->_params['protocol'] = 'tcp'; $this->_params['tls'] = true; @@ -162,16 +162,40 @@ class Swift_Transport_EsmtpTransport extends Swift_Transport_AbstractSmtpTranspo return $this->_params['tls'] ? 'tls' : $this->_params['protocol']; } + /** + * Sets the stream context options. + * + * @param array $options + * + * @return $this + */ + 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. * * @param string $source * - * @return Swift_Transport_EsmtpTransport + * @return $this */ public function setSourceIp($source) { - $this->_params['sourceIp']=$source; + $this->_params['sourceIp'] = $source; return $this; } @@ -183,7 +207,7 @@ class Swift_Transport_EsmtpTransport extends Swift_Transport_AbstractSmtpTranspo */ public function getSourceIp() { - return $this->_params['sourceIp']; + return isset($this->_params['sourceIp']) ? $this->_params['sourceIp'] : null; } /** @@ -191,7 +215,7 @@ class Swift_Transport_EsmtpTransport extends Swift_Transport_AbstractSmtpTranspo * * @param Swift_Transport_EsmtpHandler[] $handlers * - * @return Swift_Transport_EsmtpTransport + * @return $this */ public function setExtensionHandlers(array $handlers) { @@ -199,7 +223,8 @@ class Swift_Transport_EsmtpTransport extends Swift_Transport_AbstractSmtpTranspo foreach ($handlers as $handler) { $assoc[$handler->getHandledKeyword()] = $handler; } - uasort($assoc, array($this, '_sortHandlers')); + + @uasort($assoc, array($this, '_sortHandlers')); $this->_handlers = $assoc; $this->_setHandlerParams(); @@ -245,30 +270,25 @@ class Swift_Transport_EsmtpTransport extends Swift_Transport_AbstractSmtpTranspo return parent::executeCommand($command, $codes, $failures); } - // -- Mixin invocation code - /** Mixin handling method for ESMTP handlers */ public function __call($method, $args) { foreach ($this->_handlers as $handler) { if (in_array(strtolower($method), array_map('strtolower', (array) $handler->exposeMixinMethods()) - )) - { + )) { $return = call_user_func_array(array($handler, $method), $args); // Allow fluid method calls - if (is_null($return) && substr($method, 0, 3) == 'set') { + if (null === $return && substr($method, 0, 3) == 'set') { return $this; } else { return $return; } } } - trigger_error('Call to undefined method ' . $method, E_USER_ERROR); + trigger_error('Call to undefined method '.$method, E_USER_ERROR); } - // -- Protected methods - /** Get the params to initialize the buffer */ protected function _getBufferParams() { @@ -321,9 +341,9 @@ class Swift_Transport_EsmtpTransport extends Swift_Transport_AbstractSmtpTranspo foreach ($handlers as $handler) { $params = array_merge($params, (array) $handler->getMailParams()); } - $paramStr = !empty($params) ? ' ' . implode(' ', $params) : ''; + $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) ); } @@ -335,14 +355,12 @@ class Swift_Transport_EsmtpTransport extends Swift_Transport_AbstractSmtpTranspo foreach ($handlers as $handler) { $params = array_merge($params, (array) $handler->getRcptParams()); } - $paramStr = !empty($params) ? ' ' . implode(' ', $params) : ''; + $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) ); } - // -- Private methods - /** Determine ESMTP capabilities by function group */ private function _getCapabilities($ehloResponse) { diff --git a/lib/swiftmailer/lib/classes/Swift/Transport/FailoverTransport.php b/lib/swiftmailer/lib/classes/Swift/Transport/FailoverTransport.php index d0d3f69be..311a0f2ad 100644 --- a/lib/swiftmailer/lib/classes/Swift/Transport/FailoverTransport.php +++ b/lib/swiftmailer/lib/classes/Swift/Transport/FailoverTransport.php @@ -11,9 +11,7 @@ /** * Contains a list of redundant Transports so when one fails, the next is used. * - * @package Swift - * @subpackage Transport - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_Transport_FailoverTransport extends Swift_Transport_LoadBalancedTransport { @@ -24,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(); @@ -47,16 +43,20 @@ class Swift_Transport_FailoverTransport extends Swift_Transport_LoadBalancedTran { $maxTransports = count($this->_transports); $sent = 0; + $this->_lastUsedTransport = null; for ($i = 0; $i < $maxTransports - && $transport = $this->_getNextTransport(); ++$i) - { + && $transport = $this->_getNextTransport(); ++$i) { try { if (!$transport->isStarted()) { $transport->start(); } - return $transport->send($message, $failedRecipients); + if ($sent = $transport->send($message, $failedRecipients)) { + $this->_lastUsedTransport = $transport; + + return $sent; + } } catch (Swift_TransportException $e) { $this->_killCurrentTransport(); } @@ -71,8 +71,6 @@ class Swift_Transport_FailoverTransport extends Swift_Transport_LoadBalancedTran return $sent; } - // -- Protected methods - protected function _getNextTransport() { if (!isset($this->_currentTransport)) { diff --git a/lib/swiftmailer/lib/classes/Swift/Transport/IoBuffer.php b/lib/swiftmailer/lib/classes/Swift/Transport/IoBuffer.php index 835895118..af97adf1f 100644 --- a/lib/swiftmailer/lib/classes/Swift/Transport/IoBuffer.php +++ b/lib/swiftmailer/lib/classes/Swift/Transport/IoBuffer.php @@ -11,9 +11,7 @@ /** * Buffers input and output to a resource. * - * @package Swift - * @subpackage Transport - * @author Chris Corbyn + * @author Chris Corbyn */ interface Swift_Transport_IoBuffer extends Swift_InputByteStream, Swift_OutputByteStream { @@ -61,7 +59,7 @@ interface Swift_Transport_IoBuffer extends Swift_InputByteStream, Swift_OutputBy * 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/lib/swiftmailer/lib/classes/Swift/Transport/LoadBalancedTransport.php b/lib/swiftmailer/lib/classes/Swift/Transport/LoadBalancedTransport.php index 7a82632d9..e2adc567e 100644 --- a/lib/swiftmailer/lib/classes/Swift/Transport/LoadBalancedTransport.php +++ b/lib/swiftmailer/lib/classes/Swift/Transport/LoadBalancedTransport.php @@ -11,9 +11,7 @@ /** * Redundantly and rotationally uses several Transports when sending. * - * @package Swift - * @subpackage Transport - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_Transport_LoadBalancedTransport implements Swift_Transport { @@ -32,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() { } @@ -59,6 +62,16 @@ class Swift_Transport_LoadBalancedTransport implements Swift_Transport 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. * @@ -102,15 +115,16 @@ class Swift_Transport_LoadBalancedTransport implements Swift_Transport { $maxTransports = count($this->_transports); $sent = 0; + $this->_lastUsedTransport = null; for ($i = 0; $i < $maxTransports - && $transport = $this->_getNextTransport(); ++$i) - { + && $transport = $this->_getNextTransport(); ++$i) { try { if (!$transport->isStarted()) { $transport->start(); } if ($sent = $transport->send($message, $failedRecipients)) { + $this->_lastUsedTransport = $transport; break; } } catch (Swift_TransportException $e) { @@ -139,8 +153,6 @@ class Swift_Transport_LoadBalancedTransport implements Swift_Transport } } - // -- Protected methods - /** * Rotates the transport list around and returns the first instance. * diff --git a/lib/swiftmailer/lib/classes/Swift/Transport/MailInvoker.php b/lib/swiftmailer/lib/classes/Swift/Transport/MailInvoker.php index 9103f7943..77489cedc 100644 --- a/lib/swiftmailer/lib/classes/Swift/Transport/MailInvoker.php +++ b/lib/swiftmailer/lib/classes/Swift/Transport/MailInvoker.php @@ -11,8 +11,6 @@ /** * This interface intercepts calls to the mail() function. * - * @package Swift - * @subpackage Transport * @author Chris Corbyn */ interface Swift_Transport_MailInvoker diff --git a/lib/swiftmailer/lib/classes/Swift/Transport/MailTransport.php b/lib/swiftmailer/lib/classes/Swift/Transport/MailTransport.php index ec90a1bfe..48ef4a702 100644 --- a/lib/swiftmailer/lib/classes/Swift/Transport/MailTransport.php +++ b/lib/swiftmailer/lib/classes/Swift/Transport/MailTransport.php @@ -19,9 +19,9 @@ * due to limitations of PHP's internal mail() function. You'll get an * all-or-nothing result from sending. * - * @package Swift - * @subpackage Transport - * @author Chris Corbyn + * @author Chris Corbyn + * + * @deprecated since 5.4.5 (to be removed in 6.0) */ class Swift_Transport_MailTransport implements Swift_Transport { @@ -42,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; } @@ -75,7 +77,7 @@ class Swift_Transport_MailTransport implements Swift_Transport * * @param string $params * - * @return Swift_Transport_MailTransport + * @return $this */ public function setExtraParams($params) { @@ -127,6 +129,9 @@ class Swift_Transport_MailTransport implements Swift_Transport $toHeader = $message->getHeaders()->get('To'); $subjectHeader = $message->getHeaders()->get('Subject'); + if (0 === $count) { + $this->_throwException(new Swift_TransportException('Cannot send message without a recipient')); + } $to = $toHeader ? $toHeader->getFieldBody() : ''; $subject = $subjectHeader ? $subjectHeader->getFieldBody() : ''; @@ -137,18 +142,18 @@ class Swift_Transport_MailTransport implements Swift_Transport $message->getHeaders()->remove('Subject'); $messageStr = $message->toString(); - if ($toHeader) - { - $message->getHeaders()->set($toHeader); - } + + if ($toHeader) { + $message->getHeaders()->set($toHeader); + } $message->getHeaders()->set($subjectHeader); // Separate headers from body if (false !== $endHeaders = strpos($messageStr, "\r\n\r\n")) { - $headers = substr($messageStr, 0, $endHeaders) . "\r\n"; //Keep last EOL + $headers = substr($messageStr, 0, $endHeaders)."\r\n"; //Keep last EOL $body = substr($messageStr, $endHeaders + 4); } else { - $headers = $messageStr . "\r\n"; + $headers = $messageStr."\r\n"; $body = ''; } @@ -157,16 +162,18 @@ class Swift_Transport_MailTransport implements Swift_Transport 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); + $to = str_replace("\r\n", PHP_EOL, $to); } 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); + $to = str_replace("\r\n.", "\r\n..", $to); } - 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); @@ -204,7 +211,18 @@ class Swift_Transport_MailTransport implements Swift_Transport $this->_eventDispatcher->bindEventListener($plugin); } - // -- Private methods + /** Throw a TransportException, first sending it to any listeners */ + protected function _throwException(Swift_TransportException $e) + { + if ($evt = $this->_eventDispatcher->createTransportExceptionEvent($this, $e)) { + $this->_eventDispatcher->dispatchEvent($evt, 'exceptionThrown'); + if (!$evt->bubbleCancelled()) { + throw $e; + } + } else { + throw $e; + } + } /** Determine the best-use reverse path for this message */ private function _getReversePath(Swift_Mime_Message $message) @@ -225,4 +243,55 @@ class Swift_Transport_MailTransport implements Swift_Transport 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/lib/swiftmailer/lib/classes/Swift/Transport/NullTransport.php b/lib/swiftmailer/lib/classes/Swift/Transport/NullTransport.php index fcfd9218d..ad20e0e53 100644 --- a/lib/swiftmailer/lib/classes/Swift/Transport/NullTransport.php +++ b/lib/swiftmailer/lib/classes/Swift/Transport/NullTransport.php @@ -11,8 +11,7 @@ /** * Pretends messages have been sent, but just ignores them. * - * @package Swift - * @author Fabien Potencier + * @author Fabien Potencier */ class Swift_Transport_NullTransport implements Swift_Transport { @@ -57,7 +56,7 @@ class Swift_Transport_NullTransport implements Swift_Transport * @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/lib/swiftmailer/lib/classes/Swift/Transport/SendmailTransport.php b/lib/swiftmailer/lib/classes/Swift/Transport/SendmailTransport.php index 9ce748017..6430d5f6b 100644 --- a/lib/swiftmailer/lib/classes/Swift/Transport/SendmailTransport.php +++ b/lib/swiftmailer/lib/classes/Swift/Transport/SendmailTransport.php @@ -15,9 +15,7 @@ * It is advised to use -bs mode since error reporting with -t mode is not * possible. * - * @package Swift - * @subpackage Transport - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_Transport_SendmailTransport extends Swift_Transport_AbstractSmtpTransport { @@ -30,7 +28,7 @@ class Swift_Transport_SendmailTransport extends Swift_Transport_AbstractSmtpTran 'timeout' => 30, 'blocking' => 1, 'command' => '/usr/sbin/sendmail -bs', - 'type' => Swift_Transport_IoBuffer::TYPE_PROCESS + 'type' => Swift_Transport_IoBuffer::TYPE_PROCESS, ); /** @@ -66,7 +64,7 @@ class Swift_Transport_SendmailTransport extends Swift_Transport_AbstractSmtpTran * * @param string $command * - * @return Swift_Transport_SendmailTransport + * @return $this */ public function setCommand($command) { @@ -104,6 +102,7 @@ class Swift_Transport_SendmailTransport extends Swift_Transport_AbstractSmtpTran $failedRecipients = (array) $failedRecipients; $command = $this->getCommand(); $buffer = $this->getBuffer(); + $count = 0; if (false !== strpos($command, ' -t')) { if ($evt = $this->_eventDispatcher->createSendEvent($this, $message)) { @@ -114,7 +113,7 @@ class Swift_Transport_SendmailTransport extends Swift_Transport_AbstractSmtpTran } if (false === strpos($command, ' -f')) { - $command .= ' -f' . escapeshellarg($this->_getReversePath($message)); + $command .= ' -f'.escapeshellarg($this->_getReversePath($message)); } $buffer->initialize(array_merge($this->_params, array('command' => $command))); @@ -122,7 +121,7 @@ class Swift_Transport_SendmailTransport extends Swift_Transport_AbstractSmtpTran if (false === strpos($command, ' -i') && false === strpos($command, ' -oi')) { $buffer->setWriteTranslations(array("\r\n" => "\n", "\n." => "\n..")); } else { - $buffer->setWriteTranslations(array("\r\n"=>"\n")); + $buffer->setWriteTranslations(array("\r\n" => "\n")); } $count = count((array) $message->getTo()) @@ -145,7 +144,7 @@ class Swift_Transport_SendmailTransport extends Swift_Transport_AbstractSmtpTran $count = parent::send($message, $failedRecipients); } else { $this->_throwException(new Swift_TransportException( - 'Unsupported sendmail command flags [' . $command . ']. ' . + 'Unsupported sendmail command flags ['.$command.']. '. 'Must be one of "-bs" or "-t" but can include additional flags.' )); } @@ -153,8 +152,6 @@ class Swift_Transport_SendmailTransport extends Swift_Transport_AbstractSmtpTran return $count; } - // -- Protected methods - /** Get the params to initialize the buffer */ protected function _getBufferParams() { diff --git a/lib/swiftmailer/lib/classes/Swift/Transport/SimpleMailInvoker.php b/lib/swiftmailer/lib/classes/Swift/Transport/SimpleMailInvoker.php index 0bf6c160a..4cab66bd6 100644 --- a/lib/swiftmailer/lib/classes/Swift/Transport/SimpleMailInvoker.php +++ b/lib/swiftmailer/lib/classes/Swift/Transport/SimpleMailInvoker.php @@ -11,8 +11,6 @@ /** * This is the implementation class for {@link Swift_Transport_MailInvoker}. * - * @package Swift - * @subpackage Transport * @author Chris Corbyn */ class Swift_Transport_SimpleMailInvoker implements Swift_Transport_MailInvoker @@ -34,8 +32,8 @@ class Swift_Transport_SimpleMailInvoker implements Swift_Transport_MailInvoker { 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/lib/swiftmailer/lib/classes/Swift/Transport/SmtpAgent.php b/lib/swiftmailer/lib/classes/Swift/Transport/SmtpAgent.php index fcbf5e981..90e913f8e 100644 --- a/lib/swiftmailer/lib/classes/Swift/Transport/SmtpAgent.php +++ b/lib/swiftmailer/lib/classes/Swift/Transport/SmtpAgent.php @@ -11,9 +11,7 @@ /** * Wraps an IoBuffer to send/receive SMTP commands/responses. * - * @package Swift - * @subpackage Transport - * @author Chris Corbyn + * @author Chris Corbyn */ interface Swift_Transport_SmtpAgent { diff --git a/lib/swiftmailer/lib/classes/Swift/Transport/SpoolTransport.php b/lib/swiftmailer/lib/classes/Swift/Transport/SpoolTransport.php index 0fafed72c..e4b87f347 100644 --- a/lib/swiftmailer/lib/classes/Swift/Transport/SpoolTransport.php +++ b/lib/swiftmailer/lib/classes/Swift/Transport/SpoolTransport.php @@ -11,8 +11,7 @@ /** * Stores Messages in a queue. * - * @package Swift - * @author Fabien Potencier + * @author Fabien Potencier */ class Swift_Transport_SpoolTransport implements Swift_Transport { @@ -36,7 +35,7 @@ class Swift_Transport_SpoolTransport implements Swift_Transport * * @param Swift_Spool $spool * - * @return Swift_Transport_SpoolTransport + * @return $this */ public function setSpool(Swift_Spool $spool) { @@ -85,7 +84,7 @@ class Swift_Transport_SpoolTransport implements Swift_Transport * @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) { @@ -99,7 +98,7 @@ class Swift_Transport_SpoolTransport implements Swift_Transport $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/lib/swiftmailer/lib/classes/Swift/Transport/StreamBuffer.php b/lib/swiftmailer/lib/classes/Swift/Transport/StreamBuffer.php index f11e344e6..9f2fff4bf 100644 --- a/lib/swiftmailer/lib/classes/Swift/Transport/StreamBuffer.php +++ b/lib/swiftmailer/lib/classes/Swift/Transport/StreamBuffer.php @@ -11,9 +11,7 @@ /** * A generic IoBuffer implementation supporting remote sockets and local processes. * - * @package Swift - * @subpackage Transport - * @author Chris Corbyn + * @author Chris Corbyn */ class Swift_Transport_StreamBuffer extends Swift_ByteStream_AbstractFilterableInputStream implements Swift_Transport_IoBuffer { @@ -86,7 +84,6 @@ class Swift_Transport_StreamBuffer extends Swift_ByteStream_AbstractFilterableIn if ($this->_stream) { stream_set_blocking($this->_stream, 1); } - } } $this->_params[$param] = $value; @@ -153,22 +150,22 @@ class Swift_Transport_StreamBuffer extends Swift_ByteStream_AbstractFilterableIn * 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) { if (isset($this->_out) && !feof($this->_out)) { $line = fgets($this->_out); - if (strlen($line)==0) { + if (strlen($line) == 0) { $metas = stream_get_meta_data($this->_out); if ($metas['timed_out']) { throw new Swift_IoException( - 'Connection to ' . - $this->_getReadConnectionDescription() . + 'Connection to '. + $this->_getReadConnectionDescription(). ' Timed Out' ); } @@ -185,22 +182,22 @@ class Swift_Transport_StreamBuffer extends Swift_ByteStream_AbstractFilterableIn * 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) { if (isset($this->_out) && !feof($this->_out)) { $ret = fread($this->_out, $length); - if (strlen($ret)==0) { + if (strlen($ret) == 0) { $metas = stream_get_meta_data($this->_out); if ($metas['timed_out']) { throw new Swift_IoException( - 'Connection to ' . - $this->_getReadConnectionDescription() . + 'Connection to '. + $this->_getReadConnectionDescription(). ' Timed Out' ); } @@ -215,8 +212,6 @@ class Swift_Transport_StreamBuffer extends Swift_ByteStream_AbstractFilterableIn { } - // -- Protected methods - /** Flush the stream contents */ protected function _flush() { @@ -247,8 +242,6 @@ class Swift_Transport_StreamBuffer extends Swift_ByteStream_AbstractFilterableIn } } - // -- Private methods - /** * Establishes a connection to a remote server. */ @@ -256,7 +249,7 @@ class Swift_Transport_StreamBuffer extends Swift_ByteStream_AbstractFilterableIn { $host = $this->_params['host']; if (!empty($this->_params['protocol'])) { - $host = $this->_params['protocol'] . '://' . $host; + $host = $this->_params['protocol'].'://'.$host; } $timeout = 15; if (!empty($this->_params['timeout'])) { @@ -264,13 +257,17 @@ class Swift_Transport_StreamBuffer extends Swift_ByteStream_AbstractFilterableIn } $options = array(); if (!empty($this->_params['sourceIp'])) { - $options['socket']['bindto']=$this->_params['sourceIp'].':0'; + $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'] . - ' [' . $errstr . ' #' . $errno . ']' + 'Connection could not be established with host '.$this->_params['host']. + ' ['.$errstr.' #'.$errno.']' ); } if (!empty($this->_params['blocking'])) { @@ -279,8 +276,8 @@ class Swift_Transport_StreamBuffer extends Swift_ByteStream_AbstractFilterableIn 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; } /** @@ -292,17 +289,18 @@ class Swift_Transport_StreamBuffer extends Swift_ByteStream_AbstractFilterableIn $descriptorSpec = array( 0 => array('pipe', 'r'), 1 => array('pipe', 'w'), - 2 => array('pipe', 'w') + 2 => array('pipe', 'w'), ); + $pipes = array(); $this->_stream = proc_open($command, $descriptorSpec, $pipes); stream_set_blocking($pipes[2], 0); if ($err = stream_get_contents($pipes[2])) { throw new Swift_TransportException( - 'Process could not be started [' . $err . ']' + '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() @@ -316,9 +314,9 @@ class Swift_Transport_StreamBuffer extends Swift_ByteStream_AbstractFilterableIn default: $host = $this->_params['host']; if (!empty($this->_params['protocol'])) { - $host = $this->_params['protocol'] . '://' . $host; + $host = $this->_params['protocol'].'://'.$host; } - $host.=':'.$this->_params['port']; + $host .= ':'.$this->_params['port']; return $host; break; diff --git a/lib/swiftmailer/lib/classes/Swift/TransportException.php b/lib/swiftmailer/lib/classes/Swift/TransportException.php index 48e41d16d..4ae2412e6 100644 --- a/lib/swiftmailer/lib/classes/Swift/TransportException.php +++ b/lib/swiftmailer/lib/classes/Swift/TransportException.php @@ -11,19 +11,19 @@ /** * TransportException thrown when an error occurs in the Transport subsystem. * - * @package Swift - * @subpackage Transport - * @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/lib/swiftmailer/lib/classes/Swift/Validate.php b/lib/swiftmailer/lib/classes/Swift/Validate.php index b6906c0b6..e16c212c4 100644 --- a/lib/swiftmailer/lib/classes/Swift/Validate.php +++ b/lib/swiftmailer/lib/classes/Swift/Validate.php @@ -1,4 +1,5 @@ */ class Swift_Validate { /** - * Grammar Object + * Grammar Object. * * @var Swift_Mime_Grammar */ @@ -30,13 +30,13 @@ class Swift_Validate */ public static function email($email) { - if (self::$grammar===null) { + if (self::$grammar === null) { self::$grammar = Swift_DependencyContainer::getInstance() ->lookup('mime.grammar'); } return (bool) preg_match( - '/^' . self::$grammar->getDefinition('addr-spec') . '$/D', + '/^'.self::$grammar->getDefinition('addr-spec').'$/D', $email ); } diff --git a/lib/swiftmailer/lib/dependency_maps/mime_deps.php b/lib/swiftmailer/lib/dependency_maps/mime_deps.php index a13472e9b..d575e4f2d 100644 --- a/lib/swiftmailer/lib/dependency_maps/mime_deps.php +++ b/lib/swiftmailer/lib/dependency_maps/mime_deps.php @@ -1,6 +1,6 @@ register('properties.charset') @@ -16,7 +16,7 @@ Swift_DependencyContainer::getInstance() 'mime.qpcontentencoder', 'cache', 'mime.grammar', - 'properties.charset' + 'properties.charset', )) ->register('mime.part') @@ -26,7 +26,7 @@ Swift_DependencyContainer::getInstance() 'mime.qpcontentencoder', 'cache', 'mime.grammar', - 'properties.charset' + 'properties.charset', )) ->register('mime.attachment') @@ -35,7 +35,7 @@ Swift_DependencyContainer::getInstance() 'mime.headerset', 'mime.base64contentencoder', 'cache', - 'mime.grammar' + 'mime.grammar', )) ->addConstructorValue($swift_mime_types) @@ -45,7 +45,7 @@ Swift_DependencyContainer::getInstance() 'mime.headerset', 'mime.base64contentencoder', 'cache', - 'mime.grammar' + 'mime.grammar', )) ->addConstructorValue($swift_mime_types) @@ -55,7 +55,7 @@ Swift_DependencyContainer::getInstance() 'mime.qpheaderencoder', 'mime.rfc2231encoder', 'mime.grammar', - 'properties.charset' + 'properties.charset', )) ->register('mime.headerset') @@ -117,7 +117,7 @@ Swift_DependencyContainer::getInstance() // As of PHP 5.4.7, the quoted_printable_encode() function behaves correctly. // see https://github.com/php/php-src/commit/18bb426587d62f93c54c40bf8535eb8416603629 ->register('mime.qpcontentencoder') - ->asAliasOf(version_compare(phpversion(), '5.4.7', '>=') ? 'mime.qpcontentencoderproxy' : 'mime.safeqpcontentencoder') + ->asAliasOf(PHP_VERSION_ID >= 50407 ? 'mime.qpcontentencoderproxy' : 'mime.safeqpcontentencoder') ; unset($swift_mime_types); diff --git a/lib/swiftmailer/lib/dependency_maps/transport_deps.php b/lib/swiftmailer/lib/dependency_maps/transport_deps.php index 56ca0590f..77e432cfa 100644 --- a/lib/swiftmailer/lib/dependency_maps/transport_deps.php +++ b/lib/swiftmailer/lib/dependency_maps/transport_deps.php @@ -6,14 +6,14 @@ Swift_DependencyContainer::getInstance() ->withDependencies(array( 'transport.buffer', array('transport.authhandler'), - 'transport.eventdispatcher' + 'transport.eventdispatcher', )) ->register('transport.sendmail') ->asNewInstanceOf('Swift_Transport_SendmailTransport') ->withDependencies(array( 'transport.buffer', - 'transport.eventdispatcher' + 'transport.eventdispatcher', )) ->register('transport.mail') @@ -50,7 +50,7 @@ Swift_DependencyContainer::getInstance() 'transport.plainauth', 'transport.ntlmauth', 'transport.xoauth2auth', - ) + ), )) ->register('transport.crammd5auth') @@ -61,7 +61,7 @@ Swift_DependencyContainer::getInstance() ->register('transport.plainauth') ->asNewInstanceOf('Swift_Transport_Esmtp_Auth_PlainAuthenticator') - + ->register('transport.xoauth2auth') ->asNewInstanceOf('Swift_Transport_Esmtp_Auth_XOAuth2Authenticator') diff --git a/lib/swiftmailer/lib/mime_types.php b/lib/swiftmailer/lib/mime_types.php index 964c34986..b42c1cc1a 100644 --- a/lib/swiftmailer/lib/mime_types.php +++ b/lib/swiftmailer/lib/mime_types.php @@ -7,7 +7,7 @@ * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. * - * autogenerated using http://svn.apache.org/repos/asf/httpd/httpd/trunk/docs/conf/mime.types + * autogenerated using https://svn.apache.org/repos/asf/httpd/httpd/trunk/docs/conf/mime.types * and https://raw.github.com/minad/mimemagic/master/script/freedesktop.org.xml */ @@ -1003,5 +1003,5 @@ $swift_mime_types = array( 'zir' => 'application/vnd.zul', 'zirz' => 'application/vnd.zul', 'zmm' => 'application/vnd.handheld-entertainment+xml', - '123' => 'application/vnd.lotus-1-2-3' -); \ No newline at end of file + '123' => 'application/vnd.lotus-1-2-3', +); diff --git a/lib/swiftmailer/lib/preferences.php b/lib/swiftmailer/lib/preferences.php index 422394370..0b430e67d 100644 --- a/lib/swiftmailer/lib/preferences.php +++ b/lib/swiftmailer/lib/preferences.php @@ -14,22 +14,12 @@ $preferences->setCharset('utf-8'); // Without these lines the default caching mechanism is "array" but this uses a lot of memory. // If possible, use a disk cache to enable attaching large attachments etc. // You can override the default temporary directory by setting the TMPDIR environment variable. - -// The @ operator in front of is_writable calls is to avoid PHP warnings -// when using open_basedir -$tmp = getenv('TMPDIR'); -if ($tmp && @is_writable($tmp)) { - $preferences - ->setTempDir($tmp) - ->setCacheType('disk'); -} elseif (function_exists('sys_get_temp_dir') && @is_writable(sys_get_temp_dir())) { - $preferences - ->setTempDir(sys_get_temp_dir()) - ->setCacheType('disk'); +if (@is_writable($tmpDir = sys_get_temp_dir())) { + $preferences->setTempDir($tmpDir)->setCacheType('disk'); } // this should only be done when Swiftmailer won't use the native QP content encoder // see mime_deps.php -if (version_compare(phpversion(), '5.4.7', '<')) { +if (PHP_VERSION_ID < 50407) { $preferences->setQPDotEscape(false); } diff --git a/lib/swiftmailer/lib/swift_init.php b/lib/swiftmailer/lib/swift_init.php index 5c80b05c1..ff7196344 100644 --- a/lib/swiftmailer/lib/swift_init.php +++ b/lib/swiftmailer/lib/swift_init.php @@ -19,10 +19,10 @@ if (defined('SWIFT_INIT_LOADED')) { 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/lib/swiftmailer/lib/swift_required.php b/lib/swiftmailer/lib/swift_required.php index d64d26ed6..03a72ceae 100644 --- a/lib/swiftmailer/lib/swift_required.php +++ b/lib/swiftmailer/lib/swift_required.php @@ -17,12 +17,12 @@ if (class_exists('Swift', false)) { } // 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/lib/swiftmailer/lib/swift_required_pear.php b/lib/swiftmailer/lib/swift_required_pear.php index 05acc3237..2b5181a93 100644 --- a/lib/swiftmailer/lib/swift_required_pear.php +++ b/lib/swiftmailer/lib/swift_required_pear.php @@ -17,12 +17,12 @@ if (class_exists('Swift', false)) { } // 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'; } }