mirror of
https://gitlab.com/TheGamecraft/c-cms.git
synced 2026-04-24 03:49:10 -04:00
ALPHA 3.0.2
This commit is contained in:
9
vendor/swiftmailer/swiftmailer/.php_cs.dist
vendored
9
vendor/swiftmailer/swiftmailer/.php_cs.dist
vendored
@@ -1,15 +1,16 @@
|
||||
<?php
|
||||
|
||||
return PhpCsFixer\Config::create()
|
||||
->setRules(array(
|
||||
->setRules([
|
||||
'@Symfony' => true,
|
||||
'@Symfony:risky' => true,
|
||||
'array_syntax' => array('syntax' => 'long'),
|
||||
'array_syntax' => ['syntax' => 'short'],
|
||||
'no_unreachable_default_argument_value' => false,
|
||||
'braces' => array('allow_single_line_closure' => true),
|
||||
'braces' => ['allow_single_line_closure' => true],
|
||||
'heredoc_to_nowdoc' => false,
|
||||
'phpdoc_annotation_without_dot' => false,
|
||||
))
|
||||
'ternary_to_null_coalescing' => true,
|
||||
])
|
||||
->setRiskyAllowed(true)
|
||||
->setFinder(PhpCsFixer\Finder::create()->in(__DIR__))
|
||||
;
|
||||
|
||||
1
vendor/swiftmailer/swiftmailer/.travis.yml
vendored
1
vendor/swiftmailer/swiftmailer/.travis.yml
vendored
@@ -17,6 +17,7 @@ matrix:
|
||||
include:
|
||||
- php: 7.0
|
||||
- php: 7.1
|
||||
- php: 7.2
|
||||
fast_finish: true
|
||||
|
||||
cache:
|
||||
|
||||
21
vendor/swiftmailer/swiftmailer/CHANGES
vendored
21
vendor/swiftmailer/swiftmailer/CHANGES
vendored
@@ -1,6 +1,23 @@
|
||||
Changelog
|
||||
=========
|
||||
|
||||
6.1.1 (2018-07-04)
|
||||
------------------
|
||||
|
||||
* removed hard dependency on an IDN encoder
|
||||
|
||||
6.1.0 (2018-07-02)
|
||||
------------------
|
||||
|
||||
* added address encoder exceptions during send
|
||||
* added support for bubbling up authenticator error messages
|
||||
* added support for non-ASCII email addresses
|
||||
* introduced new dependencies: transport.smtphandlers and transport.authhandlers
|
||||
* deprecated Swift_Signers_OpenDKIMSigner; use Swift_Signers_DKIMSigner instead
|
||||
* added support for SMTP pipelining
|
||||
* added Swift_Transport_Esmtp_EightBitMimeHandler
|
||||
* fixed startTLS only allowed tls1.0, now allowed: tls1.0, tls1.1, tls1.2
|
||||
|
||||
6.0.2 (2017-09-30)
|
||||
------------------
|
||||
|
||||
@@ -28,10 +45,10 @@ Changelog
|
||||
* bumped minimum version to PHP 7.0
|
||||
* removed Swift_Validate and replaced by egulias/email-validator
|
||||
|
||||
5.4.9 (2017-XX-XX)
|
||||
5.4.9 (2018-01-23)
|
||||
------------------
|
||||
|
||||
* n/a
|
||||
* no changes, last version of the 5.x series
|
||||
|
||||
5.4.8 (2017-05-01)
|
||||
------------------
|
||||
|
||||
2
vendor/swiftmailer/swiftmailer/LICENSE
vendored
2
vendor/swiftmailer/swiftmailer/LICENSE
vendored
@@ -1,4 +1,4 @@
|
||||
Copyright (c) 2013-2016 Fabien Potencier
|
||||
Copyright (c) 2013-2018 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
|
||||
|
||||
8
vendor/swiftmailer/swiftmailer/composer.json
vendored
8
vendor/swiftmailer/swiftmailer/composer.json
vendored
@@ -3,7 +3,7 @@
|
||||
"type": "library",
|
||||
"description": "Swiftmailer, free feature-rich PHP mailer",
|
||||
"keywords": ["mail","mailer","email"],
|
||||
"homepage": "http://swiftmailer.symfony.com",
|
||||
"homepage": "https://swiftmailer.symfony.com",
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
{
|
||||
@@ -22,6 +22,10 @@
|
||||
"mockery/mockery": "~0.9.1",
|
||||
"symfony/phpunit-bridge": "~3.3@dev"
|
||||
},
|
||||
"suggest": {
|
||||
"ext-intl": "Needed to support internationalized email addresses",
|
||||
"true/punycode": "Needed to support internationalized email addresses, if ext-intl is not installed"
|
||||
},
|
||||
"autoload": {
|
||||
"files": ["lib/swift_required.php"]
|
||||
},
|
||||
@@ -30,7 +34,7 @@
|
||||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "6.0-dev"
|
||||
"dev-master": "6.1-dev"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
14
vendor/swiftmailer/swiftmailer/doc/headers.rst
vendored
14
vendor/swiftmailer/swiftmailer/doc/headers.rst
vendored
@@ -383,6 +383,19 @@ following::
|
||||
|
||||
*/
|
||||
|
||||
Internationalized domains are automatically converted to IDN encoding::
|
||||
|
||||
$to = $message->getHeaders()->get('To');
|
||||
$to->setAddresses('joe@ëxämple.org');
|
||||
|
||||
echo $to->toString();
|
||||
|
||||
/*
|
||||
|
||||
To: joe@xn--xmple-gra1c.org
|
||||
|
||||
*/
|
||||
|
||||
ID Headers
|
||||
~~~~~~~~~~
|
||||
|
||||
@@ -439,7 +452,6 @@ You add a new path header to a HeaderSet by calling the HeaderSet's
|
||||
$headers = $message->getHeaders();
|
||||
$headers->addPathHeader('Your-Header-Name', 'person@example.org');
|
||||
|
||||
|
||||
Changing the value of an existing path header is done by calling its
|
||||
``setAddress()`` method::
|
||||
|
||||
|
||||
52
vendor/swiftmailer/swiftmailer/doc/messages.rst
vendored
52
vendor/swiftmailer/swiftmailer/doc/messages.rst
vendored
@@ -223,11 +223,9 @@ the same filename as the one you attached::
|
||||
// Attach it to the message
|
||||
$message->attach($attachment);
|
||||
|
||||
|
||||
// The two statements above could be written in one line instead
|
||||
$message->attach(Swift_Attachment::fromPath('/path/to/image.jpg'));
|
||||
|
||||
|
||||
// You can attach files from a URL if allow_url_fopen is on in php.ini
|
||||
$message->attach(Swift_Attachment::fromPath('http://site.tld/logo.png'));
|
||||
|
||||
@@ -245,7 +243,6 @@ the email will rename the file to something else::
|
||||
$attachment = Swift_Attachment::fromPath('/path/to/image.jpg')
|
||||
->setFilename('cool.jpg');
|
||||
|
||||
|
||||
// Because there's a fluid interface, you can do this in one statement
|
||||
$message->attach(
|
||||
Swift_Attachment::fromPath('/path/to/image.jpg')->setFilename('cool.jpg')
|
||||
@@ -631,6 +628,26 @@ the address::
|
||||
$message->addBcc('person1@example.org');
|
||||
$message->addBcc('person2@example.org', 'Person 2 Name');
|
||||
|
||||
.. sidebar:: Internationalized Email Addresses
|
||||
|
||||
Traditionally only ASCII characters have been allowed in email addresses.
|
||||
With the introduction of internationalized domain names (IDNs), non-ASCII
|
||||
characters may appear in the domain name. By default, Swiftmailer encodes
|
||||
such domain names in Punycode (e.g. xn--xample-ova.invalid). This is
|
||||
compatible with all mail servers.
|
||||
|
||||
RFC 6531 introduced an SMTP extension, SMTPUTF8, that allows non-ASCII
|
||||
characters in email addresses on both sides of the @ sign. To send to such
|
||||
addresses, your outbound SMTP server must support the SMTPUTF8 extension.
|
||||
You should use the ``Swift_AddressEncoder_Utf8AddressEncoder`` address
|
||||
encoder and enable the ``Swift_Transport_Esmtp_SmtpUtf8Handler`` SMTP
|
||||
extension handler::
|
||||
|
||||
$smtpUtf8 = new Swift_Transport_Esmtp_SmtpUtf8Handler();
|
||||
$transport->setExtensionHandlers([$smtpUtf8]);
|
||||
$utf8Encoder = new Swift_AddressEncoder_Utf8AddressEncoder();
|
||||
$transport->setAddressEncoder($utf8Encoder);
|
||||
|
||||
Specifying Sender Details
|
||||
-------------------------
|
||||
|
||||
@@ -789,7 +806,7 @@ Using both signing and encrypting is also possible::
|
||||
The used encryption cipher can be set as the second parameter of
|
||||
setEncryptCertificate()
|
||||
|
||||
See http://php.net/manual/openssl.ciphers for a list of supported ciphers.
|
||||
See https://secure.php.net/manual/openssl.ciphers for a list of supported ciphers.
|
||||
|
||||
By default the message is first signed and then encrypted, this can be changed
|
||||
by adding::
|
||||
@@ -822,7 +839,7 @@ sent to this address.
|
||||
Setting the Character Set
|
||||
-------------------------
|
||||
|
||||
The character set of the message (and it's MIME parts) is set with the
|
||||
The character set of the message (and its MIME parts) is set with the
|
||||
``setCharset()`` method. You can also change the global default of UTF-8 by
|
||||
working with the ``Swift_Preferences`` class.
|
||||
|
||||
@@ -860,6 +877,31 @@ To set the character set of your Message:
|
||||
// Approach 4: Specify the charset for each part added
|
||||
$message->addPart('My part', 'text/plain', 'iso-8859-2');
|
||||
|
||||
Setting the Encoding
|
||||
--------------------
|
||||
|
||||
The body of each MIME part needs to be encoded. Binary attachments are encoded
|
||||
in base64 using the ``Swift_Mime_ContentEncoder_Base64ContentEncoder``. Text
|
||||
parts are traditionally encoded in quoted-printable using
|
||||
``Swift_Mime_ContentEncoder_QpContentEncoder`` or
|
||||
``Swift_Mime_ContentEncoder_NativeQpContentEncoder``.
|
||||
|
||||
The encoder of the message or MIME part is set with the ``setEncoder()`` method.
|
||||
|
||||
Quoted-printable is the safe choice, because it converts 8-bit text as 7-bit.
|
||||
Most modern SMTP servers support 8-bit text. This is advertised via the 8BITMIME
|
||||
SMTP extension. If your outbound SMTP server supports this SMTP extension, and
|
||||
it supports downgrading the message (e.g converting to quoted-printable on the
|
||||
fly) when delivering to a downstream server that does not support the extension,
|
||||
you may wish to use ``Swift_Mime_ContentEncoder_PlainContentEncoder`` in
|
||||
``8bit`` mode instead. This has the advantage that the source data is slightly
|
||||
more readable and compact, especially for non-Western languages.
|
||||
|
||||
$eightBitMime = new Swift_Transport_Esmtp_EightBitMimeHandler();
|
||||
$transport->setExtensionHandlers([$eightBitMime]);
|
||||
$plainEncoder = new Swift_Mime_ContentEncoder_PlainContentEncoder('8bit');
|
||||
$message->setEncoder($plainEncoder);
|
||||
|
||||
Setting the Line Length
|
||||
-----------------------
|
||||
|
||||
|
||||
15
vendor/swiftmailer/swiftmailer/doc/sending.rst
vendored
15
vendor/swiftmailer/swiftmailer/doc/sending.rst
vendored
@@ -149,6 +149,10 @@ settings.
|
||||
"ssl" are present in your PHP installation by using the PHP function
|
||||
``stream_get_transports()``.
|
||||
|
||||
.. note::
|
||||
If you are using Mailcatcher_, make sure you do not set the encryption
|
||||
for the ``Swift_SmtpTransport``, since Mailcatcher does not support encryption.
|
||||
|
||||
SMTP with a Username and Password
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
@@ -343,10 +347,11 @@ Mailer will throw a ``Swift_RfcComplianceException``.
|
||||
|
||||
If you add recipients automatically based on a data source that may contain
|
||||
invalid email addresses, you can prevent possible exceptions by validating the
|
||||
addresses using ``Swift_Validate::email($email)`` and only adding addresses
|
||||
that validate. Another way would be to wrap your ``setTo()``, ``setCc()`` and
|
||||
``setBcc()`` calls in a try-catch block and handle the
|
||||
``Swift_RfcComplianceException`` in the catch block.
|
||||
addresses using ``Egulias\EmailValidator\EmailValidator`` (a dependency that is
|
||||
installed with Swift Mailer) and only adding addresses that validate. Another
|
||||
way would be to wrap your ``setTo()``, ``setCc()`` and ``setBcc()`` calls in a
|
||||
try-catch block and handle the ``Swift_RfcComplianceException`` in the catch
|
||||
block.
|
||||
|
||||
Handling invalid addresses properly is especially important when sending emails
|
||||
in large batches since a single invalid address might cause an unhandled
|
||||
@@ -444,3 +449,5 @@ added to the array provided by-reference.
|
||||
empty array and then failures will be added to that array. If the variable
|
||||
already exists it will be type-cast to an array and failures will be added
|
||||
to it.
|
||||
|
||||
.. _Mailcatcher: https://mailcatcher.me/
|
||||
|
||||
@@ -11,15 +11,14 @@
|
||||
/**
|
||||
* General utility class in Swift Mailer, not to be instantiated.
|
||||
*
|
||||
*
|
||||
* @author Chris Corbyn
|
||||
*/
|
||||
abstract class Swift
|
||||
{
|
||||
const VERSION = '6.0.2';
|
||||
const VERSION = '6.1.1';
|
||||
|
||||
public static $initialized = false;
|
||||
public static $inits = array();
|
||||
public static $inits = [];
|
||||
|
||||
/**
|
||||
* Registers an initializer callable that will be called the first time
|
||||
@@ -74,6 +73,6 @@ abstract class Swift
|
||||
if (null !== $callable) {
|
||||
self::$inits[] = $callable;
|
||||
}
|
||||
spl_autoload_register(array('Swift', 'autoload'));
|
||||
spl_autoload_register(['Swift', 'autoload']);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ class Swift_Attachment extends Swift_Mime_Attachment
|
||||
public function __construct($data = null, $filename = null, $contentType = null)
|
||||
{
|
||||
call_user_func_array(
|
||||
array($this, 'Swift_Mime_Attachment::__construct'),
|
||||
[$this, 'Swift_Mime_Attachment::__construct'],
|
||||
Swift_DependencyContainer::getInstance()
|
||||
->createDependenciesFor('mime.attachment')
|
||||
);
|
||||
|
||||
@@ -25,7 +25,7 @@ abstract class Swift_ByteStream_AbstractFilterableInputStream implements Swift_I
|
||||
*
|
||||
* @var Swift_StreamFilter[]
|
||||
*/
|
||||
private $filters = array();
|
||||
private $filters = [];
|
||||
|
||||
/**
|
||||
* A buffer for writing.
|
||||
@@ -37,7 +37,7 @@ abstract class Swift_ByteStream_AbstractFilterableInputStream implements Swift_I
|
||||
*
|
||||
* @var Swift_InputByteStream[]
|
||||
*/
|
||||
private $mirrors = array();
|
||||
private $mirrors = [];
|
||||
|
||||
/**
|
||||
* Commit the given bytes to the storage medium immediately.
|
||||
@@ -54,8 +54,7 @@ abstract class Swift_ByteStream_AbstractFilterableInputStream implements Swift_I
|
||||
/**
|
||||
* Add a StreamFilter to this InputByteStream.
|
||||
*
|
||||
* @param Swift_StreamFilter $filter
|
||||
* @param string $key
|
||||
* @param string $key
|
||||
*/
|
||||
public function addFilter(Swift_StreamFilter $filter, $key)
|
||||
{
|
||||
@@ -110,8 +109,6 @@ abstract class Swift_ByteStream_AbstractFilterableInputStream implements Swift_I
|
||||
*
|
||||
* The stream acts as an observer, receiving all data that is written.
|
||||
* All {@link write()} and {@link flushBuffers()} operations will be mirrored.
|
||||
*
|
||||
* @param Swift_InputByteStream $is
|
||||
*/
|
||||
public function bind(Swift_InputByteStream $is)
|
||||
{
|
||||
@@ -124,14 +121,12 @@ abstract class Swift_ByteStream_AbstractFilterableInputStream implements Swift_I
|
||||
* If $is is not bound, no errors will be raised.
|
||||
* If the stream currently has any buffered data it will be written to $is
|
||||
* before unbinding occurs.
|
||||
*
|
||||
* @param Swift_InputByteStream $is
|
||||
*/
|
||||
public function unbind(Swift_InputByteStream $is)
|
||||
{
|
||||
foreach ($this->mirrors as $k => $stream) {
|
||||
if ($is === $stream) {
|
||||
if ($this->writeBuffer !== '') {
|
||||
if ('' !== $this->writeBuffer) {
|
||||
$stream->write($this->writeBuffer);
|
||||
}
|
||||
unset($this->mirrors[$k]);
|
||||
@@ -147,7 +142,7 @@ abstract class Swift_ByteStream_AbstractFilterableInputStream implements Swift_I
|
||||
*/
|
||||
public function flushBuffers()
|
||||
{
|
||||
if ($this->writeBuffer !== '') {
|
||||
if ('' !== $this->writeBuffer) {
|
||||
$this->doWrite($this->writeBuffer);
|
||||
}
|
||||
$this->flush();
|
||||
|
||||
@@ -20,7 +20,7 @@ class Swift_ByteStream_ArrayByteStream implements Swift_InputByteStream, Swift_O
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
private $array = array();
|
||||
private $array = [];
|
||||
|
||||
/**
|
||||
* The size of the stack.
|
||||
@@ -41,7 +41,7 @@ class Swift_ByteStream_ArrayByteStream implements Swift_InputByteStream, Swift_O
|
||||
*
|
||||
* @var Swift_InputByteStream[]
|
||||
*/
|
||||
private $mirrors = array();
|
||||
private $mirrors = [];
|
||||
|
||||
/**
|
||||
* Create a new ArrayByteStream.
|
||||
@@ -58,7 +58,7 @@ class Swift_ByteStream_ArrayByteStream implements Swift_InputByteStream, Swift_O
|
||||
} elseif (is_string($stack)) {
|
||||
$this->write($stack);
|
||||
} else {
|
||||
$this->array = array();
|
||||
$this->array = [];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -121,8 +121,6 @@ class Swift_ByteStream_ArrayByteStream implements Swift_InputByteStream, Swift_O
|
||||
*
|
||||
* The stream acts as an observer, receiving all data that is written.
|
||||
* All {@link write()} and {@link flushBuffers()} operations will be mirrored.
|
||||
*
|
||||
* @param Swift_InputByteStream $is
|
||||
*/
|
||||
public function bind(Swift_InputByteStream $is)
|
||||
{
|
||||
@@ -135,8 +133,6 @@ class Swift_ByteStream_ArrayByteStream implements Swift_InputByteStream, Swift_O
|
||||
* If $is is not bound, no errors will be raised.
|
||||
* If the stream currently has any buffered data it will be written to $is
|
||||
* before unbinding occurs.
|
||||
*
|
||||
* @param Swift_InputByteStream $is
|
||||
*/
|
||||
public function unbind(Swift_InputByteStream $is)
|
||||
{
|
||||
@@ -172,7 +168,7 @@ class Swift_ByteStream_ArrayByteStream implements Swift_InputByteStream, Swift_O
|
||||
public function flushBuffers()
|
||||
{
|
||||
$this->offset = 0;
|
||||
$this->array = array();
|
||||
$this->array = [];
|
||||
$this->arraySize = 0;
|
||||
|
||||
foreach ($this->mirrors as $stream) {
|
||||
|
||||
@@ -81,7 +81,7 @@ class Swift_ByteStream_FileByteStream extends Swift_ByteStream_AbstractFilterabl
|
||||
|
||||
// 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)) {
|
||||
if ('' === $bytes && feof($fp)) {
|
||||
$this->resetReadHandle();
|
||||
|
||||
return false;
|
||||
@@ -131,7 +131,7 @@ class Swift_ByteStream_FileByteStream extends Swift_ByteStream_AbstractFilterabl
|
||||
throw new Swift_IoException('Unable to open file for reading ['.$this->path.']');
|
||||
}
|
||||
$this->reader = $pointer;
|
||||
if ($this->offset != 0) {
|
||||
if (0 != $this->offset) {
|
||||
$this->getReadStreamSeekableStatus();
|
||||
$this->seekReadStreamToPosition($this->offset);
|
||||
}
|
||||
@@ -173,10 +173,10 @@ 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 (null === $this->seekable) {
|
||||
$this->getReadStreamSeekableStatus();
|
||||
}
|
||||
if ($this->seekable === false) {
|
||||
if (false === $this->seekable) {
|
||||
$currentPos = ftell($this->reader);
|
||||
if ($currentPos < $offset) {
|
||||
$toDiscard = $offset - $currentPos;
|
||||
|
||||
@@ -17,7 +17,7 @@ class Swift_ByteStream_TemporaryFileByteStream extends Swift_ByteStream_FileByte
|
||||
{
|
||||
$filePath = tempnam(sys_get_temp_dir(), 'FileByteStream');
|
||||
|
||||
if ($filePath === false) {
|
||||
if (false === $filePath) {
|
||||
throw new Swift_IoException('Failed to retrieve temporary file name.');
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ class Swift_ByteStream_TemporaryFileByteStream extends Swift_ByteStream_FileByte
|
||||
|
||||
public function getContent()
|
||||
{
|
||||
if (($content = file_get_contents($this->getPath())) === false) {
|
||||
if (false === ($content = file_get_contents($this->getPath()))) {
|
||||
throw new Swift_IoException('Failed to get temporary file content.');
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
class Swift_CharacterReader_Utf8Reader implements Swift_CharacterReader
|
||||
{
|
||||
/** Pre-computed for optimization */
|
||||
private static $length_map = array(
|
||||
private static $length_map = [
|
||||
// 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
|
||||
@@ -35,9 +35,9 @@ class Swift_CharacterReader_Utf8Reader implements Swift_CharacterReader
|
||||
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(
|
||||
private static $s_length_map = [
|
||||
"\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,
|
||||
@@ -70,7 +70,7 @@ class Swift_CharacterReader_Utf8Reader implements Swift_CharacterReader
|
||||
"\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.
|
||||
@@ -85,7 +85,7 @@ class Swift_CharacterReader_Utf8Reader implements Swift_CharacterReader
|
||||
public function getCharPositions($string, $startOffset, &$currentMap, &$ignoredChars)
|
||||
{
|
||||
if (!isset($currentMap['i']) || !isset($currentMap['p'])) {
|
||||
$currentMap['p'] = $currentMap['i'] = array();
|
||||
$currentMap['p'] = $currentMap['i'] = [];
|
||||
}
|
||||
|
||||
$strlen = strlen($string);
|
||||
@@ -95,12 +95,12 @@ class Swift_CharacterReader_Utf8Reader implements Swift_CharacterReader
|
||||
for ($i = 0; $i < $strlen; ++$i) {
|
||||
$char = $string[$i];
|
||||
$size = self::$s_length_map[$char];
|
||||
if ($size == 0) {
|
||||
if (0 == $size) {
|
||||
/* char is invalid, we must wait for a resync */
|
||||
$invalid = true;
|
||||
continue;
|
||||
} else {
|
||||
if ($invalid == true) {
|
||||
if (true === $invalid) {
|
||||
/* We mark the chars as invalid and start a new char */
|
||||
$currentMap['p'][$charPos + $foundChars] = $startOffset + $i;
|
||||
$currentMap['i'][$charPos + $foundChars] = true;
|
||||
|
||||
@@ -20,14 +20,14 @@ class Swift_CharacterReaderFactory_SimpleCharacterReaderFactory implements Swift
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private static $map = array();
|
||||
private static $map = [];
|
||||
|
||||
/**
|
||||
* Factories which have already been loaded.
|
||||
*
|
||||
* @var Swift_CharacterReaderFactory[]
|
||||
*/
|
||||
private static $loaded = array();
|
||||
private static $loaded = [];
|
||||
|
||||
/**
|
||||
* Creates a new CharacterReaderFactory.
|
||||
@@ -50,26 +50,26 @@ class Swift_CharacterReaderFactory_SimpleCharacterReaderFactory implements Swift
|
||||
|
||||
$prefix = 'Swift_CharacterReader_';
|
||||
|
||||
$singleByte = array(
|
||||
$singleByte = [
|
||||
'class' => $prefix.'GenericFixedWidthReader',
|
||||
'constructor' => array(1),
|
||||
);
|
||||
'constructor' => [1],
|
||||
];
|
||||
|
||||
$doubleByte = array(
|
||||
$doubleByte = [
|
||||
'class' => $prefix.'GenericFixedWidthReader',
|
||||
'constructor' => array(2),
|
||||
);
|
||||
'constructor' => [2],
|
||||
];
|
||||
|
||||
$fourBytes = array(
|
||||
$fourBytes = [
|
||||
'class' => $prefix.'GenericFixedWidthReader',
|
||||
'constructor' => array(4),
|
||||
);
|
||||
'constructor' => [4],
|
||||
];
|
||||
|
||||
// Utf-8
|
||||
self::$map['utf-?8'] = array(
|
||||
self::$map['utf-?8'] = [
|
||||
'class' => $prefix.'Utf8Reader',
|
||||
'constructor' => array(),
|
||||
);
|
||||
'constructor' => [],
|
||||
];
|
||||
|
||||
//7-8 bit charsets
|
||||
self::$map['(us-)?ascii'] = $singleByte;
|
||||
|
||||
@@ -31,10 +31,10 @@ class Swift_CharacterStream_ArrayCharacterStream implements Swift_CharacterStrea
|
||||
private $charset;
|
||||
|
||||
/** Array of characters */
|
||||
private $array = array();
|
||||
private $array = [];
|
||||
|
||||
/** Size of the array of character */
|
||||
private $array_size = array();
|
||||
private $array_size = [];
|
||||
|
||||
/** The current character offset in the stream */
|
||||
private $offset = 0;
|
||||
@@ -65,8 +65,6 @@ class Swift_CharacterStream_ArrayCharacterStream implements Swift_CharacterStrea
|
||||
|
||||
/**
|
||||
* Set the CharacterReaderFactory for multi charset support.
|
||||
*
|
||||
* @param Swift_CharacterReaderFactory $factory
|
||||
*/
|
||||
public function setCharacterReaderFactory(Swift_CharacterReaderFactory $factory)
|
||||
{
|
||||
@@ -87,7 +85,7 @@ class Swift_CharacterStream_ArrayCharacterStream implements Swift_CharacterStrea
|
||||
|
||||
$startLength = $this->charReader->getInitialByteSize();
|
||||
while (false !== $bytes = $os->read($startLength)) {
|
||||
$c = array();
|
||||
$c = [];
|
||||
for ($i = 0, $len = strlen($bytes); $i < $len; ++$i) {
|
||||
$c[] = self::$byteMap[$bytes[$i]];
|
||||
}
|
||||
@@ -132,7 +130,7 @@ class Swift_CharacterStream_ArrayCharacterStream implements Swift_CharacterStrea
|
||||
}
|
||||
|
||||
// Don't use array slice
|
||||
$arrays = array();
|
||||
$arrays = [];
|
||||
$end = $length + $this->offset;
|
||||
for ($i = $this->offset; $i < $end; ++$i) {
|
||||
if (!isset($this->array[$i])) {
|
||||
@@ -162,7 +160,7 @@ class Swift_CharacterStream_ArrayCharacterStream implements Swift_CharacterStrea
|
||||
if ($this->offset == $this->array_size) {
|
||||
return false;
|
||||
}
|
||||
$arrays = array();
|
||||
$arrays = [];
|
||||
$end = $length + $this->offset;
|
||||
for ($i = $this->offset; $i < $end; ++$i) {
|
||||
if (!isset($this->array[$i])) {
|
||||
@@ -194,12 +192,12 @@ class Swift_CharacterStream_ArrayCharacterStream implements Swift_CharacterStrea
|
||||
unset($chars);
|
||||
fseek($fp, 0, SEEK_SET);
|
||||
|
||||
$buffer = array(0);
|
||||
$buffer = [0];
|
||||
$buf_pos = 1;
|
||||
$buf_len = 1;
|
||||
$has_datas = true;
|
||||
do {
|
||||
$bytes = array();
|
||||
$bytes = [];
|
||||
// Buffer Filing
|
||||
if ($buf_len - $buf_pos < $startLength) {
|
||||
$buf = array_splice($buffer, $buf_pos);
|
||||
@@ -262,14 +260,14 @@ class Swift_CharacterStream_ArrayCharacterStream implements Swift_CharacterStrea
|
||||
public function flushContents()
|
||||
{
|
||||
$this->offset = 0;
|
||||
$this->array = array();
|
||||
$this->array = [];
|
||||
$this->array_size = 0;
|
||||
}
|
||||
|
||||
private function reloadBuffer($fp, $len)
|
||||
{
|
||||
if (!feof($fp) && ($bytes = fread($fp, $len)) !== false) {
|
||||
$buf = array();
|
||||
if (!feof($fp) && false !== ($bytes = fread($fp, $len))) {
|
||||
$buf = [];
|
||||
for ($i = 0, $len = strlen($bytes); $i < $len; ++$i) {
|
||||
$buf[] = self::$byteMap[$bytes[$i]];
|
||||
}
|
||||
@@ -283,7 +281,7 @@ class Swift_CharacterStream_ArrayCharacterStream implements Swift_CharacterStrea
|
||||
private static function initializeMaps()
|
||||
{
|
||||
if (!isset(self::$charMap)) {
|
||||
self::$charMap = array();
|
||||
self::$charMap = [];
|
||||
for ($byte = 0; $byte < 256; ++$byte) {
|
||||
self::$charMap[$byte] = chr($byte);
|
||||
}
|
||||
|
||||
@@ -81,8 +81,7 @@ class Swift_CharacterStream_NgCharacterStream implements Swift_CharacterStream
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param Swift_CharacterReaderFactory $factory
|
||||
* @param string $charset
|
||||
* @param string $charset
|
||||
*/
|
||||
public function __construct(Swift_CharacterReaderFactory $factory, $charset)
|
||||
{
|
||||
@@ -106,8 +105,6 @@ class Swift_CharacterStream_NgCharacterStream implements Swift_CharacterStream
|
||||
|
||||
/**
|
||||
* Set the CharacterReaderFactory for multi charset support.
|
||||
*
|
||||
* @param Swift_CharacterReaderFactory $factory
|
||||
*/
|
||||
public function setCharacterReaderFactory(Swift_CharacterReaderFactory $factory)
|
||||
{
|
||||
@@ -128,8 +125,6 @@ class Swift_CharacterStream_NgCharacterStream implements Swift_CharacterStream
|
||||
|
||||
/**
|
||||
* @see Swift_CharacterStream::importByteStream()
|
||||
*
|
||||
* @param Swift_OutputByteStream $os
|
||||
*/
|
||||
public function importByteStream(Swift_OutputByteStream $os)
|
||||
{
|
||||
@@ -220,7 +215,7 @@ class Swift_CharacterStream_NgCharacterStream implements Swift_CharacterStream
|
||||
public function readBytes($length)
|
||||
{
|
||||
$read = $this->read($length);
|
||||
if ($read !== false) {
|
||||
if (false !== $read) {
|
||||
$ret = array_map('ord', str_split($read, 1));
|
||||
|
||||
return $ret;
|
||||
@@ -252,13 +247,13 @@ class Swift_CharacterStream_NgCharacterStream implements Swift_CharacterStream
|
||||
if (!isset($this->charReader)) {
|
||||
$this->charReader = $this->charReaderFactory->getReaderFor(
|
||||
$this->charset);
|
||||
$this->map = array();
|
||||
$this->map = [];
|
||||
$this->mapType = $this->charReader->getMapType();
|
||||
}
|
||||
$ignored = '';
|
||||
$this->datas .= $chars;
|
||||
$this->charCount += $this->charReader->getCharPositions(substr($this->datas, $this->datasSize), $this->datasSize, $this->map, $ignored);
|
||||
if ($ignored !== false) {
|
||||
if (false !== $ignored) {
|
||||
$this->datasSize = strlen($this->datas) - strlen($ignored);
|
||||
} else {
|
||||
$this->datasSize = strlen($this->datas);
|
||||
|
||||
@@ -16,22 +16,25 @@
|
||||
class Swift_DependencyContainer
|
||||
{
|
||||
/** Constant for literal value types */
|
||||
const TYPE_VALUE = 0x0001;
|
||||
const TYPE_VALUE = 0x00001;
|
||||
|
||||
/** Constant for new instance types */
|
||||
const TYPE_INSTANCE = 0x0010;
|
||||
const TYPE_INSTANCE = 0x00010;
|
||||
|
||||
/** Constant for shared instance types */
|
||||
const TYPE_SHARED = 0x0100;
|
||||
const TYPE_SHARED = 0x00100;
|
||||
|
||||
/** Constant for aliases */
|
||||
const TYPE_ALIAS = 0x1000;
|
||||
const TYPE_ALIAS = 0x01000;
|
||||
|
||||
/** Constant for arrays */
|
||||
const TYPE_ARRAY = 0x10000;
|
||||
|
||||
/** Singleton instance */
|
||||
private static $instance = null;
|
||||
|
||||
/** The data container */
|
||||
private $store = array();
|
||||
private $store = [];
|
||||
|
||||
/** The current endpoint in the data container */
|
||||
private $endPoint;
|
||||
@@ -112,6 +115,8 @@ class Swift_DependencyContainer
|
||||
return $this->createNewInstance($itemName);
|
||||
case self::TYPE_SHARED:
|
||||
return $this->createSharedInstance($itemName);
|
||||
case self::TYPE_ARRAY:
|
||||
return $this->createDependenciesFor($itemName);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -124,7 +129,7 @@ class Swift_DependencyContainer
|
||||
*/
|
||||
public function createDependenciesFor($itemName)
|
||||
{
|
||||
$args = array();
|
||||
$args = [];
|
||||
if (isset($this->store[$itemName]['args'])) {
|
||||
$args = $this->resolveArgs($this->store[$itemName]['args']);
|
||||
}
|
||||
@@ -147,7 +152,7 @@ class Swift_DependencyContainer
|
||||
*/
|
||||
public function register($itemName)
|
||||
{
|
||||
$this->store[$itemName] = array();
|
||||
$this->store[$itemName] = [];
|
||||
$this->endPoint = &$this->store[$itemName];
|
||||
|
||||
return $this;
|
||||
@@ -227,6 +232,21 @@ class Swift_DependencyContainer
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify the previously registered item as array of dependencies.
|
||||
*
|
||||
* {@link register()} must be called before this will work.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function asArray()
|
||||
{
|
||||
$endPoint = &$this->getEndPoint();
|
||||
$endPoint['lookupType'] = self::TYPE_ARRAY;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify a list of injected dependencies for the previously registered item.
|
||||
*
|
||||
@@ -234,14 +254,12 @@ class Swift_DependencyContainer
|
||||
*
|
||||
* @see addConstructorValue(), addConstructorLookup()
|
||||
*
|
||||
* @param array $lookups
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function withDependencies(array $lookups)
|
||||
{
|
||||
$endPoint = &$this->getEndPoint();
|
||||
$endPoint['args'] = array();
|
||||
$endPoint['args'] = [];
|
||||
foreach ($lookups as $lookup) {
|
||||
$this->addConstructorLookup($lookup);
|
||||
}
|
||||
@@ -263,9 +281,9 @@ class Swift_DependencyContainer
|
||||
{
|
||||
$endPoint = &$this->getEndPoint();
|
||||
if (!isset($endPoint['args'])) {
|
||||
$endPoint['args'] = array();
|
||||
$endPoint['args'] = [];
|
||||
}
|
||||
$endPoint['args'][] = array('type' => 'value', 'item' => $value);
|
||||
$endPoint['args'][] = ['type' => 'value', 'item' => $value];
|
||||
|
||||
return $this;
|
||||
}
|
||||
@@ -284,9 +302,9 @@ class Swift_DependencyContainer
|
||||
{
|
||||
$endPoint = &$this->getEndPoint();
|
||||
if (!isset($this->endPoint['args'])) {
|
||||
$endPoint['args'] = array();
|
||||
$endPoint['args'] = [];
|
||||
}
|
||||
$endPoint['args'][] = array('type' => 'lookup', 'item' => $lookup);
|
||||
$endPoint['args'][] = ['type' => 'lookup', 'item' => $lookup];
|
||||
|
||||
return $this;
|
||||
}
|
||||
@@ -341,7 +359,7 @@ class Swift_DependencyContainer
|
||||
/** Get an argument list with dependencies resolved */
|
||||
private function resolveArgs(array $args)
|
||||
{
|
||||
$resolved = array();
|
||||
$resolved = [];
|
||||
foreach ($args as $argDefinition) {
|
||||
switch ($argDefinition['type']) {
|
||||
case 'lookup':
|
||||
@@ -360,7 +378,7 @@ class Swift_DependencyContainer
|
||||
private function lookupRecursive($item)
|
||||
{
|
||||
if (is_array($item)) {
|
||||
$collection = array();
|
||||
$collection = [];
|
||||
foreach ($item as $k => $v) {
|
||||
$collection[$k] = $this->lookupRecursive($v);
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ class Swift_EmbeddedFile extends Swift_Mime_EmbeddedFile
|
||||
public function __construct($data = null, $filename = null, $contentType = null)
|
||||
{
|
||||
call_user_func_array(
|
||||
array($this, 'Swift_Mime_EmbeddedFile::__construct'),
|
||||
[$this, 'Swift_Mime_EmbeddedFile::__construct'],
|
||||
Swift_DependencyContainer::getInstance()
|
||||
->createDependenciesFor('mime.embeddedfile')
|
||||
);
|
||||
|
||||
@@ -36,7 +36,7 @@ class Swift_Encoder_QpEncoder implements Swift_Encoder
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
protected static $qpMap = array(
|
||||
protected static $qpMap = [
|
||||
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',
|
||||
@@ -89,16 +89,16 @@ class Swift_Encoder_QpEncoder implements Swift_Encoder
|
||||
245 => '=F5', 246 => '=F6', 247 => '=F7', 248 => '=F8', 249 => '=F9',
|
||||
250 => '=FA', 251 => '=FB', 252 => '=FC', 253 => '=FD', 254 => '=FE',
|
||||
255 => '=FF',
|
||||
);
|
||||
];
|
||||
|
||||
protected static $safeMapShare = array();
|
||||
protected static $safeMapShare = [];
|
||||
|
||||
/**
|
||||
* A map of non-encoded ascii characters.
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
protected $safeMap = array();
|
||||
protected $safeMap = [];
|
||||
|
||||
/**
|
||||
* Creates a new QpEncoder for the given CharacterStream.
|
||||
@@ -120,7 +120,7 @@ class Swift_Encoder_QpEncoder implements Swift_Encoder
|
||||
|
||||
public function __sleep()
|
||||
{
|
||||
return array('charStream', 'filter');
|
||||
return ['charStream', 'filter'];
|
||||
}
|
||||
|
||||
public function __wakeup()
|
||||
@@ -141,7 +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) {
|
||||
[0x09, 0x20], range(0x21, 0x3C), range(0x3E, 0x7E)) as $byte) {
|
||||
$this->safeMap[$byte] = chr($byte);
|
||||
}
|
||||
}
|
||||
@@ -153,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
|
||||
*/
|
||||
@@ -167,7 +167,7 @@ class Swift_Encoder_QpEncoder implements Swift_Encoder
|
||||
|
||||
$thisLineLength = $maxLineLength - $firstLineOffset;
|
||||
|
||||
$lines = array();
|
||||
$lines = [];
|
||||
$lNo = 0;
|
||||
$lines[$lNo] = '';
|
||||
$currentLine = &$lines[$lNo++];
|
||||
@@ -200,7 +200,7 @@ class Swift_Encoder_QpEncoder implements Swift_Encoder
|
||||
$enc = $this->encodeByteSequence($bytes, $size);
|
||||
|
||||
$i = strpos($enc, '=0D=0A');
|
||||
$newLineLength = $lineLen + ($i === false ? $size : $i);
|
||||
$newLineLength = $lineLen + (false === $i ? $size : $i);
|
||||
|
||||
if ($currentLine && $newLineLength >= $thisLineLength) {
|
||||
$lines[$lNo] = '';
|
||||
@@ -211,7 +211,7 @@ class Swift_Encoder_QpEncoder implements Swift_Encoder
|
||||
|
||||
$currentLine .= $enc;
|
||||
|
||||
if ($i === false) {
|
||||
if (false === $i) {
|
||||
$lineLen += $size;
|
||||
} else {
|
||||
// 6 is the length of '=0D=0A'.
|
||||
@@ -278,8 +278,8 @@ class Swift_Encoder_QpEncoder implements Swift_Encoder
|
||||
*/
|
||||
protected function standardize($string)
|
||||
{
|
||||
$string = str_replace(array("\t=0D=0A", ' =0D=0A', '=0D=0A'),
|
||||
array("=09\r\n", "=20\r\n", "\r\n"), $string
|
||||
$string = str_replace(["\t=0D=0A", ' =0D=0A', '=0D=0A'],
|
||||
["=09\r\n", "=20\r\n", "\r\n"], $string
|
||||
);
|
||||
switch ($end = ord(substr($string, -1))) {
|
||||
case 0x09:
|
||||
|
||||
@@ -24,8 +24,6 @@ class Swift_Encoder_Rfc2231Encoder implements Swift_Encoder
|
||||
|
||||
/**
|
||||
* Creates a new Rfc2231Encoder using the given character stream instance.
|
||||
*
|
||||
* @param Swift_CharacterStream
|
||||
*/
|
||||
public function __construct(Swift_CharacterStream $charStream)
|
||||
{
|
||||
@@ -44,7 +42,7 @@ class Swift_Encoder_Rfc2231Encoder implements Swift_Encoder
|
||||
*/
|
||||
public function encodeString($string, $firstLineOffset = 0, $maxLineLength = 0)
|
||||
{
|
||||
$lines = array();
|
||||
$lines = [];
|
||||
$lineCount = 0;
|
||||
$lines[] = '';
|
||||
$currentLine = &$lines[$lineCount++];
|
||||
|
||||
@@ -27,16 +27,15 @@ class Swift_Events_CommandEvent extends Swift_Events_EventObject
|
||||
*
|
||||
* @var int[]
|
||||
*/
|
||||
private $successCodes = array();
|
||||
private $successCodes = [];
|
||||
|
||||
/**
|
||||
* Create a new CommandEvent for $source with $command.
|
||||
*
|
||||
* @param Swift_Transport $source
|
||||
* @param string $command
|
||||
* @param array $successCodes
|
||||
* @param string $command
|
||||
* @param array $successCodes
|
||||
*/
|
||||
public function __construct(Swift_Transport $source, $command, $successCodes = array())
|
||||
public function __construct(Swift_Transport $source, $command, $successCodes = [])
|
||||
{
|
||||
parent::__construct($source);
|
||||
$this->command = $command;
|
||||
|
||||
@@ -34,7 +34,7 @@ interface Swift_Events_EventDispatcher
|
||||
*
|
||||
* @return Swift_Events_CommandEvent
|
||||
*/
|
||||
public function createCommandEvent(Swift_Transport $source, $command, $successCodes = array());
|
||||
public function createCommandEvent(Swift_Transport $source, $command, $successCodes = []);
|
||||
|
||||
/**
|
||||
* Create a new ResponseEvent for $source and $response.
|
||||
|
||||
@@ -43,8 +43,6 @@ class Swift_Events_EventObject implements Swift_Events_Event
|
||||
|
||||
/**
|
||||
* Prevent this Event from bubbling any further up the stack.
|
||||
*
|
||||
* @param bool $cancel, optional
|
||||
*/
|
||||
public function cancelBubble($cancel = true)
|
||||
{
|
||||
|
||||
@@ -32,9 +32,8 @@ class Swift_Events_ResponseEvent extends Swift_Events_EventObject
|
||||
/**
|
||||
* Create a new ResponseEvent for $source and $response.
|
||||
*
|
||||
* @param Swift_Transport $source
|
||||
* @param string $response
|
||||
* @param bool $valid
|
||||
* @param string $response
|
||||
* @param bool $valid
|
||||
*/
|
||||
public function __construct(Swift_Transport $source, $response, $valid = false)
|
||||
{
|
||||
|
||||
@@ -42,7 +42,7 @@ class Swift_Events_SendEvent extends Swift_Events_EventObject
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
private $failedRecipients = array();
|
||||
private $failedRecipients = [];
|
||||
|
||||
/**
|
||||
* The overall result as a bitmask from the class constants.
|
||||
@@ -53,9 +53,6 @@ class Swift_Events_SendEvent extends Swift_Events_EventObject
|
||||
|
||||
/**
|
||||
* Create a new SendEvent for $source and $message.
|
||||
*
|
||||
* @param Swift_Transport $source
|
||||
* @param Swift_Mime_SimpleMessage $message
|
||||
*/
|
||||
public function __construct(Swift_Transport $source, Swift_Mime_SimpleMessage $message)
|
||||
{
|
||||
|
||||
@@ -16,34 +16,31 @@
|
||||
class Swift_Events_SimpleEventDispatcher implements Swift_Events_EventDispatcher
|
||||
{
|
||||
/** A map of event types to their associated listener types */
|
||||
private $eventMap = array();
|
||||
private $eventMap = [];
|
||||
|
||||
/** Event listeners bound to this dispatcher */
|
||||
private $listeners = array();
|
||||
private $listeners = [];
|
||||
|
||||
/** Listeners queued to have an Event bubbled up the stack to them */
|
||||
private $bubbleQueue = array();
|
||||
private $bubbleQueue = [];
|
||||
|
||||
/**
|
||||
* Create a new EventDispatcher.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->eventMap = array(
|
||||
$this->eventMap = [
|
||||
'Swift_Events_CommandEvent' => 'Swift_Events_CommandListener',
|
||||
'Swift_Events_ResponseEvent' => 'Swift_Events_ResponseListener',
|
||||
'Swift_Events_SendEvent' => 'Swift_Events_SendListener',
|
||||
'Swift_Events_TransportChangeEvent' => 'Swift_Events_TransportChangeListener',
|
||||
'Swift_Events_TransportExceptionEvent' => 'Swift_Events_TransportExceptionListener',
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new SendEvent for $source and $message.
|
||||
*
|
||||
* @param Swift_Transport $source
|
||||
* @param Swift_Mime_SimpleMessage
|
||||
*
|
||||
* @return Swift_Events_SendEvent
|
||||
*/
|
||||
public function createSendEvent(Swift_Transport $source, Swift_Mime_SimpleMessage $message)
|
||||
@@ -54,13 +51,12 @@ class Swift_Events_SimpleEventDispatcher implements Swift_Events_EventDispatcher
|
||||
/**
|
||||
* Create a new CommandEvent for $source and $command.
|
||||
*
|
||||
* @param Swift_Transport $source
|
||||
* @param string $command That will be executed
|
||||
* @param array $successCodes That are needed
|
||||
* @param string $command That will be executed
|
||||
* @param array $successCodes That are needed
|
||||
*
|
||||
* @return Swift_Events_CommandEvent
|
||||
*/
|
||||
public function createCommandEvent(Swift_Transport $source, $command, $successCodes = array())
|
||||
public function createCommandEvent(Swift_Transport $source, $command, $successCodes = [])
|
||||
{
|
||||
return new Swift_Events_CommandEvent($source, $command, $successCodes);
|
||||
}
|
||||
@@ -68,9 +64,8 @@ class Swift_Events_SimpleEventDispatcher implements Swift_Events_EventDispatcher
|
||||
/**
|
||||
* Create a new ResponseEvent for $source and $response.
|
||||
*
|
||||
* @param Swift_Transport $source
|
||||
* @param string $response
|
||||
* @param bool $valid If the response is valid
|
||||
* @param string $response
|
||||
* @param bool $valid If the response is valid
|
||||
*
|
||||
* @return Swift_Events_ResponseEvent
|
||||
*/
|
||||
@@ -82,8 +77,6 @@ class Swift_Events_SimpleEventDispatcher implements Swift_Events_EventDispatcher
|
||||
/**
|
||||
* Create a new TransportChangeEvent for $source.
|
||||
*
|
||||
* @param Swift_Transport $source
|
||||
*
|
||||
* @return Swift_Events_TransportChangeEvent
|
||||
*/
|
||||
public function createTransportChangeEvent(Swift_Transport $source)
|
||||
@@ -94,9 +87,6 @@ class Swift_Events_SimpleEventDispatcher implements Swift_Events_EventDispatcher
|
||||
/**
|
||||
* Create a new TransportExceptionEvent for $source.
|
||||
*
|
||||
* @param Swift_Transport $source
|
||||
* @param Swift_TransportException $ex
|
||||
*
|
||||
* @return Swift_Events_TransportExceptionEvent
|
||||
*/
|
||||
public function createTransportExceptionEvent(Swift_Transport $source, Swift_TransportException $ex)
|
||||
@@ -106,8 +96,6 @@ class Swift_Events_SimpleEventDispatcher implements Swift_Events_EventDispatcher
|
||||
|
||||
/**
|
||||
* Bind an event listener to this dispatcher.
|
||||
*
|
||||
* @param Swift_Events_EventListener $listener
|
||||
*/
|
||||
public function bindEventListener(Swift_Events_EventListener $listener)
|
||||
{
|
||||
@@ -123,8 +111,7 @@ class Swift_Events_SimpleEventDispatcher implements Swift_Events_EventDispatcher
|
||||
/**
|
||||
* Dispatch the given Event to all suitable listeners.
|
||||
*
|
||||
* @param Swift_Events_EventObject $evt
|
||||
* @param string $target method
|
||||
* @param string $target method
|
||||
*/
|
||||
public function dispatchEvent(Swift_Events_EventObject $evt, $target)
|
||||
{
|
||||
@@ -135,7 +122,7 @@ class Swift_Events_SimpleEventDispatcher implements Swift_Events_EventDispatcher
|
||||
/** Queue listeners on a stack ready for $evt to be bubbled up it */
|
||||
private function prepareBubbleQueue(Swift_Events_EventObject $evt)
|
||||
{
|
||||
$this->bubbleQueue = array();
|
||||
$this->bubbleQueue = [];
|
||||
$evtClass = get_class($evt);
|
||||
foreach ($this->listeners as $listener) {
|
||||
if (array_key_exists($evtClass, $this->eventMap)
|
||||
|
||||
@@ -24,9 +24,6 @@ class Swift_Events_TransportExceptionEvent extends Swift_Events_EventObject
|
||||
|
||||
/**
|
||||
* Create a new TransportExceptionEvent for $transport.
|
||||
*
|
||||
* @param Swift_Transport $transport
|
||||
* @param Swift_TransportException $ex
|
||||
*/
|
||||
public function __construct(Swift_Transport $transport, Swift_TransportException $ex)
|
||||
{
|
||||
|
||||
@@ -20,10 +20,10 @@ class Swift_FailoverTransport extends Swift_Transport_FailoverTransport
|
||||
*
|
||||
* @param Swift_Transport[] $transports
|
||||
*/
|
||||
public function __construct($transports = array())
|
||||
public function __construct($transports = [])
|
||||
{
|
||||
call_user_func_array(
|
||||
array($this, 'Swift_Transport_FailoverTransport::__construct'),
|
||||
[$this, 'Swift_Transport_FailoverTransport::__construct'],
|
||||
Swift_DependencyContainer::getInstance()
|
||||
->createDependenciesFor('transport.failover')
|
||||
);
|
||||
|
||||
@@ -121,7 +121,7 @@ class Swift_FileSpool extends Swift_ConfigurableSpool
|
||||
foreach (new DirectoryIterator($this->path) as $file) {
|
||||
$file = $file->getRealPath();
|
||||
|
||||
if (substr($file, -16) == '.message.sending') {
|
||||
if ('.message.sending' == substr($file, -16)) {
|
||||
$lockedtime = filectime($file);
|
||||
if ((time() - $lockedtime) > $timeout) {
|
||||
rename($file, substr($file, 0, -8));
|
||||
@@ -145,7 +145,7 @@ class Swift_FileSpool extends Swift_ConfigurableSpool
|
||||
/* Start the transport only if there are queued files to send */
|
||||
if (!$transport->isStarted()) {
|
||||
foreach ($directoryIterator as $file) {
|
||||
if (substr($file->getRealPath(), -8) == '.message') {
|
||||
if ('.message' == substr($file->getRealPath(), -8)) {
|
||||
$transport->start();
|
||||
break;
|
||||
}
|
||||
@@ -158,7 +158,7 @@ class Swift_FileSpool extends Swift_ConfigurableSpool
|
||||
foreach ($directoryIterator as $file) {
|
||||
$file = $file->getRealPath();
|
||||
|
||||
if (substr($file, -8) != '.message') {
|
||||
if ('.message' != substr($file, -8)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ interface Swift_InputByteStream
|
||||
*
|
||||
* @param Swift_InputByteStream $is
|
||||
*/
|
||||
public function bind(Swift_InputByteStream $is);
|
||||
public function bind(self $is);
|
||||
|
||||
/**
|
||||
* Remove an already bound stream.
|
||||
@@ -63,7 +63,7 @@ interface Swift_InputByteStream
|
||||
*
|
||||
* @param Swift_InputByteStream $is
|
||||
*/
|
||||
public function unbind(Swift_InputByteStream $is);
|
||||
public function unbind(self $is);
|
||||
|
||||
/**
|
||||
* Flush the contents of the stream (empty it) and set the internal pointer
|
||||
|
||||
@@ -18,9 +18,8 @@ class Swift_IoException extends Swift_SwiftException
|
||||
/**
|
||||
* Create a new IoException with $message.
|
||||
*
|
||||
* @param string $message
|
||||
* @param int $code
|
||||
* @param Exception $previous
|
||||
* @param string $message
|
||||
* @param int $code
|
||||
*/
|
||||
public function __construct($message, $code = 0, Exception $previous = null)
|
||||
{
|
||||
|
||||
@@ -20,7 +20,7 @@ class Swift_KeyCache_ArrayKeyCache implements Swift_KeyCache
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $contents = array();
|
||||
private $contents = [];
|
||||
|
||||
/**
|
||||
* An InputStream for cloning.
|
||||
@@ -32,8 +32,6 @@ class Swift_KeyCache_ArrayKeyCache implements Swift_KeyCache
|
||||
/**
|
||||
* Create a new ArrayKeyCache with the given $stream for cloning to make
|
||||
* InputByteStreams.
|
||||
*
|
||||
* @param Swift_KeyCache_KeyCacheInputStream $stream
|
||||
*/
|
||||
public function __construct(Swift_KeyCache_KeyCacheInputStream $stream)
|
||||
{
|
||||
@@ -76,10 +74,9 @@ class Swift_KeyCache_ArrayKeyCache implements Swift_KeyCache
|
||||
*
|
||||
* @see MODE_WRITE, MODE_APPEND
|
||||
*
|
||||
* @param string $nsKey
|
||||
* @param string $itemKey
|
||||
* @param Swift_OutputByteStream $os
|
||||
* @param int $mode
|
||||
* @param string $nsKey
|
||||
* @param string $itemKey
|
||||
* @param int $mode
|
||||
*/
|
||||
public function importFromByteStream($nsKey, $itemKey, Swift_OutputByteStream $os, $mode)
|
||||
{
|
||||
@@ -87,6 +84,7 @@ class Swift_KeyCache_ArrayKeyCache implements Swift_KeyCache
|
||||
switch ($mode) {
|
||||
case self::MODE_WRITE:
|
||||
$this->clearKey($nsKey, $itemKey);
|
||||
// no break
|
||||
case self::MODE_APPEND:
|
||||
if (!$this->hasKey($nsKey, $itemKey)) {
|
||||
$this->contents[$nsKey][$itemKey] = '';
|
||||
@@ -108,9 +106,8 @@ class Swift_KeyCache_ArrayKeyCache implements Swift_KeyCache
|
||||
*
|
||||
* NOTE: The stream will always write in append mode.
|
||||
*
|
||||
* @param string $nsKey
|
||||
* @param string $itemKey
|
||||
* @param Swift_InputByteStream $writeThrough
|
||||
* @param string $nsKey
|
||||
* @param string $itemKey
|
||||
*
|
||||
* @return Swift_InputByteStream
|
||||
*/
|
||||
@@ -200,7 +197,7 @@ class Swift_KeyCache_ArrayKeyCache implements Swift_KeyCache
|
||||
private function prepareCache($nsKey)
|
||||
{
|
||||
if (!array_key_exists($nsKey, $this->contents)) {
|
||||
$this->contents[$nsKey] = array();
|
||||
$this->contents[$nsKey] = [];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,14 +43,13 @@ class Swift_KeyCache_DiskKeyCache implements Swift_KeyCache
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $keys = array();
|
||||
private $keys = [];
|
||||
|
||||
/**
|
||||
* Create a new DiskKeyCache with the given $stream for cloning to make
|
||||
* InputByteStreams, and the given $path to save to.
|
||||
*
|
||||
* @param Swift_KeyCache_KeyCacheInputStream $stream
|
||||
* @param string $path to save to
|
||||
* @param string $path to save to
|
||||
*/
|
||||
public function __construct(Swift_KeyCache_KeyCacheInputStream $stream, $path)
|
||||
{
|
||||
@@ -96,10 +95,9 @@ class Swift_KeyCache_DiskKeyCache implements Swift_KeyCache
|
||||
*
|
||||
* @see MODE_WRITE, MODE_APPEND
|
||||
*
|
||||
* @param string $nsKey
|
||||
* @param string $itemKey
|
||||
* @param Swift_OutputByteStream $os
|
||||
* @param int $mode
|
||||
* @param string $nsKey
|
||||
* @param string $itemKey
|
||||
* @param int $mode
|
||||
*
|
||||
* @throws Swift_IoException
|
||||
*/
|
||||
@@ -131,9 +129,8 @@ class Swift_KeyCache_DiskKeyCache implements Swift_KeyCache
|
||||
*
|
||||
* NOTE: The stream will always write in append mode.
|
||||
*
|
||||
* @param string $nsKey
|
||||
* @param string $itemKey
|
||||
* @param Swift_InputByteStream $writeThrough
|
||||
* @param string $nsKey
|
||||
* @param string $itemKey
|
||||
*
|
||||
* @return Swift_InputByteStream
|
||||
*/
|
||||
@@ -250,7 +247,7 @@ class Swift_KeyCache_DiskKeyCache implements Swift_KeyCache
|
||||
if (!mkdir($cacheDir)) {
|
||||
throw new Swift_IoException('Failed to create cache directory '.$cacheDir);
|
||||
}
|
||||
$this->keys[$nsKey] = array();
|
||||
$this->keys[$nsKey] = [];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -34,10 +34,9 @@ class Swift_KeyCache_NullKeyCache implements Swift_KeyCache
|
||||
*
|
||||
* @see MODE_WRITE, MODE_APPEND
|
||||
*
|
||||
* @param string $nsKey
|
||||
* @param string $itemKey
|
||||
* @param Swift_OutputByteStream $os
|
||||
* @param int $mode
|
||||
* @param string $nsKey
|
||||
* @param string $itemKey
|
||||
* @param int $mode
|
||||
*/
|
||||
public function importFromByteStream($nsKey, $itemKey, Swift_OutputByteStream $os, $mode)
|
||||
{
|
||||
@@ -48,9 +47,8 @@ class Swift_KeyCache_NullKeyCache implements Swift_KeyCache
|
||||
*
|
||||
* NOTE: The stream will always write in append mode.
|
||||
*
|
||||
* @param string $nsKey
|
||||
* @param string $itemKey
|
||||
* @param Swift_InputByteStream $writeThrough
|
||||
* @param string $nsKey
|
||||
* @param string $itemKey
|
||||
*
|
||||
* @return Swift_InputByteStream
|
||||
*/
|
||||
|
||||
@@ -29,8 +29,6 @@ class Swift_KeyCache_SimpleKeyCacheInputStream implements Swift_KeyCache_KeyCach
|
||||
|
||||
/**
|
||||
* Set the KeyCache to wrap.
|
||||
*
|
||||
* @param Swift_KeyCache $keyCache
|
||||
*/
|
||||
public function setKeyCache(Swift_KeyCache $keyCache)
|
||||
{
|
||||
@@ -39,8 +37,6 @@ class Swift_KeyCache_SimpleKeyCacheInputStream implements Swift_KeyCache_KeyCach
|
||||
|
||||
/**
|
||||
* Specify a stream to write through for each write().
|
||||
*
|
||||
* @param Swift_InputByteStream $is
|
||||
*/
|
||||
public function setWriteThroughStream(Swift_InputByteStream $is)
|
||||
{
|
||||
|
||||
@@ -20,10 +20,10 @@ class Swift_LoadBalancedTransport extends Swift_Transport_LoadBalancedTransport
|
||||
*
|
||||
* @param array $transports
|
||||
*/
|
||||
public function __construct($transports = array())
|
||||
public function __construct($transports = [])
|
||||
{
|
||||
call_user_func_array(
|
||||
array($this, 'Swift_Transport_LoadBalancedTransport::__construct'),
|
||||
[$this, 'Swift_Transport_LoadBalancedTransport::__construct'],
|
||||
Swift_DependencyContainer::getInstance()
|
||||
->createDependenciesFor('transport.loadbalanced')
|
||||
);
|
||||
|
||||
@@ -20,8 +20,6 @@ class Swift_Mailer
|
||||
|
||||
/**
|
||||
* Create a new Mailer using $transport for delivery.
|
||||
*
|
||||
* @param Swift_Transport $transport
|
||||
*/
|
||||
public function __construct(Swift_Transport $transport)
|
||||
{
|
||||
@@ -54,8 +52,7 @@ class Swift_Mailer
|
||||
* The return value is the number of recipients who were accepted for
|
||||
* delivery.
|
||||
*
|
||||
* @param Swift_Mime_SimpleMessage $message
|
||||
* @param array $failedRecipients An array of failures by-reference
|
||||
* @param array $failedRecipients An array of failures by-reference
|
||||
*
|
||||
* @return int The number of successful recipients. Can be 0 which indicates failure
|
||||
*/
|
||||
@@ -82,8 +79,6 @@ class Swift_Mailer
|
||||
|
||||
/**
|
||||
* Register a plugin using a known unique key (e.g. myPlugin).
|
||||
*
|
||||
* @param Swift_Events_EventListener $plugin
|
||||
*/
|
||||
public function registerPlugin(Swift_Events_EventListener $plugin)
|
||||
{
|
||||
|
||||
@@ -20,12 +20,10 @@ class Swift_Mailer_ArrayRecipientIterator implements Swift_Mailer_RecipientItera
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $recipients = array();
|
||||
private $recipients = [];
|
||||
|
||||
/**
|
||||
* Create a new ArrayRecipientIterator from $recipients.
|
||||
*
|
||||
* @param array $recipients
|
||||
*/
|
||||
public function __construct(array $recipients)
|
||||
{
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
class Swift_MemorySpool implements Swift_Spool
|
||||
{
|
||||
protected $messages = array();
|
||||
protected $messages = [];
|
||||
private $flushRetries = 3;
|
||||
|
||||
/**
|
||||
|
||||
@@ -18,17 +18,17 @@ class Swift_Message extends Swift_Mime_SimpleMessage
|
||||
/**
|
||||
* @var Swift_Signers_HeaderSigner[]
|
||||
*/
|
||||
private $headerSigners = array();
|
||||
private $headerSigners = [];
|
||||
|
||||
/**
|
||||
* @var Swift_Signers_BodySigner[]
|
||||
*/
|
||||
private $bodySigners = array();
|
||||
private $bodySigners = [];
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $savedMessage = array();
|
||||
private $savedMessage = [];
|
||||
|
||||
/**
|
||||
* Create a new Message.
|
||||
@@ -43,7 +43,7 @@ class Swift_Message extends Swift_Mime_SimpleMessage
|
||||
public function __construct($subject = null, $body = null, $contentType = null, $charset = null)
|
||||
{
|
||||
call_user_func_array(
|
||||
array($this, 'Swift_Mime_SimpleMessage::__construct'),
|
||||
[$this, 'Swift_Mime_SimpleMessage::__construct'],
|
||||
Swift_DependencyContainer::getInstance()
|
||||
->createDependenciesFor('mime.message')
|
||||
);
|
||||
@@ -75,9 +75,7 @@ class Swift_Message extends Swift_Mime_SimpleMessage
|
||||
}
|
||||
|
||||
/**
|
||||
* Detach a signature handler from a message.
|
||||
*
|
||||
* @param Swift_Signer $signer
|
||||
* Attach a new signature handler to the message.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
@@ -93,9 +91,7 @@ class Swift_Message extends Swift_Mime_SimpleMessage
|
||||
}
|
||||
|
||||
/**
|
||||
* Attach a new signature handler to the message.
|
||||
*
|
||||
* @param Swift_Signer $signer
|
||||
* Detach a signature handler from a message.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
@@ -122,6 +118,19 @@ class Swift_Message extends Swift_Mime_SimpleMessage
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear all signature handlers attached to the message.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function clearSigners()
|
||||
{
|
||||
$this->headerSigners = [];
|
||||
$this->bodySigners = [];
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get this message as a complete string.
|
||||
*
|
||||
@@ -146,8 +155,6 @@ class Swift_Message extends Swift_Mime_SimpleMessage
|
||||
|
||||
/**
|
||||
* Write this message to a {@link Swift_InputByteStream}.
|
||||
*
|
||||
* @param Swift_InputByteStream $is
|
||||
*/
|
||||
public function toByteStream(Swift_InputByteStream $is)
|
||||
{
|
||||
@@ -202,19 +209,17 @@ class Swift_Message extends Swift_Mime_SimpleMessage
|
||||
*/
|
||||
protected function saveMessage()
|
||||
{
|
||||
$this->savedMessage = array('headers' => array());
|
||||
$this->savedMessage = ['headers' => []];
|
||||
$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']));
|
||||
if (count($this->savedMessage['children']) > 0 && '' != $this->getBody()) {
|
||||
$this->setChildren(array_merge([$this->becomeMimePart()], $this->savedMessage['children']));
|
||||
$this->setBody('');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* save the original headers.
|
||||
*
|
||||
* @param array $altered
|
||||
*/
|
||||
protected function saveHeaders(array $altered)
|
||||
{
|
||||
@@ -252,7 +257,7 @@ class Swift_Message extends Swift_Mime_SimpleMessage
|
||||
$this->setChildren($this->savedMessage['children']);
|
||||
|
||||
$this->restoreHeaders();
|
||||
$this->savedMessage = array();
|
||||
$this->savedMessage = [];
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -16,18 +16,14 @@
|
||||
class Swift_Mime_Attachment extends Swift_Mime_SimpleMimeEntity
|
||||
{
|
||||
/** Recognized MIME types */
|
||||
private $mimeTypes = array();
|
||||
private $mimeTypes = [];
|
||||
|
||||
/**
|
||||
* Create a new Attachment with $headers, $encoder and $cache.
|
||||
*
|
||||
* @param Swift_Mime_SimpleHeaderSet $headers
|
||||
* @param Swift_Mime_ContentEncoder $encoder
|
||||
* @param Swift_KeyCache $cache
|
||||
* @param Swift_IdGenerator $idGenerator
|
||||
* @param array $mimeTypes
|
||||
* @param array $mimeTypes
|
||||
*/
|
||||
public function __construct(Swift_Mime_SimpleHeaderSet $headers, Swift_Mime_ContentEncoder $encoder, Swift_KeyCache $cache, Swift_IdGenerator $idGenerator, $mimeTypes = array())
|
||||
public function __construct(Swift_Mime_SimpleHeaderSet $headers, Swift_Mime_ContentEncoder $encoder, Swift_KeyCache $cache, Swift_IdGenerator $idGenerator, $mimeTypes = [])
|
||||
{
|
||||
parent::__construct($headers, $encoder, $cache, $idGenerator);
|
||||
$this->setDisposition('attachment');
|
||||
@@ -127,8 +123,7 @@ class Swift_Mime_Attachment extends Swift_Mime_SimpleMimeEntity
|
||||
/**
|
||||
* Set the file that this attachment is for.
|
||||
*
|
||||
* @param Swift_FileStream $file
|
||||
* @param string $contentType optional
|
||||
* @param string $contentType optional
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
|
||||
@@ -18,10 +18,7 @@ class Swift_Mime_ContentEncoder_Base64ContentEncoder extends Swift_Encoder_Base6
|
||||
/**
|
||||
* Encode stream $in to stream $out.
|
||||
*
|
||||
* @param Swift_OutputByteStream $os
|
||||
* @param Swift_InputByteStream $is
|
||||
* @param int $firstLineOffset
|
||||
* @param int $maxLineLength, optional, 0 indicates the default of 76 bytes
|
||||
* @param int $firstLineOffset
|
||||
*/
|
||||
public function encodeByteStream(Swift_OutputByteStream $os, Swift_InputByteStream $is, $firstLineOffset = 0, $maxLineLength = 0)
|
||||
{
|
||||
@@ -41,7 +38,7 @@ class Swift_Mime_ContentEncoder_Base64ContentEncoder extends Swift_Encoder_Base6
|
||||
// When the OutputStream is empty, we must flush any remainder bytes.
|
||||
while (true) {
|
||||
$readBytes = $os->read(8192);
|
||||
$atEOF = ($readBytes === false);
|
||||
$atEOF = (false === $readBytes);
|
||||
|
||||
if ($atEOF) {
|
||||
$streamTheseBytes = $base64ReadBufferRemainderBytes;
|
||||
@@ -51,7 +48,7 @@ class Swift_Mime_ContentEncoder_Base64ContentEncoder extends Swift_Encoder_Base6
|
||||
$base64ReadBufferRemainderBytes = null;
|
||||
$bytesLength = strlen($streamTheseBytes);
|
||||
|
||||
if ($bytesLength === 0) { // no data left to encode
|
||||
if (0 === $bytesLength) { // no data left to encode
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -59,7 +56,7 @@ class Swift_Mime_ContentEncoder_Base64ContentEncoder extends Swift_Encoder_Base6
|
||||
// and carry over remainder 1-2 bytes to the next loop iteration
|
||||
if (!$atEOF) {
|
||||
$excessBytes = $bytesLength % 3;
|
||||
if ($excessBytes !== 0) {
|
||||
if (0 !== $excessBytes) {
|
||||
$base64ReadBufferRemainderBytes = substr($streamTheseBytes, -$excessBytes);
|
||||
$streamTheseBytes = substr($streamTheseBytes, 0, $bytesLength - $excessBytes);
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ class Swift_Mime_ContentEncoder_NativeQpContentEncoder implements Swift_Mime_Con
|
||||
*/
|
||||
public function encodeByteStream(Swift_OutputByteStream $os, Swift_InputByteStream $is, $firstLineOffset = 0, $maxLineLength = 0)
|
||||
{
|
||||
if ($this->charset !== 'utf-8') {
|
||||
if ('utf-8' !== $this->charset) {
|
||||
throw new RuntimeException(
|
||||
sprintf('Charset "%s" not supported. NativeQpContentEncoder only supports "utf-8"', $this->charset));
|
||||
}
|
||||
@@ -87,7 +87,7 @@ class Swift_Mime_ContentEncoder_NativeQpContentEncoder implements Swift_Mime_Con
|
||||
*/
|
||||
public function encodeString($string, $firstLineOffset = 0, $maxLineLength = 0)
|
||||
{
|
||||
if ($this->charset !== 'utf-8') {
|
||||
if ('utf-8' !== $this->charset) {
|
||||
throw new RuntimeException(
|
||||
sprintf('Charset "%s" not supported. NativeQpContentEncoder only supports "utf-8"', $this->charset));
|
||||
}
|
||||
@@ -107,9 +107,9 @@ class Swift_Mime_ContentEncoder_NativeQpContentEncoder implements Swift_Mime_Con
|
||||
// transform CR or LF to CRLF
|
||||
$string = preg_replace('~=0D(?!=0A)|(?<!=0D)=0A~', '=0D=0A', $string);
|
||||
// transform =0D=0A to CRLF
|
||||
$string = str_replace(array("\t=0D=0A", ' =0D=0A', '=0D=0A'), array("=09\r\n", "=20\r\n", "\r\n"), $string);
|
||||
$string = str_replace(["\t=0D=0A", ' =0D=0A', '=0D=0A'], ["=09\r\n", "=20\r\n", "\r\n"], $string);
|
||||
|
||||
switch ($end = ord(substr($string, -1))) {
|
||||
switch (ord(substr($string, -1))) {
|
||||
case 0x09:
|
||||
$string = substr_replace($string, '=09', -1);
|
||||
break;
|
||||
|
||||
@@ -11,6 +11,10 @@
|
||||
/**
|
||||
* Handles binary/7/8-bit Transfer Encoding in Swift Mailer.
|
||||
*
|
||||
* When sending 8-bit content over SMTP, you should use
|
||||
* Swift_Transport_Esmtp_EightBitMimeHandler to enable the 8BITMIME SMTP
|
||||
* extension.
|
||||
*
|
||||
* @author Chris Corbyn
|
||||
*/
|
||||
class Swift_Mime_ContentEncoder_PlainContentEncoder implements Swift_Mime_ContentEncoder
|
||||
@@ -62,10 +66,8 @@ class Swift_Mime_ContentEncoder_PlainContentEncoder implements Swift_Mime_Conten
|
||||
/**
|
||||
* Encode stream $in to stream $out.
|
||||
*
|
||||
* @param Swift_OutputByteStream $os
|
||||
* @param Swift_InputByteStream $is
|
||||
* @param int $firstLineOffset ignored
|
||||
* @param int $maxLineLength optional, 0 means no wrapping will occur
|
||||
* @param int $firstLineOffset ignored
|
||||
* @param int $maxLineLength optional, 0 means no wrapping will occur
|
||||
*/
|
||||
public function encodeByteStream(Swift_OutputByteStream $os, Swift_InputByteStream $is, $firstLineOffset = 0, $maxLineLength = 0)
|
||||
{
|
||||
@@ -121,7 +123,7 @@ class Swift_Mime_ContentEncoder_PlainContentEncoder implements Swift_Mime_Conten
|
||||
|
||||
$originalLines = explode($le, $string);
|
||||
|
||||
$lines = array();
|
||||
$lines = [];
|
||||
$lineCount = 0;
|
||||
|
||||
foreach ($originalLines as $originalLine) {
|
||||
@@ -154,8 +156,8 @@ class Swift_Mime_ContentEncoder_PlainContentEncoder implements Swift_Mime_Conten
|
||||
private function canonicalize($string)
|
||||
{
|
||||
return str_replace(
|
||||
array("\r\n", "\r", "\n"),
|
||||
array("\n", "\n", "\r\n"),
|
||||
["\r\n", "\r", "\n"],
|
||||
["\n", "\n", "\r\n"],
|
||||
$string
|
||||
);
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ class Swift_Mime_ContentEncoder_QpContentEncoder extends Swift_Encoder_QpEncoder
|
||||
|
||||
public function __sleep()
|
||||
{
|
||||
return array('charStream', 'filter', 'dotEscape');
|
||||
return ['charStream', 'filter', 'dotEscape'];
|
||||
}
|
||||
|
||||
protected function getSafeMapShareId()
|
||||
@@ -97,7 +97,7 @@ class Swift_Mime_ContentEncoder_QpContentEncoder extends Swift_Encoder_QpEncoder
|
||||
$enc = $this->encodeByteSequence($bytes, $size);
|
||||
|
||||
$i = strpos($enc, '=0D=0A');
|
||||
$newLineLength = $lineLen + ($i === false ? $size : $i);
|
||||
$newLineLength = $lineLen + (false === $i ? $size : $i);
|
||||
|
||||
if ($currentLine && $newLineLength >= $thisLineLength) {
|
||||
$is->write($prepend.$this->standardize($currentLine));
|
||||
@@ -109,7 +109,7 @@ class Swift_Mime_ContentEncoder_QpContentEncoder extends Swift_Encoder_QpEncoder
|
||||
|
||||
$currentLine .= $enc;
|
||||
|
||||
if ($i === false) {
|
||||
if (false === $i) {
|
||||
$lineLen += $size;
|
||||
} else {
|
||||
// 6 is the length of '=0D=0A'.
|
||||
|
||||
@@ -35,9 +35,7 @@ class Swift_Mime_ContentEncoder_QpContentEncoderProxy implements Swift_Mime_Cont
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param Swift_Mime_ContentEncoder_QpContentEncoder $safeEncoder
|
||||
* @param Swift_Mime_ContentEncoder_NativeQpContentEncoder $nativeEncoder
|
||||
* @param string|null $charset
|
||||
* @param string|null $charset
|
||||
*/
|
||||
public function __construct(Swift_Mime_ContentEncoder_QpContentEncoder $safeEncoder, Swift_Mime_ContentEncoder_NativeQpContentEncoder $nativeEncoder, $charset)
|
||||
{
|
||||
|
||||
@@ -11,6 +11,9 @@
|
||||
/**
|
||||
* Handles raw Transfer Encoding in Swift Mailer.
|
||||
*
|
||||
* When sending 8-bit content over SMTP, you should use
|
||||
* Swift_Transport_Esmtp_EightBitMimeHandler to enable the 8BITMIME SMTP
|
||||
* extension.
|
||||
*
|
||||
* @author Sebastiaan Stok <s.stok@rollerscapes.net>
|
||||
*/
|
||||
@@ -33,10 +36,8 @@ class Swift_Mime_ContentEncoder_RawContentEncoder implements Swift_Mime_ContentE
|
||||
/**
|
||||
* Encode stream $in to stream $out.
|
||||
*
|
||||
* @param Swift_OutputByteStream $in
|
||||
* @param Swift_InputByteStream $out
|
||||
* @param int $firstLineOffset ignored
|
||||
* @param int $maxLineLength ignored
|
||||
* @param int $firstLineOffset ignored
|
||||
* @param int $maxLineLength ignored
|
||||
*/
|
||||
public function encodeByteStream(Swift_OutputByteStream $os, Swift_InputByteStream $is, $firstLineOffset = 0, $maxLineLength = 0)
|
||||
{
|
||||
|
||||
@@ -18,13 +18,9 @@ class Swift_Mime_EmbeddedFile extends Swift_Mime_Attachment
|
||||
/**
|
||||
* Creates a new Attachment with $headers and $encoder.
|
||||
*
|
||||
* @param Swift_Mime_SimpleHeaderSet $headers
|
||||
* @param Swift_Mime_ContentEncoder $encoder
|
||||
* @param Swift_KeyCache $cache
|
||||
* @param Swift_IdGenerator $idGenerator
|
||||
* @param array $mimeTypes optional
|
||||
* @param array $mimeTypes optional
|
||||
*/
|
||||
public function __construct(Swift_Mime_SimpleHeaderSet $headers, Swift_Mime_ContentEncoder $encoder, Swift_KeyCache $cache, Swift_IdGenerator $idGenerator, $mimeTypes = array())
|
||||
public function __construct(Swift_Mime_SimpleHeaderSet $headers, Swift_Mime_ContentEncoder $encoder, Swift_KeyCache $cache, Swift_IdGenerator $idGenerator, $mimeTypes = [])
|
||||
{
|
||||
parent::__construct($headers, $encoder, $cache, $idGenerator, $mimeTypes);
|
||||
$this->setDisposition('inline');
|
||||
|
||||
@@ -85,7 +85,7 @@ interface Swift_Mime_Header
|
||||
public function getFieldBody();
|
||||
|
||||
/**
|
||||
* Get this Header rendered as a compliant string.
|
||||
* Get this Header rendered as a compliant string, including trailing CRLF.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
|
||||
@@ -41,7 +41,7 @@ class Swift_Mime_HeaderEncoder_Base64HeaderEncoder extends Swift_Encoder_Base64E
|
||||
*/
|
||||
public function encodeString($string, $firstLineOffset = 0, $maxLineLength = 0, $charset = 'utf-8')
|
||||
{
|
||||
if (strtolower($charset) === 'iso-2022-jp') {
|
||||
if ('iso-2022-jp' === strtolower($charset)) {
|
||||
$old = mb_internal_encoding();
|
||||
mb_internal_encoding('utf-8');
|
||||
$newstring = mb_encode_mimeheader($string, $charset, $this->getName(), "\r\n");
|
||||
|
||||
@@ -29,7 +29,7 @@ class Swift_Mime_HeaderEncoder_QpHeaderEncoder extends Swift_Encoder_QpEncoder i
|
||||
{
|
||||
foreach (array_merge(
|
||||
range(0x61, 0x7A), range(0x41, 0x5A),
|
||||
range(0x30, 0x39), array(0x20, 0x21, 0x2A, 0x2B, 0x2D, 0x2F)
|
||||
range(0x30, 0x39), [0x20, 0x21, 0x2A, 0x2B, 0x2D, 0x2F]
|
||||
) as $byte) {
|
||||
$this->safeMap[$byte] = chr($byte);
|
||||
}
|
||||
@@ -58,7 +58,7 @@ class Swift_Mime_HeaderEncoder_QpHeaderEncoder extends Swift_Encoder_QpEncoder i
|
||||
*/
|
||||
public function encodeString($string, $firstLineOffset = 0, $maxLineLength = 0)
|
||||
{
|
||||
return str_replace(array(' ', '=20', "=\r\n"), array('_', '_', "\r\n"),
|
||||
return str_replace([' ', '=20', "=\r\n"], ['_', '_', "\r\n"],
|
||||
parent::encodeString($string, $firstLineOffset, $maxLineLength)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -109,8 +109,6 @@ abstract class Swift_Mime_Headers_AbstractHeader implements Swift_Mime_Header
|
||||
|
||||
/**
|
||||
* Set the encoder used for encoding the header.
|
||||
*
|
||||
* @param Swift_Mime_HeaderEncoder $encoder
|
||||
*/
|
||||
public function setEncoder(Swift_Mime_HeaderEncoder $encoder)
|
||||
{
|
||||
@@ -196,11 +194,9 @@ abstract class Swift_Mime_Headers_AbstractHeader implements Swift_Mime_Header
|
||||
/**
|
||||
* Produces a compliant, formatted RFC 2822 'phrase' based on the string given.
|
||||
*
|
||||
* @param Swift_Mime_Header $header
|
||||
* @param string $string as displayed
|
||||
* @param string $charset of the text
|
||||
* @param Swift_Mime_HeaderEncoder $encoder
|
||||
* @param bool $shorten the first line to make remove for header name
|
||||
* @param string $string as displayed
|
||||
* @param string $charset of the text
|
||||
* @param bool $shorten the first line to make remove for header name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
@@ -214,7 +210,7 @@ abstract class Swift_Mime_Headers_AbstractHeader implements Swift_Mime_Header
|
||||
// .. but it is just ascii text, try escaping some characters
|
||||
// and make it a quoted-string
|
||||
if (preg_match('/^[\x00-\x08\x0B\x0C\x0E-\x7F]*$/D', $phraseStr)) {
|
||||
$phraseStr = $this->escapeSpecials($phraseStr, array('"'));
|
||||
$phraseStr = $this->escapeSpecials($phraseStr, ['"']);
|
||||
$phraseStr = '"'.$phraseStr.'"';
|
||||
} else {
|
||||
// ... otherwise it needs encoding
|
||||
@@ -239,9 +235,9 @@ abstract class Swift_Mime_Headers_AbstractHeader implements Swift_Mime_Header
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function escapeSpecials($token, $include = array())
|
||||
private function escapeSpecials($token, $include = [])
|
||||
{
|
||||
foreach (array_merge(array('\\'), $include) as $char) {
|
||||
foreach (array_merge(['\\'], $include) as $char) {
|
||||
$token = str_replace($char, '\\'.$char, $token);
|
||||
}
|
||||
|
||||
@@ -251,9 +247,8 @@ abstract class Swift_Mime_Headers_AbstractHeader implements Swift_Mime_Header
|
||||
/**
|
||||
* Encode needed word tokens within a string of input.
|
||||
*
|
||||
* @param Swift_Mime_Header $header
|
||||
* @param string $input
|
||||
* @param string $usedLength optional
|
||||
* @param string $input
|
||||
* @param string $usedLength optional
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
@@ -310,7 +305,7 @@ abstract class Swift_Mime_Headers_AbstractHeader implements Swift_Mime_Header
|
||||
*/
|
||||
protected function getEncodableWordTokens($string)
|
||||
{
|
||||
$tokens = array();
|
||||
$tokens = [];
|
||||
|
||||
$encodedToken = '';
|
||||
// Split at all whitespace boundaries
|
||||
@@ -362,7 +357,7 @@ abstract class Swift_Mime_Headers_AbstractHeader implements Swift_Mime_Header
|
||||
)
|
||||
);
|
||||
|
||||
if (strtolower($this->charset) !== 'iso-2022-jp') {
|
||||
if ('iso-2022-jp' !== strtolower($this->charset)) {
|
||||
// special encoding for iso-2022-jp using mb_encode_mimeheader
|
||||
foreach ($encodedTextLines as $lineNum => $line) {
|
||||
$encodedTextLines[$lineNum] = '=?'.$charsetDecl.
|
||||
@@ -431,7 +426,7 @@ abstract class Swift_Mime_Headers_AbstractHeader implements Swift_Mime_Header
|
||||
$string = $this->getFieldBody();
|
||||
}
|
||||
|
||||
$tokens = array();
|
||||
$tokens = [];
|
||||
|
||||
// Generate atoms; split at all invisible boundaries followed by WSP
|
||||
foreach (preg_split('~(?=[ \t])~', $string) as $token) {
|
||||
@@ -455,7 +450,7 @@ abstract class Swift_Mime_Headers_AbstractHeader implements Swift_Mime_Header
|
||||
private function tokensToString(array $tokens)
|
||||
{
|
||||
$lineCount = 0;
|
||||
$headerLines = array();
|
||||
$headerLines = [];
|
||||
$headerLines[] = $this->name.': ';
|
||||
$currentLine = &$headerLines[$lineCount++];
|
||||
|
||||
|
||||
@@ -79,8 +79,6 @@ class Swift_Mime_Headers_DateHeader extends Swift_Mime_Headers_AbstractHeader
|
||||
* Set the date-time of the Date in this Header.
|
||||
*
|
||||
* If a DateTime instance is provided, it is converted to DateTimeImmutable.
|
||||
*
|
||||
* @param DateTimeInterface $dateTime
|
||||
*/
|
||||
public function setDateTime(DateTimeInterface $dateTime)
|
||||
{
|
||||
|
||||
@@ -25,7 +25,7 @@ class Swift_Mime_Headers_IdentificationHeader extends Swift_Mime_Headers_Abstrac
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
private $ids = array();
|
||||
private $ids = [];
|
||||
|
||||
/**
|
||||
* The strict EmailValidator.
|
||||
@@ -34,16 +34,18 @@ class Swift_Mime_Headers_IdentificationHeader extends Swift_Mime_Headers_Abstrac
|
||||
*/
|
||||
private $emailValidator;
|
||||
|
||||
private $addressEncoder;
|
||||
|
||||
/**
|
||||
* Creates a new IdentificationHeader with the given $name and $id.
|
||||
*
|
||||
* @param string $name
|
||||
* @param EmailValidator $emailValidator
|
||||
* @param string $name
|
||||
*/
|
||||
public function __construct($name, EmailValidator $emailValidator)
|
||||
public function __construct($name, EmailValidator $emailValidator, Swift_AddressEncoder $addressEncoder = null)
|
||||
{
|
||||
$this->setFieldName($name);
|
||||
$this->emailValidator = $emailValidator;
|
||||
$this->addressEncoder = $addressEncoder ?? new Swift_AddressEncoder_IdnAddressEncoder();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -94,7 +96,7 @@ class Swift_Mime_Headers_IdentificationHeader extends Swift_Mime_Headers_Abstrac
|
||||
*/
|
||||
public function setId($id)
|
||||
{
|
||||
$this->setIds(is_array($id) ? $id : array($id));
|
||||
$this->setIds(is_array($id) ? $id : [$id]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -120,7 +122,7 @@ class Swift_Mime_Headers_IdentificationHeader extends Swift_Mime_Headers_Abstrac
|
||||
*/
|
||||
public function setIds(array $ids)
|
||||
{
|
||||
$actualIds = array();
|
||||
$actualIds = [];
|
||||
|
||||
foreach ($ids as $id) {
|
||||
$this->assertValidId($id);
|
||||
@@ -156,10 +158,10 @@ class Swift_Mime_Headers_IdentificationHeader extends Swift_Mime_Headers_Abstrac
|
||||
public function getFieldBody()
|
||||
{
|
||||
if (!$this->getCachedValue()) {
|
||||
$angleAddrs = array();
|
||||
$angleAddrs = [];
|
||||
|
||||
foreach ($this->ids as $id) {
|
||||
$angleAddrs[] = '<'.$id.'>';
|
||||
$angleAddrs[] = '<'.$this->addressEncoder->encodeString($id).'>';
|
||||
}
|
||||
|
||||
$this->setCachedValue(implode(' ', $angleAddrs));
|
||||
|
||||
@@ -23,7 +23,7 @@ class Swift_Mime_Headers_MailboxHeader extends Swift_Mime_Headers_AbstractHeader
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
private $mailboxes = array();
|
||||
private $mailboxes = [];
|
||||
|
||||
/**
|
||||
* The strict EmailValidator.
|
||||
@@ -32,18 +32,19 @@ class Swift_Mime_Headers_MailboxHeader extends Swift_Mime_Headers_AbstractHeader
|
||||
*/
|
||||
private $emailValidator;
|
||||
|
||||
private $addressEncoder;
|
||||
|
||||
/**
|
||||
* Creates a new MailboxHeader with $name.
|
||||
*
|
||||
* @param string $name of Header
|
||||
* @param Swift_Mime_HeaderEncoder $encoder
|
||||
* @param EmailValidator $emailValidator
|
||||
* @param string $name of Header
|
||||
*/
|
||||
public function __construct($name, Swift_Mime_HeaderEncoder $encoder, EmailValidator $emailValidator)
|
||||
public function __construct($name, Swift_Mime_HeaderEncoder $encoder, EmailValidator $emailValidator, Swift_AddressEncoder $addressEncoder = null)
|
||||
{
|
||||
$this->setFieldName($name);
|
||||
$this->setEncoder($encoder);
|
||||
$this->emailValidator = $emailValidator;
|
||||
$this->addressEncoder = $addressEncoder ?? new Swift_AddressEncoder_IdnAddressEncoder();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -257,7 +258,7 @@ class Swift_Mime_Headers_MailboxHeader extends Swift_Mime_Headers_AbstractHeader
|
||||
*/
|
||||
protected function normalizeMailboxes(array $mailboxes)
|
||||
{
|
||||
$actualMailboxes = array();
|
||||
$actualMailboxes = [];
|
||||
|
||||
foreach ($mailboxes as $key => $value) {
|
||||
if (is_string($key)) {
|
||||
@@ -327,10 +328,10 @@ class Swift_Mime_Headers_MailboxHeader extends Swift_Mime_Headers_AbstractHeader
|
||||
*/
|
||||
private function createNameAddressStrings(array $mailboxes)
|
||||
{
|
||||
$strings = array();
|
||||
$strings = [];
|
||||
|
||||
foreach ($mailboxes as $email => $name) {
|
||||
$mailboxStr = $email;
|
||||
$mailboxStr = $this->addressEncoder->encodeString($email);
|
||||
if (null !== $name) {
|
||||
$nameStr = $this->createDisplayNameString($name, empty($strings));
|
||||
$mailboxStr = $nameStr.' <'.$mailboxStr.'>';
|
||||
|
||||
@@ -12,6 +12,8 @@
|
||||
* An OpenDKIM Specific Header using only raw header datas without encoding.
|
||||
*
|
||||
* @author De Cock Xavier <xdecock@gmail.com>
|
||||
*
|
||||
* @deprecated since SwiftMailer 6.1.0; use Swift_Signers_DKIMSigner instead.
|
||||
*/
|
||||
class Swift_Mime_Headers_OpenDKIMHeader implements Swift_Mime_Header
|
||||
{
|
||||
@@ -111,7 +113,7 @@ class Swift_Mime_Headers_OpenDKIMHeader implements Swift_Mime_Header
|
||||
*/
|
||||
public function toString()
|
||||
{
|
||||
return $this->fieldName.': '.$this->value;
|
||||
return $this->fieldName.': '.$this->value."\r\n";
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -34,14 +34,12 @@ class Swift_Mime_Headers_ParameterizedHeader extends Swift_Mime_Headers_Unstruct
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
private $params = array();
|
||||
private $params = [];
|
||||
|
||||
/**
|
||||
* Creates a new ParameterizedHeader with $name.
|
||||
*
|
||||
* @param string $name
|
||||
* @param Swift_Mime_HeaderEncoder $encoder
|
||||
* @param Swift_Encoder $paramEncoder, optional
|
||||
* @param string $name
|
||||
*/
|
||||
public function __construct($name, Swift_Mime_HeaderEncoder $encoder, Swift_Encoder $paramEncoder = null)
|
||||
{
|
||||
@@ -83,7 +81,7 @@ class Swift_Mime_Headers_ParameterizedHeader extends Swift_Mime_Headers_Unstruct
|
||||
*/
|
||||
public function setParameter($parameter, $value)
|
||||
{
|
||||
$this->setParameters(array_merge($this->getParameters(), array($parameter => $value)));
|
||||
$this->setParameters(array_merge($this->getParameters(), [$parameter => $value]));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -211,14 +209,14 @@ class Swift_Mime_Headers_ParameterizedHeader extends Swift_Mime_Headers_Unstruct
|
||||
}
|
||||
}
|
||||
|
||||
$valueLines = isset($this->paramEncoder) ? explode("\r\n", $value) : array($value);
|
||||
$valueLines = isset($this->paramEncoder) ? explode("\r\n", $value) : [$value];
|
||||
|
||||
// Need to add indices
|
||||
if (count($valueLines) > 1) {
|
||||
$paramLines = array();
|
||||
$paramLines = [];
|
||||
foreach ($valueLines as $i => $line) {
|
||||
$paramLines[] = $name.'*'.$i.
|
||||
$this->getEndOfParameterValue($line, true, $i == 0);
|
||||
$this->getEndOfParameterValue($line, true, 0 == $i);
|
||||
}
|
||||
|
||||
return implode(";\r\n ", $paramLines);
|
||||
|
||||
@@ -32,16 +32,18 @@ class Swift_Mime_Headers_PathHeader extends Swift_Mime_Headers_AbstractHeader
|
||||
*/
|
||||
private $emailValidator;
|
||||
|
||||
private $addressEncoder;
|
||||
|
||||
/**
|
||||
* Creates a new PathHeader with the given $name.
|
||||
*
|
||||
* @param string $name
|
||||
* @param EmailValidator $emailValidator
|
||||
* @param string $name
|
||||
*/
|
||||
public function __construct($name, EmailValidator $emailValidator)
|
||||
public function __construct($name, EmailValidator $emailValidator, Swift_AddressEncoder $addressEncoder = null)
|
||||
{
|
||||
$this->setFieldName($name);
|
||||
$this->emailValidator = $emailValidator;
|
||||
$this->addressEncoder = $addressEncoder ?? new Swift_AddressEncoder_IdnAddressEncoder();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -127,7 +129,8 @@ class Swift_Mime_Headers_PathHeader extends Swift_Mime_Headers_AbstractHeader
|
||||
{
|
||||
if (!$this->getCachedValue()) {
|
||||
if (isset($this->address)) {
|
||||
$this->setCachedValue('<'.$this->address.'>');
|
||||
$address = $this->addressEncoder->encodeString($this->address);
|
||||
$this->setCachedValue('<'.$address.'>');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -25,8 +25,7 @@ class Swift_Mime_Headers_UnstructuredHeader extends Swift_Mime_Headers_AbstractH
|
||||
/**
|
||||
* Creates a new SimpleHeader with $name.
|
||||
*
|
||||
* @param string $name
|
||||
* @param Swift_Mime_HeaderEncoder $encoder
|
||||
* @param string $name
|
||||
*/
|
||||
public function __construct($name, Swift_Mime_HeaderEncoder $encoder)
|
||||
{
|
||||
|
||||
@@ -30,11 +30,7 @@ class Swift_Mime_MimePart extends Swift_Mime_SimpleMimeEntity
|
||||
/**
|
||||
* Create a new MimePart with $headers, $encoder and $cache.
|
||||
*
|
||||
* @param Swift_Mime_SimpleHeaderSet $headers
|
||||
* @param Swift_Mime_ContentEncoder $encoder
|
||||
* @param Swift_KeyCache $cache
|
||||
* @param Swift_IdGenerator $idGenerator
|
||||
* @param string $charset
|
||||
* @param string $charset
|
||||
*/
|
||||
public function __construct(Swift_Mime_SimpleHeaderSet $headers, Swift_Mime_ContentEncoder $encoder, Swift_KeyCache $cache, Swift_IdGenerator $idGenerator, $charset = null)
|
||||
{
|
||||
@@ -194,7 +190,7 @@ 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', 'iso-8859-15', ''))) {
|
||||
if (!in_array($charset, ['utf-8', 'iso-8859-1', 'iso-8859-15', ''])) {
|
||||
// mb_convert_encoding must be the first one to check, since iconv cannot convert some words.
|
||||
if (function_exists('mb_convert_encoding')) {
|
||||
$string = mb_convert_encoding($string, $charset, 'utf-8');
|
||||
|
||||
@@ -23,9 +23,6 @@ class Swift_Mime_SimpleHeaderFactory implements Swift_Mime_CharsetObserver
|
||||
/** The Encoder used by parameters */
|
||||
private $paramEncoder;
|
||||
|
||||
/** The Grammar */
|
||||
private $grammar;
|
||||
|
||||
/** Strict EmailValidator */
|
||||
private $emailValidator;
|
||||
|
||||
@@ -35,17 +32,15 @@ class Swift_Mime_SimpleHeaderFactory implements Swift_Mime_CharsetObserver
|
||||
/**
|
||||
* Creates a new SimpleHeaderFactory using $encoder and $paramEncoder.
|
||||
*
|
||||
* @param Swift_Mime_HeaderEncoder $encoder
|
||||
* @param Swift_Encoder $paramEncoder
|
||||
* @param EmailValidator $emailValidator
|
||||
* @param string|null $charset
|
||||
* @param string|null $charset
|
||||
*/
|
||||
public function __construct(Swift_Mime_HeaderEncoder $encoder, Swift_Encoder $paramEncoder, EmailValidator $emailValidator, $charset = null)
|
||||
public function __construct(Swift_Mime_HeaderEncoder $encoder, Swift_Encoder $paramEncoder, EmailValidator $emailValidator, $charset = null, Swift_AddressEncoder $addressEncoder = null)
|
||||
{
|
||||
$this->encoder = $encoder;
|
||||
$this->paramEncoder = $paramEncoder;
|
||||
$this->emailValidator = $emailValidator;
|
||||
$this->charset = $charset;
|
||||
$this->addressEncoder = $addressEncoder ?? new Swift_AddressEncoder_IdnAddressEncoder();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -58,7 +53,7 @@ class Swift_Mime_SimpleHeaderFactory implements Swift_Mime_CharsetObserver
|
||||
*/
|
||||
public function createMailboxHeader($name, $addresses = null)
|
||||
{
|
||||
$header = new Swift_Mime_Headers_MailboxHeader($name, $this->encoder, $this->emailValidator);
|
||||
$header = new Swift_Mime_Headers_MailboxHeader($name, $this->encoder, $this->emailValidator, $this->addressEncoder);
|
||||
if (isset($addresses)) {
|
||||
$header->setFieldBodyModel($addresses);
|
||||
}
|
||||
@@ -114,9 +109,9 @@ class Swift_Mime_SimpleHeaderFactory implements Swift_Mime_CharsetObserver
|
||||
*
|
||||
* @return Swift_Mime_Headers_ParameterizedHeader
|
||||
*/
|
||||
public function createParameterizedHeader($name, $value = null, $params = array())
|
||||
public function createParameterizedHeader($name, $value = null, $params = [])
|
||||
{
|
||||
$header = new Swift_Mime_Headers_ParameterizedHeader($name, $this->encoder, (strtolower($name) == 'content-disposition') ? $this->paramEncoder : null);
|
||||
$header = new Swift_Mime_Headers_ParameterizedHeader($name, $this->encoder, ('content-disposition' == strtolower($name)) ? $this->paramEncoder : null);
|
||||
if (isset($value)) {
|
||||
$header->setFieldBodyModel($value);
|
||||
}
|
||||
|
||||
@@ -19,13 +19,13 @@ class Swift_Mime_SimpleHeaderSet implements Swift_Mime_CharsetObserver
|
||||
private $factory;
|
||||
|
||||
/** Collection of set Headers */
|
||||
private $headers = array();
|
||||
private $headers = [];
|
||||
|
||||
/** Field ordering details */
|
||||
private $order = array();
|
||||
private $order = [];
|
||||
|
||||
/** List of fields which are required to be displayed */
|
||||
private $required = array();
|
||||
private $required = [];
|
||||
|
||||
/** The charset used by Headers */
|
||||
private $charset;
|
||||
@@ -33,8 +33,7 @@ class Swift_Mime_SimpleHeaderSet implements Swift_Mime_CharsetObserver
|
||||
/**
|
||||
* Create a new SimpleHeaderSet with the given $factory.
|
||||
*
|
||||
* @param Swift_Mime_SimpleHeaderFactory $factory
|
||||
* @param string $charset
|
||||
* @param string $charset
|
||||
*/
|
||||
public function __construct(Swift_Mime_SimpleHeaderFactory $factory, $charset = null)
|
||||
{
|
||||
@@ -69,20 +68,17 @@ class Swift_Mime_SimpleHeaderSet implements Swift_Mime_CharsetObserver
|
||||
*/
|
||||
public function addMailboxHeader($name, $addresses = null)
|
||||
{
|
||||
$this->storeHeader($name,
|
||||
$this->factory->createMailboxHeader($name, $addresses));
|
||||
$this->storeHeader($name, $this->factory->createMailboxHeader($name, $addresses));
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a new Date header using $dateTime.
|
||||
*
|
||||
* @param string $name
|
||||
* @param DateTimeInterface $dateTime
|
||||
* @param string $name
|
||||
*/
|
||||
public function addDateHeader($name, DateTimeInterface $dateTime = null)
|
||||
{
|
||||
$this->storeHeader($name,
|
||||
$this->factory->createDateHeader($name, $dateTime));
|
||||
$this->storeHeader($name, $this->factory->createDateHeader($name, $dateTime));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -93,8 +89,7 @@ class Swift_Mime_SimpleHeaderSet implements Swift_Mime_CharsetObserver
|
||||
*/
|
||||
public function addTextHeader($name, $value = null)
|
||||
{
|
||||
$this->storeHeader($name,
|
||||
$this->factory->createTextHeader($name, $value));
|
||||
$this->storeHeader($name, $this->factory->createTextHeader($name, $value));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -104,7 +99,7 @@ class Swift_Mime_SimpleHeaderSet implements Swift_Mime_CharsetObserver
|
||||
* @param string $value
|
||||
* @param array $params
|
||||
*/
|
||||
public function addParameterizedHeader($name, $value = null, $params = array())
|
||||
public function addParameterizedHeader($name, $value = null, $params = [])
|
||||
{
|
||||
$this->storeHeader($name, $this->factory->createParameterizedHeader($name, $value, $params));
|
||||
}
|
||||
@@ -166,8 +161,7 @@ class Swift_Mime_SimpleHeaderSet implements Swift_Mime_CharsetObserver
|
||||
* If $index is specified, the header will be inserted into the set at this
|
||||
* offset.
|
||||
*
|
||||
* @param Swift_Mime_Header $header
|
||||
* @param int $index
|
||||
* @param int $index
|
||||
*/
|
||||
public function set(Swift_Mime_Header $header, $index = 0)
|
||||
{
|
||||
@@ -212,7 +206,7 @@ class Swift_Mime_SimpleHeaderSet implements Swift_Mime_CharsetObserver
|
||||
public function getAll($name = null)
|
||||
{
|
||||
if (!isset($name)) {
|
||||
$headers = array();
|
||||
$headers = [];
|
||||
foreach ($this->headers as $collection) {
|
||||
$headers = array_merge($headers, $collection);
|
||||
}
|
||||
@@ -222,7 +216,7 @@ class Swift_Mime_SimpleHeaderSet implements Swift_Mime_CharsetObserver
|
||||
|
||||
$lowerName = strtolower($name);
|
||||
if (!array_key_exists($lowerName, $this->headers)) {
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
|
||||
return $this->headers[$lowerName];
|
||||
@@ -237,7 +231,7 @@ class Swift_Mime_SimpleHeaderSet implements Swift_Mime_CharsetObserver
|
||||
{
|
||||
$headers = $this->headers;
|
||||
if ($this->canSort()) {
|
||||
uksort($headers, array($this, 'sortHeaders'));
|
||||
uksort($headers, [$this, 'sortHeaders']);
|
||||
}
|
||||
|
||||
return array_keys($headers);
|
||||
@@ -272,8 +266,6 @@ class Swift_Mime_SimpleHeaderSet implements Swift_Mime_CharsetObserver
|
||||
* Define a list of Header names as an array in the correct order.
|
||||
*
|
||||
* These Headers will be output in the given order where present.
|
||||
*
|
||||
* @param array $sequence
|
||||
*/
|
||||
public function defineOrdering(array $sequence)
|
||||
{
|
||||
@@ -284,8 +276,6 @@ class Swift_Mime_SimpleHeaderSet implements Swift_Mime_CharsetObserver
|
||||
* Set a list of header names which must always be displayed when set.
|
||||
*
|
||||
* Usually headers without a field value won't be output unless set here.
|
||||
*
|
||||
* @param array $names
|
||||
*/
|
||||
public function setAlwaysDisplayed(array $names)
|
||||
{
|
||||
@@ -312,11 +302,11 @@ class Swift_Mime_SimpleHeaderSet implements Swift_Mime_CharsetObserver
|
||||
$string = '';
|
||||
$headers = $this->headers;
|
||||
if ($this->canSort()) {
|
||||
uksort($headers, array($this, 'sortHeaders'));
|
||||
uksort($headers, [$this, 'sortHeaders']);
|
||||
}
|
||||
foreach ($headers as $collection) {
|
||||
foreach ($collection as $header) {
|
||||
if ($this->isDisplayed($header) || $header->getFieldBody() != '') {
|
||||
if ($this->isDisplayed($header) || '' != $header->getFieldBody()) {
|
||||
$string .= $header->toString();
|
||||
}
|
||||
}
|
||||
@@ -341,7 +331,7 @@ class Swift_Mime_SimpleHeaderSet implements Swift_Mime_CharsetObserver
|
||||
private function storeHeader($name, Swift_Mime_Header $header, $offset = null)
|
||||
{
|
||||
if (!isset($this->headers[strtolower($name)])) {
|
||||
$this->headers[strtolower($name)] = array();
|
||||
$this->headers[strtolower($name)] = [];
|
||||
}
|
||||
if (!isset($offset)) {
|
||||
$this->headers[strtolower($name)][] = $header;
|
||||
|
||||
@@ -24,16 +24,12 @@ class Swift_Mime_SimpleMessage extends Swift_Mime_MimePart
|
||||
/**
|
||||
* Create a new SimpleMessage with $headers, $encoder and $cache.
|
||||
*
|
||||
* @param Swift_Mime_SimpleHeaderSet $headers
|
||||
* @param Swift_Mime_ContentEncoder $encoder
|
||||
* @param Swift_KeyCache $cache
|
||||
* @param Swift_IdGenerator $idGenerator
|
||||
* @param string $charset
|
||||
* @param string $charset
|
||||
*/
|
||||
public function __construct(Swift_Mime_SimpleHeaderSet $headers, Swift_Mime_ContentEncoder $encoder, Swift_KeyCache $cache, Swift_IdGenerator $idGenerator, $charset = null)
|
||||
{
|
||||
parent::__construct($headers, $encoder, $cache, $idGenerator, $charset);
|
||||
$this->getHeaders()->defineOrdering(array(
|
||||
$this->getHeaders()->defineOrdering([
|
||||
'Return-Path',
|
||||
'Received',
|
||||
'DKIM-Signature',
|
||||
@@ -50,8 +46,8 @@ class Swift_Mime_SimpleMessage extends Swift_Mime_MimePart
|
||||
'MIME-Version',
|
||||
'Content-Type',
|
||||
'Content-Transfer-Encoding',
|
||||
));
|
||||
$this->getHeaders()->setAlwaysDisplayed(array('Date', 'Message-ID', 'From'));
|
||||
]);
|
||||
$this->getHeaders()->setAlwaysDisplayed(['Date', 'Message-ID', 'From']);
|
||||
$this->getHeaders()->addTextHeader('MIME-Version', '1.0');
|
||||
$this->setDate(new DateTimeImmutable());
|
||||
$this->setId($this->getId());
|
||||
@@ -97,8 +93,6 @@ class Swift_Mime_SimpleMessage extends Swift_Mime_MimePart
|
||||
/**
|
||||
* Set the date at which this message was created.
|
||||
*
|
||||
* @param DateTimeInterface $dateTime
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setDate(DateTimeInterface $dateTime)
|
||||
@@ -159,7 +153,7 @@ class Swift_Mime_SimpleMessage extends Swift_Mime_MimePart
|
||||
public function setSender($address, $name = null)
|
||||
{
|
||||
if (!is_array($address) && isset($name)) {
|
||||
$address = array($address => $name);
|
||||
$address = [$address => $name];
|
||||
}
|
||||
|
||||
if (!$this->setHeaderFieldModel('Sender', (array) $address)) {
|
||||
@@ -213,7 +207,7 @@ class Swift_Mime_SimpleMessage extends Swift_Mime_MimePart
|
||||
public function setFrom($addresses, $name = null)
|
||||
{
|
||||
if (!is_array($addresses) && isset($name)) {
|
||||
$addresses = array($addresses => $name);
|
||||
$addresses = [$addresses => $name];
|
||||
}
|
||||
|
||||
if (!$this->setHeaderFieldModel('From', (array) $addresses)) {
|
||||
@@ -267,7 +261,7 @@ class Swift_Mime_SimpleMessage extends Swift_Mime_MimePart
|
||||
public function setReplyTo($addresses, $name = null)
|
||||
{
|
||||
if (!is_array($addresses) && isset($name)) {
|
||||
$addresses = array($addresses => $name);
|
||||
$addresses = [$addresses => $name];
|
||||
}
|
||||
|
||||
if (!$this->setHeaderFieldModel('Reply-To', (array) $addresses)) {
|
||||
@@ -322,7 +316,7 @@ class Swift_Mime_SimpleMessage extends Swift_Mime_MimePart
|
||||
public function setTo($addresses, $name = null)
|
||||
{
|
||||
if (!is_array($addresses) && isset($name)) {
|
||||
$addresses = array($addresses => $name);
|
||||
$addresses = [$addresses => $name];
|
||||
}
|
||||
|
||||
if (!$this->setHeaderFieldModel('To', (array) $addresses)) {
|
||||
@@ -374,7 +368,7 @@ class Swift_Mime_SimpleMessage extends Swift_Mime_MimePart
|
||||
public function setCc($addresses, $name = null)
|
||||
{
|
||||
if (!is_array($addresses) && isset($name)) {
|
||||
$addresses = array($addresses => $name);
|
||||
$addresses = [$addresses => $name];
|
||||
}
|
||||
|
||||
if (!$this->setHeaderFieldModel('Cc', (array) $addresses)) {
|
||||
@@ -426,7 +420,7 @@ class Swift_Mime_SimpleMessage extends Swift_Mime_MimePart
|
||||
public function setBcc($addresses, $name = null)
|
||||
{
|
||||
if (!is_array($addresses) && isset($name)) {
|
||||
$addresses = array($addresses => $name);
|
||||
$addresses = [$addresses => $name];
|
||||
}
|
||||
|
||||
if (!$this->setHeaderFieldModel('Bcc', (array) $addresses)) {
|
||||
@@ -457,13 +451,13 @@ class Swift_Mime_SimpleMessage extends Swift_Mime_MimePart
|
||||
*/
|
||||
public function setPriority($priority)
|
||||
{
|
||||
$priorityMap = array(
|
||||
$priorityMap = [
|
||||
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)) {
|
||||
$priority = max($pMapKeys);
|
||||
@@ -526,13 +520,11 @@ class Swift_Mime_SimpleMessage extends Swift_Mime_MimePart
|
||||
/**
|
||||
* Attach a {@link Swift_Mime_SimpleMimeEntity} such as an Attachment or MimePart.
|
||||
*
|
||||
* @param Swift_Mime_SimpleMimeEntity $entity
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function attach(Swift_Mime_SimpleMimeEntity $entity)
|
||||
{
|
||||
$this->setChildren(array_merge($this->getChildren(), array($entity)));
|
||||
$this->setChildren(array_merge($this->getChildren(), [$entity]));
|
||||
|
||||
return $this;
|
||||
}
|
||||
@@ -540,13 +532,11 @@ class Swift_Mime_SimpleMessage extends Swift_Mime_MimePart
|
||||
/**
|
||||
* Remove an already attached entity.
|
||||
*
|
||||
* @param Swift_Mime_SimpleMimeEntity $entity
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function detach(Swift_Mime_SimpleMimeEntity $entity)
|
||||
{
|
||||
$newChildren = array();
|
||||
$newChildren = [];
|
||||
foreach ($this->getChildren() as $child) {
|
||||
if ($entity !== $child) {
|
||||
$newChildren[] = $child;
|
||||
@@ -559,9 +549,8 @@ class Swift_Mime_SimpleMessage extends Swift_Mime_MimePart
|
||||
|
||||
/**
|
||||
* Attach a {@link Swift_Mime_SimpleMimeEntity} and return it's CID source.
|
||||
* This method should be used when embedding images or other data in a message.
|
||||
*
|
||||
* @param Swift_Mime_SimpleMimeEntity $entity
|
||||
* This method should be used when embedding images or other data in a message.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
@@ -579,8 +568,8 @@ class Swift_Mime_SimpleMessage extends Swift_Mime_MimePart
|
||||
*/
|
||||
public function toString()
|
||||
{
|
||||
if (count($children = $this->getChildren()) > 0 && $this->getBody() != '') {
|
||||
$this->setChildren(array_merge(array($this->becomeMimePart()), $children));
|
||||
if (count($children = $this->getChildren()) > 0 && '' != $this->getBody()) {
|
||||
$this->setChildren(array_merge([$this->becomeMimePart()], $children));
|
||||
$string = parent::toString();
|
||||
$this->setChildren($children);
|
||||
} else {
|
||||
@@ -604,13 +593,11 @@ class Swift_Mime_SimpleMessage extends Swift_Mime_MimePart
|
||||
|
||||
/**
|
||||
* Write this message to a {@link Swift_InputByteStream}.
|
||||
*
|
||||
* @param Swift_InputByteStream $is
|
||||
*/
|
||||
public function toByteStream(Swift_InputByteStream $is)
|
||||
{
|
||||
if (count($children = $this->getChildren()) > 0 && $this->getBody() != '') {
|
||||
$this->setChildren(array_merge(array($this->becomeMimePart()), $children));
|
||||
if (count($children = $this->getChildren()) > 0 && '' != $this->getBody()) {
|
||||
$this->setChildren(array_merge([$this->becomeMimePart()], $children));
|
||||
parent::toByteStream($is);
|
||||
$this->setChildren($children);
|
||||
} else {
|
||||
|
||||
@@ -43,14 +43,14 @@ class Swift_Mime_SimpleMimeEntity implements Swift_Mime_CharsetObserver, Swift_M
|
||||
private $boundary;
|
||||
|
||||
/** Mime types to be used based on the nesting level */
|
||||
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),
|
||||
);
|
||||
private $compositeRanges = [
|
||||
'multipart/mixed' => [self::LEVEL_TOP, self::LEVEL_MIXED],
|
||||
'multipart/alternative' => [self::LEVEL_MIXED, self::LEVEL_ALTERNATIVE],
|
||||
'multipart/related' => [self::LEVEL_ALTERNATIVE, self::LEVEL_RELATED],
|
||||
];
|
||||
|
||||
/** A set of filter rules to define what level an entity should be nested at */
|
||||
private $compoundLevelFilters = array();
|
||||
private $compoundLevelFilters = [];
|
||||
|
||||
/** The nesting level of this entity */
|
||||
private $nestingLevel = self::LEVEL_ALTERNATIVE;
|
||||
@@ -59,20 +59,20 @@ class Swift_Mime_SimpleMimeEntity implements Swift_Mime_CharsetObserver, Swift_M
|
||||
private $cache;
|
||||
|
||||
/** Direct descendants of this entity */
|
||||
private $immediateChildren = array();
|
||||
private $immediateChildren = [];
|
||||
|
||||
/** All descendants of this entity */
|
||||
private $children = array();
|
||||
private $children = [];
|
||||
|
||||
/** The maximum line length of the body of this entity */
|
||||
private $maxLineLength = 78;
|
||||
|
||||
/** The order in which alternative mime types should appear */
|
||||
private $alternativePartOrder = array(
|
||||
private $alternativePartOrder = [
|
||||
'text/plain' => 1,
|
||||
'text/html' => 2,
|
||||
'multipart/related' => 3,
|
||||
);
|
||||
];
|
||||
|
||||
/** The CID of this entity */
|
||||
private $id;
|
||||
@@ -84,11 +84,6 @@ class Swift_Mime_SimpleMimeEntity implements Swift_Mime_CharsetObserver, Swift_M
|
||||
|
||||
/**
|
||||
* Create a new SimpleMimeEntity with $headers, $encoder and $cache.
|
||||
*
|
||||
* @param Swift_Mime_SimpleHeaderSet $headers
|
||||
* @param Swift_Mime_ContentEncoder $encoder
|
||||
* @param Swift_KeyCache $cache
|
||||
* @param Swift_IdGenerator $idGenerator
|
||||
*/
|
||||
public function __construct(Swift_Mime_SimpleHeaderSet $headers, Swift_Mime_ContentEncoder $encoder, Swift_KeyCache $cache, Swift_IdGenerator $idGenerator)
|
||||
{
|
||||
@@ -97,7 +92,7 @@ class Swift_Mime_SimpleMimeEntity implements Swift_Mime_CharsetObserver, Swift_M
|
||||
$this->headers = $headers;
|
||||
$this->idGenerator = $idGenerator;
|
||||
$this->setEncoder($encoder);
|
||||
$this->headers->defineOrdering(array('Content-Type', 'Content-Transfer-Encoding'));
|
||||
$this->headers->defineOrdering(['Content-Type', 'Content-Transfer-Encoding']);
|
||||
|
||||
// This array specifies that, when the entire MIME document contains
|
||||
// $compoundLevel, then for each child within $level, if its Content-Type
|
||||
@@ -112,14 +107,14 @@ class Swift_Mime_SimpleMimeEntity implements Swift_Mime_CharsetObserver, Swift_M
|
||||
// )
|
||||
// )
|
||||
|
||||
$this->compoundLevelFilters = array(
|
||||
(self::LEVEL_ALTERNATIVE + self::LEVEL_RELATED) => array(
|
||||
self::LEVEL_ALTERNATIVE => array(
|
||||
$this->compoundLevelFilters = [
|
||||
(self::LEVEL_ALTERNATIVE + self::LEVEL_RELATED) => [
|
||||
self::LEVEL_ALTERNATIVE => [
|
||||
'text/plain' => self::LEVEL_ALTERNATIVE,
|
||||
'text/html' => self::LEVEL_RELATED,
|
||||
),
|
||||
),
|
||||
);
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
$this->id = $this->idGenerator->generateId();
|
||||
}
|
||||
@@ -294,15 +289,15 @@ class Swift_Mime_SimpleMimeEntity implements Swift_Mime_CharsetObserver, Swift_M
|
||||
{
|
||||
// TODO: Try to refactor this logic
|
||||
$compoundLevel = $compoundLevel ?? $this->getCompoundLevel($children);
|
||||
$immediateChildren = array();
|
||||
$grandchildren = array();
|
||||
$immediateChildren = [];
|
||||
$grandchildren = [];
|
||||
$newContentType = $this->userContentType;
|
||||
|
||||
foreach ($children as $child) {
|
||||
$level = $this->getNeededChildLevel($child, $compoundLevel);
|
||||
if (empty($immediateChildren)) {
|
||||
//first iteration
|
||||
$immediateChildren = array($child);
|
||||
$immediateChildren = [$child];
|
||||
} else {
|
||||
$nextLevel = $this->getNeededChildLevel($immediateChildren[0], $compoundLevel);
|
||||
if ($nextLevel == $level) {
|
||||
@@ -311,7 +306,7 @@ class Swift_Mime_SimpleMimeEntity implements Swift_Mime_CharsetObserver, Swift_M
|
||||
// Re-assign immediateChildren to grandchildren
|
||||
$grandchildren = array_merge($grandchildren, $immediateChildren);
|
||||
// Set new children
|
||||
$immediateChildren = array($child);
|
||||
$immediateChildren = [$child];
|
||||
} else {
|
||||
$grandchildren[] = $child;
|
||||
}
|
||||
@@ -395,8 +390,6 @@ class Swift_Mime_SimpleMimeEntity implements Swift_Mime_CharsetObserver, Swift_M
|
||||
/**
|
||||
* Set the encoder used for the body of this entity.
|
||||
*
|
||||
* @param Swift_Mime_ContentEncoder $encoder
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setEncoder(Swift_Mime_ContentEncoder $encoder)
|
||||
@@ -457,8 +450,6 @@ class Swift_Mime_SimpleMimeEntity implements Swift_Mime_CharsetObserver, Swift_M
|
||||
/**
|
||||
* Receive notification that the encoder of this entity or a parent entity
|
||||
* has changed.
|
||||
*
|
||||
* @param Swift_Mime_ContentEncoder $encoder
|
||||
*/
|
||||
public function encoderChanged(Swift_Mime_ContentEncoder $encoder)
|
||||
{
|
||||
@@ -522,8 +513,6 @@ class Swift_Mime_SimpleMimeEntity implements Swift_Mime_CharsetObserver, Swift_M
|
||||
|
||||
/**
|
||||
* Write this entire entity to a {@see Swift_InputByteStream}.
|
||||
*
|
||||
* @param Swift_InputByteStream
|
||||
*/
|
||||
public function toByteStream(Swift_InputByteStream $is)
|
||||
{
|
||||
@@ -535,8 +524,6 @@ class Swift_Mime_SimpleMimeEntity implements Swift_Mime_CharsetObserver, Swift_M
|
||||
|
||||
/**
|
||||
* Write this entire entity to a {@link Swift_InputByteStream}.
|
||||
*
|
||||
* @param Swift_InputByteStream
|
||||
*/
|
||||
protected function bodyToByteStream(Swift_InputByteStream $is)
|
||||
{
|
||||
@@ -726,7 +713,7 @@ class Swift_Mime_SimpleMimeEntity implements Swift_Mime_CharsetObserver, Swift_M
|
||||
|
||||
private function getNeededChildLevel($child, $compoundLevel)
|
||||
{
|
||||
$filter = array();
|
||||
$filter = [];
|
||||
foreach ($this->compoundLevelFilters as $bitmask => $rules) {
|
||||
if (($compoundLevel & $bitmask) === $bitmask) {
|
||||
$filter = $rules + $filter;
|
||||
@@ -769,7 +756,7 @@ class Swift_Mime_SimpleMimeEntity implements Swift_Mime_CharsetObserver, Swift_M
|
||||
$shouldSort = false;
|
||||
foreach ($this->immediateChildren as $child) {
|
||||
// NOTE: This include alternative parts moved into a related part
|
||||
if ($child->getNestingLevel() == self::LEVEL_ALTERNATIVE) {
|
||||
if (self::LEVEL_ALTERNATIVE == $child->getNestingLevel()) {
|
||||
$shouldSort = true;
|
||||
break;
|
||||
}
|
||||
@@ -778,13 +765,13 @@ class Swift_Mime_SimpleMimeEntity implements Swift_Mime_CharsetObserver, Swift_M
|
||||
// Sort in order of preference, if there is one
|
||||
if ($shouldSort) {
|
||||
// Group the messages by order of preference
|
||||
$sorted = array();
|
||||
$sorted = [];
|
||||
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] = [];
|
||||
}
|
||||
|
||||
$sorted[$level][] = $child;
|
||||
@@ -792,7 +779,7 @@ class Swift_Mime_SimpleMimeEntity implements Swift_Mime_CharsetObserver, Swift_M
|
||||
|
||||
ksort($sorted);
|
||||
|
||||
$this->immediateChildren = array_reduce($sorted, 'array_merge', array());
|
||||
$this->immediateChildren = array_reduce($sorted, 'array_merge', []);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -814,7 +801,7 @@ class Swift_Mime_SimpleMimeEntity implements Swift_Mime_CharsetObserver, Swift_M
|
||||
$this->headers = clone $this->headers;
|
||||
$this->encoder = clone $this->encoder;
|
||||
$this->cacheKey = bin2hex(random_bytes(16)); // set 32 hex values
|
||||
$children = array();
|
||||
$children = [];
|
||||
foreach ($this->children as $pos => $child) {
|
||||
$children[$pos] = clone $child;
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ class Swift_MimePart extends Swift_Mime_MimePart
|
||||
public function __construct($body = null, $contentType = null, $charset = null)
|
||||
{
|
||||
call_user_func_array(
|
||||
array($this, 'Swift_Mime_MimePart::__construct'),
|
||||
[$this, 'Swift_Mime_MimePart::__construct'],
|
||||
Swift_DependencyContainer::getInstance()
|
||||
->createDependenciesFor('mime.part')
|
||||
);
|
||||
|
||||
@@ -18,7 +18,7 @@ class Swift_NullTransport extends Swift_Transport_NullTransport
|
||||
public function __construct()
|
||||
{
|
||||
call_user_func_array(
|
||||
array($this, 'Swift_Transport_NullTransport::__construct'),
|
||||
[$this, 'Swift_Transport_NullTransport::__construct'],
|
||||
Swift_DependencyContainer::getInstance()
|
||||
->createDependenciesFor('transport.null')
|
||||
);
|
||||
|
||||
@@ -99,8 +99,6 @@ class Swift_Plugins_AntiFloodPlugin implements Swift_Events_SendListener, Swift_
|
||||
|
||||
/**
|
||||
* Invoked immediately before the Message is sent.
|
||||
*
|
||||
* @param Swift_Events_SendEvent $evt
|
||||
*/
|
||||
public function beforeSendPerformed(Swift_Events_SendEvent $evt)
|
||||
{
|
||||
@@ -108,8 +106,6 @@ class Swift_Plugins_AntiFloodPlugin implements Swift_Events_SendListener, Swift_
|
||||
|
||||
/**
|
||||
* Invoked immediately after the Message is sent.
|
||||
*
|
||||
* @param Swift_Events_SendEvent $evt
|
||||
*/
|
||||
public function sendPerformed(Swift_Events_SendEvent $evt)
|
||||
{
|
||||
|
||||
@@ -30,7 +30,7 @@ class Swift_Plugins_BandwidthMonitorPlugin implements Swift_Events_SendListener,
|
||||
private $in = 0;
|
||||
|
||||
/** Bound byte streams */
|
||||
private $mirrors = array();
|
||||
private $mirrors = [];
|
||||
|
||||
/**
|
||||
* Not used.
|
||||
@@ -41,8 +41,6 @@ class Swift_Plugins_BandwidthMonitorPlugin implements Swift_Events_SendListener,
|
||||
|
||||
/**
|
||||
* Invoked immediately after the Message is sent.
|
||||
*
|
||||
* @param Swift_Events_SendEvent $evt
|
||||
*/
|
||||
public function sendPerformed(Swift_Events_SendEvent $evt)
|
||||
{
|
||||
@@ -52,8 +50,6 @@ class Swift_Plugins_BandwidthMonitorPlugin implements Swift_Events_SendListener,
|
||||
|
||||
/**
|
||||
* Invoked immediately following a command being sent.
|
||||
*
|
||||
* @param Swift_Events_CommandEvent $evt
|
||||
*/
|
||||
public function commandSent(Swift_Events_CommandEvent $evt)
|
||||
{
|
||||
@@ -63,8 +59,6 @@ class Swift_Plugins_BandwidthMonitorPlugin implements Swift_Events_SendListener,
|
||||
|
||||
/**
|
||||
* Invoked immediately following a response coming back.
|
||||
*
|
||||
* @param Swift_Events_ResponseEvent $evt
|
||||
*/
|
||||
public function responseReceived(Swift_Events_ResponseEvent $evt)
|
||||
{
|
||||
@@ -97,8 +91,6 @@ class Swift_Plugins_BandwidthMonitorPlugin implements Swift_Events_SendListener,
|
||||
*
|
||||
* The stream acts as an observer, receiving all data that is written.
|
||||
* All {@link write()} and {@link flushBuffers()} operations will be mirrored.
|
||||
*
|
||||
* @param Swift_InputByteStream $is
|
||||
*/
|
||||
public function bind(Swift_InputByteStream $is)
|
||||
{
|
||||
@@ -111,8 +103,6 @@ class Swift_Plugins_BandwidthMonitorPlugin implements Swift_Events_SendListener,
|
||||
* If $is is not bound, no errors will be raised.
|
||||
* If the stream currently has any buffered data it will be written to $is
|
||||
* before unbinding occurs.
|
||||
*
|
||||
* @param Swift_InputByteStream $is
|
||||
*/
|
||||
public function unbind(Swift_InputByteStream $is)
|
||||
{
|
||||
|
||||
@@ -23,10 +23,10 @@ class Swift_Plugins_DecoratorPlugin implements Swift_Events_SendListener, Swift_
|
||||
private $originalBody;
|
||||
|
||||
/** The original headers of the message, before replacements */
|
||||
private $originalHeaders = array();
|
||||
private $originalHeaders = [];
|
||||
|
||||
/** Bodies of children before they are replaced */
|
||||
private $originalChildBodies = array();
|
||||
private $originalChildBodies = [];
|
||||
|
||||
/** The Message that was last replaced */
|
||||
private $lastMessage;
|
||||
@@ -74,8 +74,6 @@ class Swift_Plugins_DecoratorPlugin implements Swift_Events_SendListener, Swift_
|
||||
|
||||
/**
|
||||
* Invoked immediately before the Message is sent.
|
||||
*
|
||||
* @param Swift_Events_SendEvent $evt
|
||||
*/
|
||||
public function beforeSendPerformed(Swift_Events_SendEvent $evt)
|
||||
{
|
||||
@@ -99,7 +97,7 @@ class Swift_Plugins_DecoratorPlugin implements Swift_Events_SendListener, Swift_
|
||||
$body = $header->getFieldBodyModel();
|
||||
$count = 0;
|
||||
if (is_array($body)) {
|
||||
$bodyReplaced = array();
|
||||
$bodyReplaced = [];
|
||||
foreach ($body as $key => $value) {
|
||||
$count1 = 0;
|
||||
$count2 = 0;
|
||||
@@ -164,8 +162,6 @@ class Swift_Plugins_DecoratorPlugin implements Swift_Events_SendListener, Swift_
|
||||
|
||||
/**
|
||||
* Invoked immediately after the Message is sent.
|
||||
*
|
||||
* @param Swift_Events_SendEvent $evt
|
||||
*/
|
||||
public function sendPerformed(Swift_Events_SendEvent $evt)
|
||||
{
|
||||
@@ -186,7 +182,7 @@ class Swift_Plugins_DecoratorPlugin implements Swift_Events_SendListener, Swift_
|
||||
$header->setFieldBodyModel($this->originalHeaders[$header->getFieldName()]);
|
||||
}
|
||||
}
|
||||
$this->originalHeaders = array();
|
||||
$this->originalHeaders = [];
|
||||
}
|
||||
if (!empty($this->originalChildBodies)) {
|
||||
$children = (array) $message->getChildren();
|
||||
@@ -196,7 +192,7 @@ class Swift_Plugins_DecoratorPlugin implements Swift_Events_SendListener, Swift_
|
||||
$child->setBody($this->originalChildBodies[$id]);
|
||||
}
|
||||
}
|
||||
$this->originalChildBodies = array();
|
||||
$this->originalChildBodies = [];
|
||||
}
|
||||
$this->lastMessage = null;
|
||||
}
|
||||
|
||||
@@ -34,8 +34,6 @@ class Swift_Plugins_ImpersonatePlugin implements Swift_Events_SendListener
|
||||
|
||||
/**
|
||||
* Invoked immediately before the Message is sent.
|
||||
*
|
||||
* @param Swift_Events_SendEvent $evt
|
||||
*/
|
||||
public function beforeSendPerformed(Swift_Events_SendEvent $evt)
|
||||
{
|
||||
@@ -51,8 +49,6 @@ class Swift_Plugins_ImpersonatePlugin implements Swift_Events_SendListener
|
||||
|
||||
/**
|
||||
* Invoked immediately after the Message is sent.
|
||||
*
|
||||
* @param Swift_Events_SendEvent $evt
|
||||
*/
|
||||
public function sendPerformed(Swift_Events_SendEvent $evt)
|
||||
{
|
||||
|
||||
@@ -20,8 +20,6 @@ class Swift_Plugins_LoggerPlugin implements Swift_Events_CommandListener, Swift_
|
||||
|
||||
/**
|
||||
* Create a new LoggerPlugin using $logger.
|
||||
*
|
||||
* @param Swift_Plugins_Logger $logger
|
||||
*/
|
||||
public function __construct(Swift_Plugins_Logger $logger)
|
||||
{
|
||||
@@ -58,8 +56,6 @@ class Swift_Plugins_LoggerPlugin implements Swift_Events_CommandListener, Swift_
|
||||
|
||||
/**
|
||||
* Invoked immediately following a command being sent.
|
||||
*
|
||||
* @param Swift_Events_CommandEvent $evt
|
||||
*/
|
||||
public function commandSent(Swift_Events_CommandEvent $evt)
|
||||
{
|
||||
@@ -69,8 +65,6 @@ class Swift_Plugins_LoggerPlugin implements Swift_Events_CommandListener, Swift_
|
||||
|
||||
/**
|
||||
* Invoked immediately following a response coming back.
|
||||
*
|
||||
* @param Swift_Events_ResponseEvent $evt
|
||||
*/
|
||||
public function responseReceived(Swift_Events_ResponseEvent $evt)
|
||||
{
|
||||
@@ -80,8 +74,6 @@ class Swift_Plugins_LoggerPlugin implements Swift_Events_CommandListener, Swift_
|
||||
|
||||
/**
|
||||
* Invoked just before a Transport is started.
|
||||
*
|
||||
* @param Swift_Events_TransportChangeEvent $evt
|
||||
*/
|
||||
public function beforeTransportStarted(Swift_Events_TransportChangeEvent $evt)
|
||||
{
|
||||
@@ -91,8 +83,6 @@ class Swift_Plugins_LoggerPlugin implements Swift_Events_CommandListener, Swift_
|
||||
|
||||
/**
|
||||
* Invoked immediately after the Transport is started.
|
||||
*
|
||||
* @param Swift_Events_TransportChangeEvent $evt
|
||||
*/
|
||||
public function transportStarted(Swift_Events_TransportChangeEvent $evt)
|
||||
{
|
||||
@@ -102,8 +92,6 @@ class Swift_Plugins_LoggerPlugin implements Swift_Events_CommandListener, Swift_
|
||||
|
||||
/**
|
||||
* Invoked just before a Transport is stopped.
|
||||
*
|
||||
* @param Swift_Events_TransportChangeEvent $evt
|
||||
*/
|
||||
public function beforeTransportStopped(Swift_Events_TransportChangeEvent $evt)
|
||||
{
|
||||
@@ -113,8 +101,6 @@ class Swift_Plugins_LoggerPlugin implements Swift_Events_CommandListener, Swift_
|
||||
|
||||
/**
|
||||
* Invoked immediately after the Transport is stopped.
|
||||
*
|
||||
* @param Swift_Events_TransportChangeEvent $evt
|
||||
*/
|
||||
public function transportStopped(Swift_Events_TransportChangeEvent $evt)
|
||||
{
|
||||
@@ -124,8 +110,6 @@ class Swift_Plugins_LoggerPlugin implements Swift_Events_CommandListener, Swift_
|
||||
|
||||
/**
|
||||
* Invoked as a TransportException is thrown in the Transport system.
|
||||
*
|
||||
* @param Swift_Events_TransportExceptionEvent $evt
|
||||
*/
|
||||
public function exceptionThrown(Swift_Events_TransportExceptionEvent $evt)
|
||||
{
|
||||
|
||||
@@ -20,7 +20,7 @@ class Swift_Plugins_Loggers_ArrayLogger implements Swift_Plugins_Logger
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $log = array();
|
||||
private $log = [];
|
||||
|
||||
/**
|
||||
* Max size of the log.
|
||||
@@ -57,7 +57,7 @@ class Swift_Plugins_Loggers_ArrayLogger implements Swift_Plugins_Logger
|
||||
*/
|
||||
public function clear()
|
||||
{
|
||||
$this->log = array();
|
||||
$this->log = [];
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -22,7 +22,7 @@ class Swift_Plugins_MessageLogger implements Swift_Events_SendListener
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->messages = array();
|
||||
$this->messages = [];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -50,13 +50,11 @@ class Swift_Plugins_MessageLogger implements Swift_Events_SendListener
|
||||
*/
|
||||
public function clear()
|
||||
{
|
||||
$this->messages = array();
|
||||
$this->messages = [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoked immediately before the Message is sent.
|
||||
*
|
||||
* @param Swift_Events_SendEvent $evt
|
||||
*/
|
||||
public function beforeSendPerformed(Swift_Events_SendEvent $evt)
|
||||
{
|
||||
@@ -65,8 +63,6 @@ class Swift_Plugins_MessageLogger implements Swift_Events_SendListener
|
||||
|
||||
/**
|
||||
* Invoked immediately after the Message is sent.
|
||||
*
|
||||
* @param Swift_Events_SendEvent $evt
|
||||
*/
|
||||
public function sendPerformed(Swift_Events_SendEvent $evt)
|
||||
{
|
||||
|
||||
@@ -45,7 +45,8 @@ class Swift_Plugins_PopBeforeSmtpPlugin implements Swift_Events_TransportChangeL
|
||||
/**
|
||||
* Create a new PopBeforeSmtpPlugin for $host and $port.
|
||||
*
|
||||
* @param string $host
|
||||
* @param string $host Hostname or IP. Literal IPv6 addresses should be
|
||||
* wrapped in square brackets.
|
||||
* @param int $port
|
||||
* @param string $crypto as "tls" or "ssl"
|
||||
*/
|
||||
@@ -59,8 +60,6 @@ class Swift_Plugins_PopBeforeSmtpPlugin implements Swift_Events_TransportChangeL
|
||||
/**
|
||||
* Set a Pop3Connection to delegate to instead of connecting directly.
|
||||
*
|
||||
* @param Swift_Plugins_Pop_Pop3Connection $connection
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setConnection(Swift_Plugins_Pop_Pop3Connection $connection)
|
||||
@@ -72,8 +71,6 @@ class Swift_Plugins_PopBeforeSmtpPlugin implements Swift_Events_TransportChangeL
|
||||
|
||||
/**
|
||||
* Bind this plugin to a specific SMTP transport instance.
|
||||
*
|
||||
* @param Swift_Transport
|
||||
*/
|
||||
public function bindSmtp(Swift_Transport $smtp)
|
||||
{
|
||||
@@ -177,8 +174,6 @@ class Swift_Plugins_PopBeforeSmtpPlugin implements Swift_Events_TransportChangeL
|
||||
|
||||
/**
|
||||
* Invoked just before a Transport is started.
|
||||
*
|
||||
* @param Swift_Events_TransportChangeEvent $evt
|
||||
*/
|
||||
public function beforeTransportStarted(Swift_Events_TransportChangeEvent $evt)
|
||||
{
|
||||
@@ -234,7 +229,7 @@ class Swift_Plugins_PopBeforeSmtpPlugin implements Swift_Events_TransportChangeL
|
||||
|
||||
private function assertOk($response)
|
||||
{
|
||||
if (substr($response, 0, 3) != '+OK') {
|
||||
if ('+OK' != substr($response, 0, 3)) {
|
||||
throw new Swift_Plugins_Pop_Pop3Exception(
|
||||
sprintf('POP3 command failed [%s]', trim($response))
|
||||
);
|
||||
|
||||
@@ -27,15 +27,14 @@ class Swift_Plugins_RedirectingPlugin implements Swift_Events_SendListener
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $whitelist = array();
|
||||
private $whitelist = [];
|
||||
|
||||
/**
|
||||
* Create a new RedirectingPlugin.
|
||||
*
|
||||
* @param mixed $recipient
|
||||
* @param array $whitelist
|
||||
*/
|
||||
public function __construct($recipient, array $whitelist = array())
|
||||
public function __construct($recipient, array $whitelist = [])
|
||||
{
|
||||
$this->recipient = $recipient;
|
||||
$this->whitelist = $whitelist;
|
||||
@@ -63,8 +62,6 @@ class Swift_Plugins_RedirectingPlugin implements Swift_Events_SendListener
|
||||
|
||||
/**
|
||||
* Set a list of regular expressions to whitelist certain recipients.
|
||||
*
|
||||
* @param array $whitelist
|
||||
*/
|
||||
public function setWhitelist(array $whitelist)
|
||||
{
|
||||
@@ -83,8 +80,6 @@ class Swift_Plugins_RedirectingPlugin implements Swift_Events_SendListener
|
||||
|
||||
/**
|
||||
* Invoked immediately before the Message is sent.
|
||||
*
|
||||
* @param Swift_Events_SendEvent $evt
|
||||
*/
|
||||
public function beforeSendPerformed(Swift_Events_SendEvent $evt)
|
||||
{
|
||||
@@ -113,7 +108,7 @@ class Swift_Plugins_RedirectingPlugin implements Swift_Events_SendListener
|
||||
// Add each hard coded recipient
|
||||
$to = $message->getTo();
|
||||
if (null === $to) {
|
||||
$to = array();
|
||||
$to = [];
|
||||
}
|
||||
|
||||
foreach ((array) $this->recipient as $recipient) {
|
||||
@@ -126,8 +121,7 @@ class Swift_Plugins_RedirectingPlugin implements Swift_Events_SendListener
|
||||
/**
|
||||
* Filter header set against a whitelist of regular expressions.
|
||||
*
|
||||
* @param Swift_Mime_SimpleHeaderSet $headerSet
|
||||
* @param string $type
|
||||
* @param string $type
|
||||
*/
|
||||
private function filterHeaderSet(Swift_Mime_SimpleHeaderSet $headerSet, $type)
|
||||
{
|
||||
@@ -139,13 +133,11 @@ class Swift_Plugins_RedirectingPlugin implements Swift_Events_SendListener
|
||||
/**
|
||||
* Filtered list of addresses => name pairs.
|
||||
*
|
||||
* @param array $recipients
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function filterNameAddresses(array $recipients)
|
||||
{
|
||||
$filtered = array();
|
||||
$filtered = [];
|
||||
|
||||
foreach ($recipients as $address => $name) {
|
||||
if ($this->isWhitelisted($address)) {
|
||||
@@ -159,8 +151,6 @@ class Swift_Plugins_RedirectingPlugin implements Swift_Events_SendListener
|
||||
/**
|
||||
* Matches address against whitelist of regular expressions.
|
||||
*
|
||||
* @param $recipient
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function isWhitelisted($recipient)
|
||||
@@ -180,8 +170,6 @@ class Swift_Plugins_RedirectingPlugin implements Swift_Events_SendListener
|
||||
|
||||
/**
|
||||
* Invoked immediately after the Message is sent.
|
||||
*
|
||||
* @param Swift_Events_SendEvent $evt
|
||||
*/
|
||||
public function sendPerformed(Swift_Events_SendEvent $evt)
|
||||
{
|
||||
|
||||
@@ -24,8 +24,6 @@ class Swift_Plugins_ReporterPlugin implements Swift_Events_SendListener
|
||||
|
||||
/**
|
||||
* Create a new ReporterPlugin using $reporter.
|
||||
*
|
||||
* @param Swift_Plugins_Reporter $reporter
|
||||
*/
|
||||
public function __construct(Swift_Plugins_Reporter $reporter)
|
||||
{
|
||||
@@ -41,8 +39,6 @@ class Swift_Plugins_ReporterPlugin implements Swift_Events_SendListener
|
||||
|
||||
/**
|
||||
* Invoked immediately after the Message is sent.
|
||||
*
|
||||
* @param Swift_Events_SendEvent $evt
|
||||
*/
|
||||
public function sendPerformed(Swift_Events_SendEvent $evt)
|
||||
{
|
||||
|
||||
@@ -20,16 +20,15 @@ class Swift_Plugins_Reporters_HitReporter implements Swift_Plugins_Reporter
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $failures = array();
|
||||
private $failures = [];
|
||||
|
||||
private $failures_cache = array();
|
||||
private $failures_cache = [];
|
||||
|
||||
/**
|
||||
* Notifies this ReportNotifier that $address failed or succeeded.
|
||||
*
|
||||
* @param Swift_Mime_SimpleMessage $message
|
||||
* @param string $address
|
||||
* @param int $result from {@link RESULT_PASS, RESULT_FAIL}
|
||||
* @param string $address
|
||||
* @param int $result from {@link RESULT_PASS, RESULT_FAIL}
|
||||
*/
|
||||
public function notify(Swift_Mime_SimpleMessage $message, $address, $result)
|
||||
{
|
||||
@@ -54,6 +53,6 @@ class Swift_Plugins_Reporters_HitReporter implements Swift_Plugins_Reporter
|
||||
*/
|
||||
public function clear()
|
||||
{
|
||||
$this->failures = $this->failures_cache = array();
|
||||
$this->failures = $this->failures_cache = [];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,9 +18,8 @@ class Swift_Plugins_Reporters_HtmlReporter implements Swift_Plugins_Reporter
|
||||
/**
|
||||
* Notifies this ReportNotifier that $address failed or succeeded.
|
||||
*
|
||||
* @param Swift_Mime_SimpleMessage $message
|
||||
* @param string $address
|
||||
* @param int $result from {@see RESULT_PASS, RESULT_FAIL}
|
||||
* @param string $address
|
||||
* @param int $result from {@see RESULT_PASS, RESULT_FAIL}
|
||||
*/
|
||||
public function notify(Swift_Mime_SimpleMessage $message, $address, $result)
|
||||
{
|
||||
|
||||
@@ -72,7 +72,7 @@ class Swift_Plugins_ThrottlerPlugin extends Swift_Plugins_BandwidthMonitorPlugin
|
||||
* Create a new ThrottlerPlugin.
|
||||
*
|
||||
* @param int $rate
|
||||
* @param int $mode, defaults to {@link BYTES_PER_MINUTE}
|
||||
* @param int $mode defaults to {@link BYTES_PER_MINUTE}
|
||||
* @param Swift_Plugins_Sleeper $sleeper (only needed in testing)
|
||||
* @param Swift_Plugins_Timer $timer (only needed in testing)
|
||||
*/
|
||||
@@ -86,8 +86,6 @@ class Swift_Plugins_ThrottlerPlugin extends Swift_Plugins_BandwidthMonitorPlugin
|
||||
|
||||
/**
|
||||
* Invoked immediately before the Message is sent.
|
||||
*
|
||||
* @param Swift_Events_SendEvent $evt
|
||||
*/
|
||||
public function beforeSendPerformed(Swift_Events_SendEvent $evt)
|
||||
{
|
||||
@@ -119,8 +117,6 @@ class Swift_Plugins_ThrottlerPlugin extends Swift_Plugins_BandwidthMonitorPlugin
|
||||
|
||||
/**
|
||||
* Invoked when a Message is sent.
|
||||
*
|
||||
* @param Swift_Events_SendEvent $evt
|
||||
*/
|
||||
public function sendPerformed(Swift_Events_SendEvent $evt)
|
||||
{
|
||||
|
||||
@@ -92,7 +92,7 @@ class Swift_Preferences
|
||||
Swift_DependencyContainer::getInstance()
|
||||
->register('mime.qpcontentencoder')
|
||||
->asNewInstanceOf('Swift_Mime_ContentEncoder_QpContentEncoder')
|
||||
->withDependencies(array('mime.charstream', 'mime.bytecanonicalizer'))
|
||||
->withDependencies(['mime.charstream', 'mime.bytecanonicalizer'])
|
||||
->addConstructorValue($dotEscape);
|
||||
|
||||
return $this;
|
||||
|
||||
@@ -23,7 +23,7 @@ class Swift_SendmailTransport extends Swift_Transport_SendmailTransport
|
||||
public function __construct($command = '/usr/sbin/sendmail -bs')
|
||||
{
|
||||
call_user_func_array(
|
||||
array($this, 'Swift_Transport_SendmailTransport::__construct'),
|
||||
[$this, 'Swift_Transport_SendmailTransport::__construct'],
|
||||
Swift_DependencyContainer::getInstance()
|
||||
->createDependenciesFor('transport.sendmail')
|
||||
);
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
/**
|
||||
* Base Class of Signer Infrastructure.
|
||||
*
|
||||
*
|
||||
* @author Xavier De Cock <xdecock@gmail.com>
|
||||
*/
|
||||
interface Swift_Signer
|
||||
|
||||
@@ -66,7 +66,7 @@ class Swift_Signers_DKIMSigner implements Swift_Signers_HeaderSigner
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $ignoredHeaders = array('return-path' => true);
|
||||
protected $ignoredHeaders = ['return-path' => true];
|
||||
|
||||
/**
|
||||
* Signer identity.
|
||||
@@ -124,7 +124,7 @@ class Swift_Signers_DKIMSigner implements Swift_Signers_HeaderSigner
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $signedHeaders = array();
|
||||
protected $signedHeaders = [];
|
||||
|
||||
/**
|
||||
* If debugHeaders is set store debugData here.
|
||||
@@ -163,7 +163,7 @@ class Swift_Signers_DKIMSigner implements Swift_Signers_HeaderSigner
|
||||
|
||||
private $bodyCanonLine = '';
|
||||
|
||||
private $bound = array();
|
||||
private $bound = [];
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
@@ -190,7 +190,7 @@ class Swift_Signers_DKIMSigner implements Swift_Signers_HeaderSigner
|
||||
public function reset()
|
||||
{
|
||||
$this->headerHash = null;
|
||||
$this->signedHeaders = array();
|
||||
$this->signedHeaders = [];
|
||||
$this->bodyHash = null;
|
||||
$this->bodyHashHandler = null;
|
||||
$this->bodyCanonIgnoreStart = 2;
|
||||
@@ -236,10 +236,9 @@ class Swift_Signers_DKIMSigner implements Swift_Signers_HeaderSigner
|
||||
|
||||
/**
|
||||
* Attach $is to this stream.
|
||||
*
|
||||
* The stream acts as an observer, receiving all data that is written.
|
||||
* All {@link write()} and {@link flushBuffers()} operations will be mirrored.
|
||||
*
|
||||
* @param Swift_InputByteStream $is
|
||||
*/
|
||||
public function bind(Swift_InputByteStream $is)
|
||||
{
|
||||
@@ -251,11 +250,10 @@ class Swift_Signers_DKIMSigner implements Swift_Signers_HeaderSigner
|
||||
|
||||
/**
|
||||
* Remove an already bound stream.
|
||||
*
|
||||
* If $is is not bound, no errors will be raised.
|
||||
* If the stream currently has any buffered data it will be written to $is
|
||||
* before unbinding occurs.
|
||||
*
|
||||
* @param Swift_InputByteStream $is
|
||||
*/
|
||||
public function unbind(Swift_InputByteStream $is)
|
||||
{
|
||||
@@ -317,7 +315,7 @@ class Swift_Signers_DKIMSigner implements Swift_Signers_HeaderSigner
|
||||
*/
|
||||
public function setBodyCanon($canon)
|
||||
{
|
||||
if ($canon == 'relaxed') {
|
||||
if ('relaxed' == $canon) {
|
||||
$this->bodyCanon = 'relaxed';
|
||||
} else {
|
||||
$this->bodyCanon = 'simple';
|
||||
@@ -335,7 +333,7 @@ class Swift_Signers_DKIMSigner implements Swift_Signers_HeaderSigner
|
||||
*/
|
||||
public function setHeaderCanon($canon)
|
||||
{
|
||||
if ($canon == 'relaxed') {
|
||||
if ('relaxed' == $canon) {
|
||||
$this->headerCanon = 'relaxed';
|
||||
} else {
|
||||
$this->headerCanon = 'simple';
|
||||
@@ -367,10 +365,10 @@ class Swift_Signers_DKIMSigner implements Swift_Signers_HeaderSigner
|
||||
*/
|
||||
public function setBodySignedLen($len)
|
||||
{
|
||||
if ($len === true) {
|
||||
if (true === $len) {
|
||||
$this->showLen = true;
|
||||
$this->maxLen = PHP_INT_MAX;
|
||||
} elseif ($len === false) {
|
||||
} elseif (false === $len) {
|
||||
$this->showLen = false;
|
||||
$this->maxLen = PHP_INT_MAX;
|
||||
} else {
|
||||
@@ -456,9 +454,9 @@ class Swift_Signers_DKIMSigner implements Swift_Signers_HeaderSigner
|
||||
public function getAlteredHeaders()
|
||||
{
|
||||
if ($this->debugHeaders) {
|
||||
return array('DKIM-Signature', 'X-DebugHash');
|
||||
return ['DKIM-Signature', 'X-DebugHash'];
|
||||
} else {
|
||||
return array('DKIM-Signature');
|
||||
return ['DKIM-Signature'];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -479,8 +477,6 @@ class Swift_Signers_DKIMSigner implements Swift_Signers_HeaderSigner
|
||||
/**
|
||||
* Set the headers to sign.
|
||||
*
|
||||
* @param Swift_Mime_SimpleHeaderSet $headers
|
||||
*
|
||||
* @return Swift_Signers_DKIMSigner
|
||||
*/
|
||||
public function setHeaders(Swift_Mime_SimpleHeaderSet $headers)
|
||||
@@ -494,7 +490,7 @@ class Swift_Signers_DKIMSigner implements Swift_Signers_HeaderSigner
|
||||
if ($headers->has($hName)) {
|
||||
$tmp = $headers->getAll($hName);
|
||||
foreach ($tmp as $header) {
|
||||
if ($header->getFieldBody() != '') {
|
||||
if ('' != $header->getFieldBody()) {
|
||||
$this->addHeader($header->toString());
|
||||
$this->signedHeaders[] = $header->getFieldName();
|
||||
}
|
||||
@@ -509,32 +505,30 @@ class Swift_Signers_DKIMSigner implements Swift_Signers_HeaderSigner
|
||||
/**
|
||||
* Add the signature to the given Headers.
|
||||
*
|
||||
* @param Swift_Mime_SimpleHeaderSet $headers
|
||||
*
|
||||
* @return Swift_Signers_DKIMSigner
|
||||
*/
|
||||
public function addSignature(Swift_Mime_SimpleHeaderSet $headers)
|
||||
{
|
||||
// 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 = ['v' => '1', 'a' => $this->hashAlgorithm, 'bh' => base64_encode($this->bodyHash), 'd' => $this->domainName, 'h' => implode(': ', $this->signedHeaders), 'i' => $this->signerIdentity, 's' => $this->selector];
|
||||
if ('simple' != $this->bodyCanon) {
|
||||
$params['c'] = $this->headerCanon.'/'.$this->bodyCanon;
|
||||
} elseif ($this->headerCanon != 'simple') {
|
||||
} elseif ('simple' != $this->headerCanon) {
|
||||
$params['c'] = $this->headerCanon;
|
||||
}
|
||||
if ($this->showLen) {
|
||||
$params['l'] = $this->bodyLen;
|
||||
}
|
||||
if ($this->signatureTimestamp === true) {
|
||||
if (true === $this->signatureTimestamp) {
|
||||
$params['t'] = time();
|
||||
if ($this->signatureExpiration !== false) {
|
||||
if (false !== $this->signatureExpiration) {
|
||||
$params['x'] = $params['t'] + $this->signatureExpiration;
|
||||
}
|
||||
} else {
|
||||
if ($this->signatureTimestamp !== false) {
|
||||
if (false !== $this->signatureTimestamp) {
|
||||
$params['t'] = $this->signatureTimestamp;
|
||||
}
|
||||
if ($this->signatureExpiration !== false) {
|
||||
if (false !== $this->signatureExpiration) {
|
||||
$params['x'] = $this->signatureExpiration;
|
||||
}
|
||||
}
|
||||
@@ -571,6 +565,7 @@ class Swift_Signers_DKIMSigner implements Swift_Signers_HeaderSigner
|
||||
$value = str_replace("\r\n", '', $exploded[1]);
|
||||
$value = preg_replace("/[ \t][ \t]+/", ' ', $value);
|
||||
$header = $name.':'.trim($value).($is_sig ? '' : "\r\n");
|
||||
// no break
|
||||
case 'simple':
|
||||
// Nothing to do
|
||||
}
|
||||
@@ -581,7 +576,7 @@ class Swift_Signers_DKIMSigner implements Swift_Signers_HeaderSigner
|
||||
{
|
||||
$len = strlen($string);
|
||||
$canon = '';
|
||||
$method = ($this->bodyCanon == 'relaxed');
|
||||
$method = ('relaxed' == $this->bodyCanon);
|
||||
for ($i = 0; $i < $len; ++$i) {
|
||||
if ($this->bodyCanonIgnoreStart > 0) {
|
||||
--$this->bodyCanonIgnoreStart;
|
||||
@@ -592,11 +587,11 @@ class Swift_Signers_DKIMSigner implements Swift_Signers_HeaderSigner
|
||||
$this->bodyCanonLastChar = "\r";
|
||||
break;
|
||||
case "\n":
|
||||
if ($this->bodyCanonLastChar == "\r") {
|
||||
if ("\r" == $this->bodyCanonLastChar) {
|
||||
if ($method) {
|
||||
$this->bodyCanonSpace = false;
|
||||
}
|
||||
if ($this->bodyCanonLine == '') {
|
||||
if ('' == $this->bodyCanonLine) {
|
||||
++$this->bodyCanonEmptyCounter;
|
||||
} else {
|
||||
$this->bodyCanonLine = '';
|
||||
@@ -613,6 +608,7 @@ class Swift_Signers_DKIMSigner implements Swift_Signers_HeaderSigner
|
||||
$this->bodyCanonSpace = true;
|
||||
break;
|
||||
}
|
||||
// no break
|
||||
default:
|
||||
if ($this->bodyCanonEmptyCounter > 0) {
|
||||
$canon .= str_repeat("\r\n", $this->bodyCanonEmptyCounter);
|
||||
|
||||
@@ -55,7 +55,7 @@ class Swift_Signers_DomainKeySigner implements Swift_Signers_HeaderSigner
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $ignoredHeaders = array();
|
||||
protected $ignoredHeaders = [];
|
||||
|
||||
/**
|
||||
* Signer identity.
|
||||
@@ -77,7 +77,7 @@ class Swift_Signers_DomainKeySigner implements Swift_Signers_HeaderSigner
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $signedHeaders = array();
|
||||
private $signedHeaders = [];
|
||||
|
||||
/**
|
||||
* Stores the signature header.
|
||||
@@ -93,8 +93,6 @@ class Swift_Signers_DomainKeySigner implements Swift_Signers_HeaderSigner
|
||||
*/
|
||||
private $hashHandler;
|
||||
|
||||
private $hash;
|
||||
|
||||
private $canonData = '';
|
||||
|
||||
private $bodyCanonEmptyCounter = 0;
|
||||
@@ -107,7 +105,7 @@ class Swift_Signers_DomainKeySigner implements Swift_Signers_HeaderSigner
|
||||
|
||||
private $bodyCanonLine = '';
|
||||
|
||||
private $bound = array();
|
||||
private $bound = [];
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
@@ -131,7 +129,6 @@ class Swift_Signers_DomainKeySigner implements Swift_Signers_HeaderSigner
|
||||
*/
|
||||
public function reset()
|
||||
{
|
||||
$this->hash = null;
|
||||
$this->hashHandler = null;
|
||||
$this->bodyCanonIgnoreStart = 2;
|
||||
$this->bodyCanonEmptyCounter = 0;
|
||||
@@ -185,11 +182,10 @@ class Swift_Signers_DomainKeySigner implements Swift_Signers_HeaderSigner
|
||||
|
||||
/**
|
||||
* Attach $is to this stream.
|
||||
*
|
||||
* The stream acts as an observer, receiving all data that is written.
|
||||
* All {@link write()} and {@link flushBuffers()} operations will be mirrored.
|
||||
*
|
||||
* @param Swift_InputByteStream $is
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function bind(Swift_InputByteStream $is)
|
||||
@@ -202,12 +198,11 @@ class Swift_Signers_DomainKeySigner implements Swift_Signers_HeaderSigner
|
||||
|
||||
/**
|
||||
* Remove an already bound stream.
|
||||
*
|
||||
* If $is is not bound, no errors will be raised.
|
||||
* If the stream currently has any buffered data it will be written to $is
|
||||
* before unbinding occurs.
|
||||
*
|
||||
* @param Swift_InputByteStream $is
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function unbind(Swift_InputByteStream $is)
|
||||
@@ -262,7 +257,7 @@ class Swift_Signers_DomainKeySigner implements Swift_Signers_HeaderSigner
|
||||
*/
|
||||
public function setCanon($canon)
|
||||
{
|
||||
if ($canon == 'nofws') {
|
||||
if ('nofws' == $canon) {
|
||||
$this->canon = 'nofws';
|
||||
} else {
|
||||
$this->canon = 'simple';
|
||||
@@ -322,10 +317,10 @@ class Swift_Signers_DomainKeySigner implements Swift_Signers_HeaderSigner
|
||||
public function getAlteredHeaders()
|
||||
{
|
||||
if ($this->debugHeaders) {
|
||||
return array('DomainKey-Signature', 'X-DebugHash');
|
||||
return ['DomainKey-Signature', 'X-DebugHash'];
|
||||
}
|
||||
|
||||
return array('DomainKey-Signature');
|
||||
return ['DomainKey-Signature'];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -345,8 +340,6 @@ class Swift_Signers_DomainKeySigner implements Swift_Signers_HeaderSigner
|
||||
/**
|
||||
* Set the headers to sign.
|
||||
*
|
||||
* @param Swift_Mime_SimpleHeaderSet $headers
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setHeaders(Swift_Mime_SimpleHeaderSet $headers)
|
||||
@@ -361,7 +354,7 @@ class Swift_Signers_DomainKeySigner implements Swift_Signers_HeaderSigner
|
||||
if ($headers->has($hName)) {
|
||||
$tmp = $headers->getAll($hName);
|
||||
foreach ($tmp as $header) {
|
||||
if ($header->getFieldBody() != '') {
|
||||
if ('' != $header->getFieldBody()) {
|
||||
$this->addHeader($header->toString());
|
||||
$this->signedHeaders[] = $header->getFieldName();
|
||||
}
|
||||
@@ -377,14 +370,12 @@ class Swift_Signers_DomainKeySigner implements Swift_Signers_HeaderSigner
|
||||
/**
|
||||
* Add the signature to the given Headers.
|
||||
*
|
||||
* @param Swift_Mime_SimpleHeaderSet $headers
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function addSignature(Swift_Mime_SimpleHeaderSet $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 = ['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.'; ';
|
||||
@@ -407,6 +398,7 @@ class Swift_Signers_DomainKeySigner implements Swift_Signers_HeaderSigner
|
||||
$value = str_replace("\r\n", '', $exploded[1]);
|
||||
$value = preg_replace("/[ \t][ \t]+/", ' ', $value);
|
||||
$header = $name.':'.trim($value)."\r\n";
|
||||
// no break
|
||||
case 'simple':
|
||||
// Nothing to do
|
||||
}
|
||||
@@ -422,7 +414,7 @@ class Swift_Signers_DomainKeySigner implements Swift_Signers_HeaderSigner
|
||||
{
|
||||
$len = strlen($string);
|
||||
$canon = '';
|
||||
$nofws = ($this->canon == 'nofws');
|
||||
$nofws = ('nofws' == $this->canon);
|
||||
for ($i = 0; $i < $len; ++$i) {
|
||||
if ($this->bodyCanonIgnoreStart > 0) {
|
||||
--$this->bodyCanonIgnoreStart;
|
||||
@@ -433,11 +425,11 @@ class Swift_Signers_DomainKeySigner implements Swift_Signers_HeaderSigner
|
||||
$this->bodyCanonLastChar = "\r";
|
||||
break;
|
||||
case "\n":
|
||||
if ($this->bodyCanonLastChar == "\r") {
|
||||
if ("\r" == $this->bodyCanonLastChar) {
|
||||
if ($nofws) {
|
||||
$this->bodyCanonSpace = false;
|
||||
}
|
||||
if ($this->bodyCanonLine == '') {
|
||||
if ('' == $this->bodyCanonLine) {
|
||||
++$this->bodyCanonEmptyCounter;
|
||||
} else {
|
||||
$this->bodyCanonLine = '';
|
||||
@@ -455,6 +447,7 @@ class Swift_Signers_DomainKeySigner implements Swift_Signers_HeaderSigner
|
||||
$this->bodyCanonSpace = true;
|
||||
break;
|
||||
}
|
||||
// no break
|
||||
default:
|
||||
if ($this->bodyCanonEmptyCounter > 0) {
|
||||
$canon .= str_repeat("\r\n", $this->bodyCanonEmptyCounter);
|
||||
@@ -472,7 +465,6 @@ class Swift_Signers_DomainKeySigner implements Swift_Signers_HeaderSigner
|
||||
if (strlen($this->bodyCanonLine) > 0) {
|
||||
$this->addToHash("\r\n");
|
||||
}
|
||||
$this->hash = hash_final($this->hashHandler, true);
|
||||
}
|
||||
|
||||
private function addToHash($string)
|
||||
|
||||
@@ -13,6 +13,8 @@
|
||||
* Takes advantage of pecl extension.
|
||||
*
|
||||
* @author Xavier De Cock <xdecock@gmail.com>
|
||||
*
|
||||
* @deprecated since SwiftMailer 6.1.0; use Swift_Signers_DKIMSigner instead.
|
||||
*/
|
||||
class Swift_Signers_OpenDKIMSigner extends Swift_Signers_DKIMSigner
|
||||
{
|
||||
@@ -42,7 +44,7 @@ class Swift_Signers_OpenDKIMSigner extends Swift_Signers_DKIMSigner
|
||||
{
|
||||
$header = new Swift_Mime_Headers_OpenDKIMHeader('DKIM-Signature');
|
||||
$headerVal = $this->dkimHandler->getSignatureHeader();
|
||||
if (!$headerVal) {
|
||||
if (false === $headerVal || is_int($headerVal)) {
|
||||
throw new Swift_SwiftException('OpenDKIM Error: '.$this->dkimHandler->getError());
|
||||
}
|
||||
$header->setValue($headerVal);
|
||||
@@ -53,14 +55,10 @@ class Swift_Signers_OpenDKIMSigner extends Swift_Signers_DKIMSigner
|
||||
|
||||
public function setHeaders(Swift_Mime_SimpleHeaderSet $headers)
|
||||
{
|
||||
$bodyLen = $this->bodyLen;
|
||||
if (is_bool($bodyLen)) {
|
||||
$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;
|
||||
$this->dkimHandler = new OpenDKIMSign($this->privateKey, $this->selector, $this->domainName, $headerCanon, $bodyCanon, $hash, $bodyLen);
|
||||
$hash = 'rsa-sha1' == $this->hashAlgorithm ? OpenDKIMSign::ALG_RSASHA1 : OpenDKIMSign::ALG_RSASHA256;
|
||||
$bodyCanon = 'simple' == $this->bodyCanon ? OpenDKIMSign::CANON_SIMPLE : OpenDKIMSign::CANON_RELAXED;
|
||||
$headerCanon = 'simple' == $this->headerCanon ? OpenDKIMSign::CANON_SIMPLE : OpenDKIMSign::CANON_RELAXED;
|
||||
$this->dkimHandler = new OpenDKIMSign($this->privateKey, $this->selector, $this->domainName, $headerCanon, $bodyCanon, $hash, -1);
|
||||
// Hardcode signature Margin for now
|
||||
$this->dkimHandler->setMargin(78);
|
||||
|
||||
@@ -81,7 +79,7 @@ class Swift_Signers_OpenDKIMSigner extends Swift_Signers_DKIMSigner
|
||||
$tmp = $headers->getAll($hName);
|
||||
if ($headers->has($hName)) {
|
||||
foreach ($tmp as $header) {
|
||||
if ($header->getFieldBody() != '') {
|
||||
if ('' != $header->getFieldBody()) {
|
||||
$htosign = $header->toString();
|
||||
$this->dkimHandler->header($htosign);
|
||||
$this->signedHeaders[] = $header->getFieldName();
|
||||
@@ -172,8 +170,8 @@ class Swift_Signers_OpenDKIMSigner extends Swift_Signers_DKIMSigner
|
||||
if (!$this->peclLoaded) {
|
||||
return parent::canonicalizeBody($string);
|
||||
}
|
||||
if (false && $this->dropFirstLF === true) {
|
||||
if ($string[0] == "\r" && $string[1] == "\n") {
|
||||
if (true === $this->dropFirstLF) {
|
||||
if ("\r" == $string[0] && "\n" == $string[1]) {
|
||||
$string = substr($string, 2);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,9 +11,9 @@
|
||||
/**
|
||||
* MIME Message Signer used to apply S/MIME Signature/Encryption to a message.
|
||||
*
|
||||
*
|
||||
* @author Romain-Geissler
|
||||
* @author Sebastiaan Stok <s.stok@rollerscapes.net>
|
||||
* @author Jan Flora <jf@penneo.com>
|
||||
*/
|
||||
class Swift_Signers_SMimeSigner implements Swift_Signers_BodySigner
|
||||
{
|
||||
@@ -27,6 +27,7 @@ class Swift_Signers_SMimeSigner implements Swift_Signers_BodySigner
|
||||
protected $encryptOptions;
|
||||
protected $encryptCipher;
|
||||
protected $extraCerts = null;
|
||||
protected $wrapFullMessage = false;
|
||||
|
||||
/**
|
||||
* @var Swift_StreamFilters_StringReplacementFilterFactory
|
||||
@@ -65,7 +66,7 @@ class Swift_Signers_SMimeSigner implements Swift_Signers_BodySigner
|
||||
/**
|
||||
* Set the certificate location to use for signing.
|
||||
*
|
||||
* @see http://www.php.net/manual/en/openssl.pkcs7.flags.php
|
||||
* @see https://secure.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
|
||||
@@ -88,9 +89,7 @@ class Swift_Signers_SMimeSigner implements Swift_Signers_BodySigner
|
||||
}
|
||||
|
||||
$this->signOptions = $signOptions;
|
||||
if (null !== $extraCerts) {
|
||||
$this->extraCerts = str_replace('\\', '/', realpath($extraCerts));
|
||||
}
|
||||
$this->extraCerts = $extraCerts ? realpath($extraCerts) : null;
|
||||
|
||||
return $this;
|
||||
}
|
||||
@@ -98,8 +97,8 @@ class Swift_Signers_SMimeSigner implements Swift_Signers_BodySigner
|
||||
/**
|
||||
* Set the certificate location to use for encryption.
|
||||
*
|
||||
* @see http://www.php.net/manual/en/openssl.pkcs7.flags.php
|
||||
* @see http://nl3.php.net/manual/en/openssl.ciphers.php
|
||||
* @see https://secure.php.net/manual/en/openssl.pkcs7.flags.php
|
||||
* @see https://secure.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
|
||||
@@ -109,7 +108,7 @@ class Swift_Signers_SMimeSigner implements Swift_Signers_BodySigner
|
||||
public function setEncryptCertificate($recipientCerts, $cipher = null)
|
||||
{
|
||||
if (is_array($recipientCerts)) {
|
||||
$this->encryptCert = array();
|
||||
$this->encryptCert = [];
|
||||
|
||||
foreach ($recipientCerts as $cert) {
|
||||
$this->encryptCert[] = 'file://'.str_replace('\\', '/', realpath($cert));
|
||||
@@ -178,9 +177,27 @@ class Swift_Signers_SMimeSigner implements Swift_Signers_BodySigner
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the Swift_Message to apply the signing.
|
||||
* Specify whether to wrap the entire MIME message in the S/MIME message.
|
||||
*
|
||||
* @param Swift_Message $message
|
||||
* According to RFC5751 section 3.1:
|
||||
* In order to protect outer, non-content-related message header fields
|
||||
* (for instance, the "Subject", "To", "From", and "Cc" fields), the
|
||||
* sending client MAY wrap a full MIME message in a message/rfc822
|
||||
* wrapper in order to apply S/MIME security services to these header
|
||||
* fields. It is up to the receiving client to decide how to present
|
||||
* this "inner" header along with the unprotected "outer" header.
|
||||
*
|
||||
* @param bool $wrap
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setWrapFullMessage($wrap)
|
||||
{
|
||||
$this->wrapFullMessage = $wrap;
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the Swift_Message to apply the signing.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
@@ -190,17 +207,13 @@ class Swift_Signers_SMimeSigner implements Swift_Signers_BodySigner
|
||||
return $this;
|
||||
}
|
||||
|
||||
// Store the message using ByteStream to a file{1}
|
||||
// Remove all Children
|
||||
// Sign file{1}, parse the new MIME headers and set them on the primary MimeEntity
|
||||
// Set the singed-body as the new body (without boundary)
|
||||
|
||||
$messageStream = new Swift_ByteStream_TemporaryFileByteStream();
|
||||
$this->toSMimeByteStream($messageStream, $message);
|
||||
$message->setEncoder(Swift_DependencyContainer::getInstance()->lookup('mime.rawcontentencoder'));
|
||||
|
||||
$message->setChildren(array());
|
||||
$this->streamToMime($messageStream, $message);
|
||||
if ($this->signThenEncrypt) {
|
||||
$this->smimeSignMessage($message);
|
||||
$this->smimeEncryptMessage($message);
|
||||
} else {
|
||||
$this->smimeEncryptMessage($message);
|
||||
$this->smimeSignMessage($message);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -210,102 +223,303 @@ class Swift_Signers_SMimeSigner implements Swift_Signers_BodySigner
|
||||
*/
|
||||
public function getAlteredHeaders()
|
||||
{
|
||||
return array('Content-Type', 'Content-Transfer-Encoding', 'Content-Disposition');
|
||||
return ['Content-Type', 'Content-Transfer-Encoding', 'Content-Disposition'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Swift_InputByteStream $inputStream
|
||||
* @param Swift_Message $mimeEntity
|
||||
* Sign a Swift message.
|
||||
*/
|
||||
protected function toSMimeByteStream(Swift_InputByteStream $inputStream, Swift_Message $message)
|
||||
protected function smimeSignMessage(Swift_Message $message)
|
||||
{
|
||||
$mimeEntity = $this->createMessage($message);
|
||||
$messageStream = new Swift_ByteStream_TemporaryFileByteStream();
|
||||
|
||||
$mimeEntity->toByteStream($messageStream);
|
||||
$messageStream->commit();
|
||||
|
||||
if (null !== $this->signCertificate && null !== $this->encryptCert) {
|
||||
$temporaryStream = new Swift_ByteStream_TemporaryFileByteStream();
|
||||
|
||||
if ($this->signThenEncrypt) {
|
||||
$this->messageStreamToSignedByteStream($messageStream, $temporaryStream);
|
||||
$this->messageStreamToEncryptedByteStream($temporaryStream, $inputStream);
|
||||
} else {
|
||||
$this->messageStreamToEncryptedByteStream($messageStream, $temporaryStream);
|
||||
$this->messageStreamToSignedByteStream($temporaryStream, $inputStream);
|
||||
}
|
||||
} elseif ($this->signCertificate !== null) {
|
||||
$this->messageStreamToSignedByteStream($messageStream, $inputStream);
|
||||
} else {
|
||||
$this->messageStreamToEncryptedByteStream($messageStream, $inputStream);
|
||||
// If we don't have a certificate we can't sign the message
|
||||
if (null === $this->signCertificate) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Swift_Message $message
|
||||
*
|
||||
* @return Swift_Message
|
||||
*/
|
||||
protected function createMessage(Swift_Message $message)
|
||||
{
|
||||
$mimeEntity = new Swift_Message('', $message->getBody(), $message->getContentType(), $message->getCharset());
|
||||
$mimeEntity->setChildren($message->getChildren());
|
||||
// Work on a clone of the original message
|
||||
$signMessage = clone $message;
|
||||
$signMessage->clearSigners();
|
||||
|
||||
$messageHeaders = $mimeEntity->getHeaders();
|
||||
$messageHeaders->remove('Message-ID');
|
||||
$messageHeaders->remove('Date');
|
||||
$messageHeaders->remove('Subject');
|
||||
$messageHeaders->remove('MIME-Version');
|
||||
$messageHeaders->remove('To');
|
||||
$messageHeaders->remove('From');
|
||||
if ($this->wrapFullMessage) {
|
||||
// The original message essentially becomes the body of the new
|
||||
// wrapped message
|
||||
$signMessage = $this->wrapMimeMessage($signMessage);
|
||||
} else {
|
||||
// Only keep header needed to parse the body correctly
|
||||
$this->clearAllHeaders($signMessage);
|
||||
$this->copyHeaders(
|
||||
$message,
|
||||
$signMessage,
|
||||
[
|
||||
'Content-Type',
|
||||
'Content-Transfer-Encoding',
|
||||
'Content-Disposition',
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
return $mimeEntity;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Swift_FileStream $outputStream
|
||||
* @param Swift_InputByteStream $inputStream
|
||||
*
|
||||
* @throws Swift_IoException
|
||||
*/
|
||||
protected function messageStreamToSignedByteStream(Swift_FileStream $outputStream, Swift_InputByteStream $inputStream)
|
||||
{
|
||||
// Copy the cloned message into a temporary file stream
|
||||
$messageStream = new Swift_ByteStream_TemporaryFileByteStream();
|
||||
$signMessage->toByteStream($messageStream);
|
||||
$messageStream->commit();
|
||||
$signedMessageStream = new Swift_ByteStream_TemporaryFileByteStream();
|
||||
|
||||
$args = array($outputStream->getPath(), $signedMessageStream->getPath(), $this->signCertificate, $this->signPrivateKey, array(), $this->signOptions);
|
||||
if (null !== $this->extraCerts) {
|
||||
$args[] = $this->extraCerts;
|
||||
}
|
||||
|
||||
if (!openssl_pkcs7_sign(...$args)) {
|
||||
// Sign the message using openssl
|
||||
if (!openssl_pkcs7_sign(
|
||||
$messageStream->getPath(),
|
||||
$signedMessageStream->getPath(),
|
||||
$this->signCertificate,
|
||||
$this->signPrivateKey,
|
||||
[],
|
||||
$this->signOptions,
|
||||
$this->extraCerts
|
||||
)
|
||||
) {
|
||||
throw new Swift_IoException(sprintf('Failed to sign S/Mime message. Error: "%s".', openssl_error_string()));
|
||||
}
|
||||
|
||||
$this->copyFromOpenSSLOutput($signedMessageStream, $inputStream);
|
||||
// Parse the resulting signed message content back into the Swift message
|
||||
// preserving the original headers
|
||||
$this->parseSSLOutput($signedMessageStream, $message);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Swift_FileStream $outputStream
|
||||
* @param Swift_InputByteStream $is
|
||||
*
|
||||
* @throws Swift_IoException
|
||||
* Encrypt a Swift message.
|
||||
*/
|
||||
protected function messageStreamToEncryptedByteStream(Swift_FileStream $outputStream, Swift_InputByteStream $is)
|
||||
protected function smimeEncryptMessage(Swift_Message $message)
|
||||
{
|
||||
// If we don't have a certificate we can't encrypt the message
|
||||
if (null === $this->encryptCert) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Work on a clone of the original message
|
||||
$encryptMessage = clone $message;
|
||||
$encryptMessage->clearSigners();
|
||||
|
||||
if ($this->wrapFullMessage) {
|
||||
// The original message essentially becomes the body of the new
|
||||
// wrapped message
|
||||
$encryptMessage = $this->wrapMimeMessage($encryptMessage);
|
||||
} else {
|
||||
// Only keep header needed to parse the body correctly
|
||||
$this->clearAllHeaders($encryptMessage);
|
||||
$this->copyHeaders(
|
||||
$message,
|
||||
$encryptMessage,
|
||||
[
|
||||
'Content-Type',
|
||||
'Content-Transfer-Encoding',
|
||||
'Content-Disposition',
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
// Convert the message content (including headers) to a string
|
||||
// and place it in a temporary file
|
||||
$messageStream = new Swift_ByteStream_TemporaryFileByteStream();
|
||||
$encryptMessage->toByteStream($messageStream);
|
||||
$messageStream->commit();
|
||||
$encryptedMessageStream = new Swift_ByteStream_TemporaryFileByteStream();
|
||||
|
||||
if (!openssl_pkcs7_encrypt($outputStream->getPath(), $encryptedMessageStream->getPath(), $this->encryptCert, array(), 0, $this->encryptCipher)) {
|
||||
// Encrypt the message
|
||||
if (!openssl_pkcs7_encrypt(
|
||||
$messageStream->getPath(),
|
||||
$encryptedMessageStream->getPath(),
|
||||
$this->encryptCert,
|
||||
[],
|
||||
0,
|
||||
$this->encryptCipher
|
||||
)
|
||||
) {
|
||||
throw new Swift_IoException(sprintf('Failed to encrypt S/Mime message. Error: "%s".', openssl_error_string()));
|
||||
}
|
||||
|
||||
$this->copyFromOpenSSLOutput($encryptedMessageStream, $is);
|
||||
// Parse the resulting signed message content back into the Swift message
|
||||
// preserving the original headers
|
||||
$this->parseSSLOutput($encryptedMessageStream, $message);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Swift_OutputByteStream $fromStream
|
||||
* @param Swift_InputByteStream $toStream
|
||||
* Copy named headers from one Swift message to another.
|
||||
*/
|
||||
protected function copyHeaders(
|
||||
Swift_Message $fromMessage,
|
||||
Swift_Message $toMessage,
|
||||
array $headers = []
|
||||
) {
|
||||
foreach ($headers as $header) {
|
||||
$this->copyHeader($fromMessage, $toMessage, $header);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy a single header from one Swift message to another.
|
||||
*
|
||||
* @param string $headerName
|
||||
*/
|
||||
protected function copyHeader(Swift_Message $fromMessage, Swift_Message $toMessage, $headerName)
|
||||
{
|
||||
$header = $fromMessage->getHeaders()->get($headerName);
|
||||
if (!$header) {
|
||||
return;
|
||||
}
|
||||
$headers = $toMessage->getHeaders();
|
||||
switch ($header->getFieldType()) {
|
||||
case Swift_Mime_Header::TYPE_TEXT:
|
||||
$headers->addTextHeader($header->getFieldName(), $header->getValue());
|
||||
break;
|
||||
case Swift_Mime_Header::TYPE_PARAMETERIZED:
|
||||
$headers->addParameterizedHeader(
|
||||
$header->getFieldName(),
|
||||
$header->getValue(),
|
||||
$header->getParameters()
|
||||
);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove all headers from a Swift message.
|
||||
*/
|
||||
protected function clearAllHeaders(Swift_Message $message)
|
||||
{
|
||||
$headers = $message->getHeaders();
|
||||
foreach ($headers->listAll() as $header) {
|
||||
$headers->removeAll($header);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Wraps a Swift_Message in a message/rfc822 MIME part.
|
||||
*
|
||||
* @return Swift_MimePart
|
||||
*/
|
||||
protected function wrapMimeMessage(Swift_Message $message)
|
||||
{
|
||||
// Start by copying the original message into a message stream
|
||||
$messageStream = new Swift_ByteStream_TemporaryFileByteStream();
|
||||
$message->toByteStream($messageStream);
|
||||
$messageStream->commit();
|
||||
|
||||
// Create a new MIME part that wraps the original stream
|
||||
$wrappedMessage = new Swift_MimePart($messageStream, 'message/rfc822');
|
||||
$wrappedMessage->setEncoder(new Swift_Mime_ContentEncoder_PlainContentEncoder('7bit'));
|
||||
|
||||
return $wrappedMessage;
|
||||
}
|
||||
|
||||
protected function parseSSLOutput(Swift_InputByteStream $inputStream, Swift_Message $message)
|
||||
{
|
||||
$messageStream = new Swift_ByteStream_TemporaryFileByteStream();
|
||||
$this->copyFromOpenSSLOutput($inputStream, $messageStream);
|
||||
|
||||
$this->streamToMime($messageStream, $message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Merges an OutputByteStream from OpenSSL to a Swift_Message.
|
||||
*/
|
||||
protected function streamToMime(Swift_OutputByteStream $fromStream, Swift_Message $message)
|
||||
{
|
||||
// Parse the stream into headers and body
|
||||
list($headers, $messageStream) = $this->parseStream($fromStream);
|
||||
|
||||
// Get the original message headers
|
||||
$messageHeaders = $message->getHeaders();
|
||||
|
||||
// Let the stream determine the headers describing the body content,
|
||||
// since the body of the original message is overwritten by the body
|
||||
// coming from the stream.
|
||||
// These are all content-* headers.
|
||||
|
||||
// Default transfer encoding is 7bit if not set
|
||||
$encoding = '';
|
||||
// Remove all existing transfer encoding headers
|
||||
$messageHeaders->removeAll('Content-Transfer-Encoding');
|
||||
// See whether the stream sets the transfer encoding
|
||||
if (isset($headers['content-transfer-encoding'])) {
|
||||
$encoding = $headers['content-transfer-encoding'];
|
||||
}
|
||||
|
||||
// We use the null content encoder, since the body is already encoded
|
||||
// according to the transfer encoding specified in the stream
|
||||
$message->setEncoder(new Swift_Mime_ContentEncoder_NullContentEncoder($encoding));
|
||||
|
||||
// Set the disposition, if present
|
||||
if (isset($headers['content-disposition'])) {
|
||||
$messageHeaders->addTextHeader('Content-Disposition', $headers['content-disposition']);
|
||||
}
|
||||
|
||||
// Copy over the body from the stream using the content type dictated
|
||||
// by the stream content
|
||||
$message->setChildren([]);
|
||||
$message->setBody($messageStream, $headers['content-type']);
|
||||
}
|
||||
|
||||
/**
|
||||
* This message will parse the headers of a MIME email byte stream
|
||||
* and return an array that contains the headers as an associative
|
||||
* array and the email body as a string.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function parseStream(Swift_OutputByteStream $emailStream)
|
||||
{
|
||||
$bufferLength = 78;
|
||||
$headerData = '';
|
||||
$headerBodySeparator = "\r\n\r\n";
|
||||
|
||||
$emailStream->setReadPointer(0);
|
||||
|
||||
// Read out the headers section from the stream to a string
|
||||
while (false !== ($buffer = $emailStream->read($bufferLength))) {
|
||||
$headerData .= $buffer;
|
||||
|
||||
$headersPosEnd = strpos($headerData, $headerBodySeparator);
|
||||
|
||||
// Stop reading if we found the end of the headers
|
||||
if (false !== $headersPosEnd) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Split the header data into lines
|
||||
$headerData = trim(substr($headerData, 0, $headersPosEnd));
|
||||
$headerLines = explode("\r\n", $headerData);
|
||||
unset($headerData);
|
||||
|
||||
$headers = [];
|
||||
$currentHeaderName = '';
|
||||
|
||||
// Transform header lines into an associative array
|
||||
foreach ($headerLines as $headerLine) {
|
||||
// Handle headers that span multiple lines
|
||||
if (false === strpos($headerLine, ':')) {
|
||||
$headers[$currentHeaderName] .= ' '.trim($headerLine);
|
||||
continue;
|
||||
}
|
||||
|
||||
$header = explode(':', $headerLine, 2);
|
||||
$currentHeaderName = strtolower($header[0]);
|
||||
$headers[$currentHeaderName] = trim($header[1]);
|
||||
}
|
||||
|
||||
// Read the entire email body into a byte stream
|
||||
$bodyStream = new Swift_ByteStream_TemporaryFileByteStream();
|
||||
|
||||
// Skip the header and separator and point to the body
|
||||
$emailStream->setReadPointer($headersPosEnd + strlen($headerBodySeparator));
|
||||
|
||||
while (false !== ($buffer = $emailStream->read($bufferLength))) {
|
||||
$bodyStream->write($buffer);
|
||||
}
|
||||
|
||||
$bodyStream->commit();
|
||||
|
||||
return [$headers, $bodyStream];
|
||||
}
|
||||
|
||||
protected function copyFromOpenSSLOutput(Swift_OutputByteStream $fromStream, Swift_InputByteStream $toStream)
|
||||
{
|
||||
$bufferLength = 4096;
|
||||
@@ -325,93 +539,4 @@ class Swift_Signers_SMimeSigner implements Swift_Signers_BodySigner
|
||||
|
||||
$toStream->commit();
|
||||
}
|
||||
|
||||
/**
|
||||
* Merges an OutputByteStream to Swift_Message.
|
||||
*
|
||||
* @param Swift_OutputByteStream $fromStream
|
||||
* @param Swift_Message $message
|
||||
*/
|
||||
protected function streamToMime(Swift_OutputByteStream $fromStream, Swift_Message $message)
|
||||
{
|
||||
$bufferLength = 78;
|
||||
$headerData = '';
|
||||
|
||||
$fromStream->setReadPointer(0);
|
||||
|
||||
while (($buffer = $fromStream->read($bufferLength)) !== false) {
|
||||
$headerData .= $buffer;
|
||||
|
||||
if (false !== strpos($buffer, "\r\n\r\n")) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$headersPosEnd = strpos($headerData, "\r\n\r\n");
|
||||
$headerData = trim($headerData);
|
||||
$headerData = substr($headerData, 0, $headersPosEnd);
|
||||
$headerLines = explode("\r\n", $headerData);
|
||||
unset($headerData);
|
||||
|
||||
$headers = array();
|
||||
$currentHeaderName = '';
|
||||
|
||||
foreach ($headerLines as $headerLine) {
|
||||
// Line separated
|
||||
if (ctype_space($headerLines[0]) || false === strpos($headerLine, ':')) {
|
||||
$headers[$currentHeaderName] .= ' '.trim($headerLine);
|
||||
continue;
|
||||
}
|
||||
|
||||
$header = explode(':', $headerLine, 2);
|
||||
$currentHeaderName = strtolower($header[0]);
|
||||
$headers[$currentHeaderName] = trim($header[1]);
|
||||
}
|
||||
|
||||
$messageStream = new Swift_ByteStream_TemporaryFileByteStream();
|
||||
$messageStream->addFilter($this->replacementFactory->createFilter("\r\n", "\n"), 'CRLF to LF');
|
||||
$messageStream->addFilter($this->replacementFactory->createFilter("\n", "\r\n"), 'LF to CRLF');
|
||||
|
||||
$messageHeaders = $message->getHeaders();
|
||||
|
||||
// No need to check for 'application/pkcs7-mime', as this is always base64
|
||||
if ('multipart/signed;' === substr($headers['content-type'], 0, 17)) {
|
||||
if (!preg_match('/boundary=("[^"]+"|(?:[^\s]+|$))/is', $headers['content-type'], $contentTypeData)) {
|
||||
throw new Swift_SwiftException('Failed to find Boundary parameter');
|
||||
}
|
||||
|
||||
$boundary = trim($contentTypeData['1'], '"');
|
||||
|
||||
// Skip the header and CRLF CRLF
|
||||
$fromStream->setReadPointer($headersPosEnd + 4);
|
||||
|
||||
while (false !== ($buffer = $fromStream->read($bufferLength))) {
|
||||
$messageStream->write($buffer);
|
||||
}
|
||||
|
||||
$messageStream->commit();
|
||||
|
||||
$messageHeaders->remove('Content-Transfer-Encoding');
|
||||
$message->setContentType($headers['content-type']);
|
||||
$message->setBoundary($boundary);
|
||||
$message->setBody($messageStream);
|
||||
} else {
|
||||
$fromStream->setReadPointer($headersPosEnd + 4);
|
||||
|
||||
if (null === $this->headerFactory) {
|
||||
$this->headerFactory = Swift_DependencyContainer::getInstance()->lookup('mime.headerfactory');
|
||||
}
|
||||
|
||||
$message->setContentType($headers['content-type']);
|
||||
$messageHeaders->set($this->headerFactory->createTextHeader('Content-Transfer-Encoding', $headers['content-transfer-encoding']));
|
||||
$messageHeaders->set($this->headerFactory->createTextHeader('Content-Disposition', $headers['content-disposition']));
|
||||
|
||||
while (false !== ($buffer = $fromStream->read($bufferLength))) {
|
||||
$messageStream->write($buffer);
|
||||
}
|
||||
|
||||
$messageStream->commit();
|
||||
$message->setBody($messageStream);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ class Swift_SmtpTransport extends Swift_Transport_EsmtpTransport
|
||||
public function __construct($host = 'localhost', $port = 25, $security = null)
|
||||
{
|
||||
call_user_func_array(
|
||||
array($this, 'Swift_Transport_EsmtpTransport::__construct'),
|
||||
[$this, 'Swift_Transport_EsmtpTransport::__construct'],
|
||||
Swift_DependencyContainer::getInstance()
|
||||
->createDependenciesFor('transport.smtp')
|
||||
);
|
||||
|
||||
@@ -17,8 +17,6 @@ class Swift_SpoolTransport extends Swift_Transport_SpoolTransport
|
||||
{
|
||||
/**
|
||||
* Create a new SpoolTransport.
|
||||
*
|
||||
* @param Swift_Spool $spool
|
||||
*/
|
||||
public function __construct(Swift_Spool $spool)
|
||||
{
|
||||
@@ -28,7 +26,7 @@ class Swift_SpoolTransport extends Swift_Transport_SpoolTransport
|
||||
$arguments[] = $spool;
|
||||
|
||||
call_user_func_array(
|
||||
array($this, 'Swift_Transport_SpoolTransport::__construct'),
|
||||
[$this, 'Swift_Transport_SpoolTransport::__construct'],
|
||||
$arguments
|
||||
);
|
||||
}
|
||||
|
||||
@@ -17,9 +17,6 @@
|
||||
*/
|
||||
class Swift_StreamFilters_ByteArrayReplacementFilter implements Swift_StreamFilter
|
||||
{
|
||||
/** The needle(s) to search for */
|
||||
private $search;
|
||||
|
||||
/** The replacement(s) to make */
|
||||
private $replace;
|
||||
|
||||
@@ -27,7 +24,7 @@ class Swift_StreamFilters_ByteArrayReplacementFilter implements Swift_StreamFilt
|
||||
private $index;
|
||||
|
||||
/** The Search Tree */
|
||||
private $tree = array();
|
||||
private $tree = [];
|
||||
|
||||
/** Gives the size of the largest search */
|
||||
private $treeMaxLen = 0;
|
||||
@@ -42,17 +39,16 @@ class Swift_StreamFilters_ByteArrayReplacementFilter implements Swift_StreamFilt
|
||||
*/
|
||||
public function __construct($search, $replace)
|
||||
{
|
||||
$this->search = $search;
|
||||
$this->index = array();
|
||||
$this->tree = array();
|
||||
$this->replace = array();
|
||||
$this->repSize = array();
|
||||
$this->index = [];
|
||||
$this->tree = [];
|
||||
$this->replace = [];
|
||||
$this->repSize = [];
|
||||
|
||||
$tree = null;
|
||||
$i = null;
|
||||
$last_size = $size = 0;
|
||||
foreach ($search as $i => $search_element) {
|
||||
if ($tree !== null) {
|
||||
if (null !== $tree) {
|
||||
$tree[-1] = min(count($replace) - 1, $i - 1);
|
||||
$tree[-2] = $last_size;
|
||||
}
|
||||
@@ -61,7 +57,7 @@ class Swift_StreamFilters_ByteArrayReplacementFilter implements Swift_StreamFilt
|
||||
foreach ($search_element as $k => $char) {
|
||||
$this->index[$char] = true;
|
||||
if (!isset($tree[$char])) {
|
||||
$tree[$char] = array();
|
||||
$tree[$char] = [];
|
||||
}
|
||||
$tree = &$tree[$char];
|
||||
}
|
||||
@@ -70,21 +66,21 @@ class Swift_StreamFilters_ByteArrayReplacementFilter implements Swift_StreamFilt
|
||||
} else {
|
||||
$last_size = 1;
|
||||
if (!isset($tree[$search_element])) {
|
||||
$tree[$search_element] = array();
|
||||
$tree[$search_element] = [];
|
||||
}
|
||||
$tree = &$tree[$search_element];
|
||||
$size = max($last_size, $size);
|
||||
$this->index[$search_element] = true;
|
||||
}
|
||||
}
|
||||
if ($i !== null) {
|
||||
if (null !== $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 = [$rep];
|
||||
}
|
||||
$this->replace[] = $rep;
|
||||
}
|
||||
@@ -118,11 +114,11 @@ class Swift_StreamFilters_ByteArrayReplacementFilter implements Swift_StreamFilt
|
||||
*/
|
||||
public function filter($buffer, $minReplaces = -1)
|
||||
{
|
||||
if ($this->treeMaxLen == 0) {
|
||||
if (0 == $this->treeMaxLen) {
|
||||
return $buffer;
|
||||
}
|
||||
|
||||
$newBuffer = array();
|
||||
$newBuffer = [];
|
||||
$buf_size = count($buffer);
|
||||
$last_size = 0;
|
||||
for ($i = 0; $i < $buf_size; ++$i) {
|
||||
@@ -141,7 +137,7 @@ class Swift_StreamFilters_ByteArrayReplacementFilter implements Swift_StreamFilt
|
||||
}
|
||||
}
|
||||
// We got a complete pattern
|
||||
elseif ($last_found !== PHP_INT_MAX) {
|
||||
elseif (PHP_INT_MAX !== $last_found) {
|
||||
// Adding replacement datas to output buffer
|
||||
$rep_size = $this->repSize[$last_found];
|
||||
for ($j = 0; $j < $rep_size; ++$j) {
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
class Swift_StreamFilters_StringReplacementFilterFactory implements Swift_ReplacementFilterFactory
|
||||
{
|
||||
/** Lazy-loaded filters */
|
||||
private $filters = array();
|
||||
private $filters = [];
|
||||
|
||||
/**
|
||||
* Create a new StreamFilter to replace $search with $replace in a string.
|
||||
@@ -30,11 +30,11 @@ class Swift_StreamFilters_StringReplacementFilterFactory implements Swift_Replac
|
||||
{
|
||||
if (!isset($this->filters[$search][$replace])) {
|
||||
if (!isset($this->filters[$search])) {
|
||||
$this->filters[$search] = array();
|
||||
$this->filters[$search] = [];
|
||||
}
|
||||
|
||||
if (!isset($this->filters[$search][$replace])) {
|
||||
$this->filters[$search][$replace] = array();
|
||||
$this->filters[$search][$replace] = [];
|
||||
}
|
||||
|
||||
$this->filters[$search][$replace] = new Swift_StreamFilters_StringReplacementFilter($search, $replace);
|
||||
|
||||
@@ -18,9 +18,8 @@ class Swift_SwiftException extends Exception
|
||||
/**
|
||||
* Create a new SwiftException with $message.
|
||||
*
|
||||
* @param string $message
|
||||
* @param int $code
|
||||
* @param Exception $previous
|
||||
* @param string $message
|
||||
* @param int $code
|
||||
*/
|
||||
public function __construct($message, $code = 0, Exception $previous = null)
|
||||
{
|
||||
|
||||
@@ -62,7 +62,7 @@ interface Swift_Transport
|
||||
* The return value is the number of recipients who were accepted for delivery.
|
||||
*
|
||||
* @param Swift_Mime_SimpleMessage $message
|
||||
* @param string[] $failedRecipients An array of failures by-reference
|
||||
* @param string[] $failedRecipients An array of failures by-reference
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
|
||||
@@ -27,6 +27,14 @@ abstract class Swift_Transport_AbstractSmtpTransport implements Swift_Transport
|
||||
/** The event dispatching layer */
|
||||
protected $eventDispatcher;
|
||||
|
||||
protected $addressEncoder;
|
||||
|
||||
/** Whether the PIPELINING SMTP extension is enabled (RFC 2920) */
|
||||
protected $pipelining = null;
|
||||
|
||||
/** The pipelined commands waiting for response */
|
||||
protected $pipeline = [];
|
||||
|
||||
/** Source Ip */
|
||||
protected $sourceIp;
|
||||
|
||||
@@ -36,14 +44,13 @@ abstract class Swift_Transport_AbstractSmtpTransport implements Swift_Transport
|
||||
/**
|
||||
* Creates a new EsmtpTransport using the given I/O buffer.
|
||||
*
|
||||
* @param Swift_Transport_IoBuffer $buf
|
||||
* @param Swift_Events_EventDispatcher $dispatcher
|
||||
* @param string $localDomain
|
||||
* @param string $localDomain
|
||||
*/
|
||||
public function __construct(Swift_Transport_IoBuffer $buf, Swift_Events_EventDispatcher $dispatcher, $localDomain = '127.0.0.1')
|
||||
public function __construct(Swift_Transport_IoBuffer $buf, Swift_Events_EventDispatcher $dispatcher, $localDomain = '127.0.0.1', Swift_AddressEncoder $addressEncoder = null)
|
||||
{
|
||||
$this->eventDispatcher = $dispatcher;
|
||||
$this->buffer = $buf;
|
||||
$this->eventDispatcher = $dispatcher;
|
||||
$this->addressEncoder = $addressEncoder ?? new Swift_AddressEncoder_IdnAddressEncoder();
|
||||
$this->setLocalDomain($localDomain);
|
||||
}
|
||||
|
||||
@@ -63,7 +70,7 @@ abstract class Swift_Transport_AbstractSmtpTransport implements Swift_Transport
|
||||
*/
|
||||
public function setLocalDomain($domain)
|
||||
{
|
||||
if (substr($domain, 0, 1) !== '[') {
|
||||
if ('[' !== substr($domain, 0, 1)) {
|
||||
if (filter_var($domain, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) {
|
||||
$domain = '['.$domain.']';
|
||||
} elseif (filter_var($domain, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) {
|
||||
@@ -109,6 +116,16 @@ abstract class Swift_Transport_AbstractSmtpTransport implements Swift_Transport
|
||||
return $this->sourceIp;
|
||||
}
|
||||
|
||||
public function setAddressEncoder(Swift_AddressEncoder $addressEncoder)
|
||||
{
|
||||
$this->addressEncoder = $addressEncoder;
|
||||
}
|
||||
|
||||
public function getAddressEncoder()
|
||||
{
|
||||
return $this->addressEncoder;
|
||||
}
|
||||
|
||||
/**
|
||||
* Start the SMTP connection.
|
||||
*/
|
||||
@@ -154,8 +171,7 @@ abstract class Swift_Transport_AbstractSmtpTransport implements Swift_Transport
|
||||
* Recipient/sender data will be retrieved from the Message API.
|
||||
* The return value is the number of recipients who were accepted for delivery.
|
||||
*
|
||||
* @param Swift_Mime_SimpleMessage $message
|
||||
* @param string[] $failedRecipients An array of failures by-reference
|
||||
* @param string[] $failedRecipients An array of failures by-reference
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
@@ -183,7 +199,7 @@ abstract class Swift_Transport_AbstractSmtpTransport implements Swift_Transport
|
||||
$tos = array_merge($to, $cc);
|
||||
$bcc = (array) $message->getBcc();
|
||||
|
||||
$message->setBcc(array());
|
||||
$message->setBcc([]);
|
||||
|
||||
try {
|
||||
$sent += $this->sendTo($message, $reversePath, $tos, $failedRecipients);
|
||||
@@ -226,7 +242,7 @@ abstract class Swift_Transport_AbstractSmtpTransport implements Swift_Transport
|
||||
}
|
||||
|
||||
try {
|
||||
$this->executeCommand("QUIT\r\n", array(221));
|
||||
$this->executeCommand("QUIT\r\n", [221]);
|
||||
} catch (Swift_TransportException $e) {
|
||||
}
|
||||
|
||||
@@ -253,7 +269,7 @@ abstract class Swift_Transport_AbstractSmtpTransport implements Swift_Transport
|
||||
$this->start();
|
||||
}
|
||||
|
||||
$this->executeCommand("NOOP\r\n", array(250));
|
||||
$this->executeCommand("NOOP\r\n", [250]);
|
||||
} catch (Swift_TransportException $e) {
|
||||
try {
|
||||
$this->stop();
|
||||
@@ -268,8 +284,6 @@ abstract class Swift_Transport_AbstractSmtpTransport implements Swift_Transport
|
||||
|
||||
/**
|
||||
* Register a plugin.
|
||||
*
|
||||
* @param Swift_Events_EventListener $plugin
|
||||
*/
|
||||
public function registerPlugin(Swift_Events_EventListener $plugin)
|
||||
{
|
||||
@@ -281,7 +295,7 @@ abstract class Swift_Transport_AbstractSmtpTransport implements Swift_Transport
|
||||
*/
|
||||
public function reset()
|
||||
{
|
||||
$this->executeCommand("RSET\r\n", array(250));
|
||||
$this->executeCommand("RSET\r\n", [250], $failures, true);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -303,18 +317,28 @@ abstract class Swift_Transport_AbstractSmtpTransport implements Swift_Transport
|
||||
* @param string $command
|
||||
* @param int[] $codes
|
||||
* @param string[] $failures An array of failures by-reference
|
||||
* @param bool $pipeline Do not wait for response
|
||||
*
|
||||
* @return string
|
||||
* @return string|null The server response, or null if pipelining is enabled
|
||||
*/
|
||||
public function executeCommand($command, $codes = array(), &$failures = null)
|
||||
public function executeCommand($command, $codes = [], &$failures = null, $pipeline = false)
|
||||
{
|
||||
$failures = (array) $failures;
|
||||
$seq = $this->buffer->write($command);
|
||||
$response = $this->getFullResponse($seq);
|
||||
if ($evt = $this->eventDispatcher->createCommandEvent($this, $command, $codes)) {
|
||||
$this->eventDispatcher->dispatchEvent($evt, 'commandSent');
|
||||
}
|
||||
$this->assertResponseCode($response, $codes);
|
||||
|
||||
$this->pipeline[] = [$command, $seq, $codes];
|
||||
if ($pipeline && $this->pipelining) {
|
||||
$response = null;
|
||||
} else {
|
||||
while ($this->pipeline) {
|
||||
list($command, $seq, $codes) = array_shift($this->pipeline);
|
||||
$response = $this->getFullResponse($seq);
|
||||
$this->assertResponseCode($response, $codes);
|
||||
}
|
||||
}
|
||||
|
||||
return $response;
|
||||
}
|
||||
@@ -322,51 +346,53 @@ abstract class Swift_Transport_AbstractSmtpTransport implements Swift_Transport
|
||||
/** Read the opening SMTP greeting */
|
||||
protected function readGreeting()
|
||||
{
|
||||
$this->assertResponseCode($this->getFullResponse(0), array(220));
|
||||
$this->assertResponseCode($this->getFullResponse(0), [220]);
|
||||
}
|
||||
|
||||
/** Send the HELO welcome */
|
||||
protected function doHeloCommand()
|
||||
{
|
||||
$this->executeCommand(
|
||||
sprintf("HELO %s\r\n", $this->domain), array(250)
|
||||
sprintf("HELO %s\r\n", $this->domain), [250]
|
||||
);
|
||||
}
|
||||
|
||||
/** Send the MAIL FROM command */
|
||||
protected function doMailFromCommand($address)
|
||||
{
|
||||
$address = $this->addressEncoder->encodeString($address);
|
||||
$this->executeCommand(
|
||||
sprintf("MAIL FROM:<%s>\r\n", $address), array(250)
|
||||
sprintf("MAIL FROM:<%s>\r\n", $address), [250], $failures, true
|
||||
);
|
||||
}
|
||||
|
||||
/** Send the RCPT TO command */
|
||||
protected function doRcptToCommand($address)
|
||||
{
|
||||
$address = $this->addressEncoder->encodeString($address);
|
||||
$this->executeCommand(
|
||||
sprintf("RCPT TO:<%s>\r\n", $address), array(250, 251, 252)
|
||||
sprintf("RCPT TO:<%s>\r\n", $address), [250, 251, 252], $failures, true
|
||||
);
|
||||
}
|
||||
|
||||
/** Send the DATA command */
|
||||
protected function doDataCommand()
|
||||
{
|
||||
$this->executeCommand("DATA\r\n", array(354));
|
||||
$this->executeCommand("DATA\r\n", [354]);
|
||||
}
|
||||
|
||||
/** Stream the contents of the message over the buffer */
|
||||
protected function streamMessage(Swift_Mime_SimpleMessage $message)
|
||||
{
|
||||
$this->buffer->setWriteTranslations(array("\r\n." => "\r\n.."));
|
||||
$this->buffer->setWriteTranslations(["\r\n." => "\r\n.."]);
|
||||
try {
|
||||
$message->toByteStream($this->buffer);
|
||||
$this->buffer->flushBuffers();
|
||||
} catch (Swift_TransportException $e) {
|
||||
$this->throwException($e);
|
||||
}
|
||||
$this->buffer->setWriteTranslations(array());
|
||||
$this->executeCommand("\r\n.\r\n", array(250));
|
||||
$this->buffer->setWriteTranslations([]);
|
||||
$this->executeCommand("\r\n.\r\n", [250]);
|
||||
}
|
||||
|
||||
/** Determine the best-use reverse path for this message */
|
||||
@@ -456,10 +482,12 @@ abstract class Swift_Transport_AbstractSmtpTransport implements Swift_Transport
|
||||
++$sent;
|
||||
} catch (Swift_TransportException $e) {
|
||||
$failedRecipients[] = $forwardPath;
|
||||
} catch (Swift_AddressEncoderException $e) {
|
||||
$failedRecipients[] = $forwardPath;
|
||||
}
|
||||
}
|
||||
|
||||
if ($sent != 0) {
|
||||
if (0 != $sent) {
|
||||
$this->doDataCommand();
|
||||
$this->streamMessage($message);
|
||||
} else {
|
||||
@@ -485,9 +513,9 @@ abstract class Swift_Transport_AbstractSmtpTransport implements Swift_Transport
|
||||
{
|
||||
$sent = 0;
|
||||
foreach ($bcc as $forwardPath => $name) {
|
||||
$message->setBcc(array($forwardPath => $name));
|
||||
$message->setBcc([$forwardPath => $name]);
|
||||
$sent += $this->doMailTransaction(
|
||||
$message, $reversePath, array($forwardPath), $failedRecipients
|
||||
$message, $reversePath, [$forwardPath], $failedRecipients
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -26,29 +26,23 @@ class Swift_Transport_Esmtp_Auth_CramMd5Authenticator implements Swift_Transport
|
||||
}
|
||||
|
||||
/**
|
||||
* Try to authenticate the user with $username and $password.
|
||||
*
|
||||
* @param Swift_Transport_SmtpAgent $agent
|
||||
* @param string $username
|
||||
* @param string $password
|
||||
*
|
||||
* @return bool
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function authenticate(Swift_Transport_SmtpAgent $agent, $username, $password)
|
||||
{
|
||||
try {
|
||||
$challenge = $agent->executeCommand("AUTH CRAM-MD5\r\n", array(334));
|
||||
$challenge = $agent->executeCommand("AUTH CRAM-MD5\r\n", [334]);
|
||||
$challenge = base64_decode(substr($challenge, 4));
|
||||
$message = base64_encode(
|
||||
$username.' '.$this->getResponse($password, $challenge)
|
||||
);
|
||||
$agent->executeCommand(sprintf("%s\r\n", $message), array(235));
|
||||
$agent->executeCommand(sprintf("%s\r\n", $message), [235]);
|
||||
|
||||
return true;
|
||||
} catch (Swift_TransportException $e) {
|
||||
$agent->executeCommand("RSET\r\n", array(250));
|
||||
$agent->executeCommand("RSET\r\n", [250]);
|
||||
|
||||
return false;
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -26,26 +26,20 @@ class Swift_Transport_Esmtp_Auth_LoginAuthenticator implements Swift_Transport_E
|
||||
}
|
||||
|
||||
/**
|
||||
* Try to authenticate the user with $username and $password.
|
||||
*
|
||||
* @param Swift_Transport_SmtpAgent $agent
|
||||
* @param string $username
|
||||
* @param string $password
|
||||
*
|
||||
* @return bool
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function authenticate(Swift_Transport_SmtpAgent $agent, $username, $password)
|
||||
{
|
||||
try {
|
||||
$agent->executeCommand("AUTH LOGIN\r\n", array(334));
|
||||
$agent->executeCommand(sprintf("%s\r\n", base64_encode($username)), array(334));
|
||||
$agent->executeCommand(sprintf("%s\r\n", base64_encode($password)), array(235));
|
||||
$agent->executeCommand("AUTH LOGIN\r\n", [334]);
|
||||
$agent->executeCommand(sprintf("%s\r\n", base64_encode($username)), [334]);
|
||||
$agent->executeCommand(sprintf("%s\r\n", base64_encode($password)), [235]);
|
||||
|
||||
return true;
|
||||
} catch (Swift_TransportException $e) {
|
||||
$agent->executeCommand("RSET\r\n", array(250));
|
||||
$agent->executeCommand("RSET\r\n", [250]);
|
||||
|
||||
return false;
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,13 +31,7 @@ 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
|
||||
*
|
||||
* @return bool
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @throws \LogicException
|
||||
*/
|
||||
@@ -65,9 +59,9 @@ class Swift_Transport_Esmtp_Auth_NTLMAuthenticator implements Swift_Transport_Es
|
||||
|
||||
return true;
|
||||
} catch (Swift_TransportException $e) {
|
||||
$agent->executeCommand("RSET\r\n", array(250));
|
||||
$agent->executeCommand("RSET\r\n", [250]);
|
||||
|
||||
return false;
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -100,15 +94,13 @@ class Swift_Transport_Esmtp_Auth_NTLMAuthenticator implements Swift_Transport_Es
|
||||
/**
|
||||
* Send our auth message and returns the response.
|
||||
*
|
||||
* @param Swift_Transport_SmtpAgent $agent
|
||||
*
|
||||
* @return string SMTP Response
|
||||
*/
|
||||
protected function sendMessage1(Swift_Transport_SmtpAgent $agent)
|
||||
{
|
||||
$message = $this->createMessage1();
|
||||
|
||||
return $agent->executeCommand(sprintf("AUTH %s %s\r\n", $this->getAuthKeyword(), base64_encode($message)), array(334));
|
||||
return $agent->executeCommand(sprintf("AUTH %s %s\r\n", $this->getAuthKeyword(), base64_encode($message)), [334]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -131,7 +123,7 @@ class Swift_Transport_Esmtp_Auth_NTLMAuthenticator implements Swift_Transport_Es
|
||||
$targetInfoBlock = substr($responseHex, $offset);
|
||||
list($domainName, $serverName, $DNSDomainName, $DNSServerName, $terminatorByte) = $this->readSubBlock($targetInfoBlock);
|
||||
|
||||
return array(
|
||||
return [
|
||||
$challenge,
|
||||
$context,
|
||||
$targetInfoH,
|
||||
@@ -142,14 +134,12 @@ class Swift_Transport_Esmtp_Auth_NTLMAuthenticator implements Swift_Transport_Es
|
||||
$DNSServerName,
|
||||
hex2bin($targetInfoBlock),
|
||||
$terminatorByte,
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Read the blob information in from message2.
|
||||
*
|
||||
* @param $block
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function readSubBlock($block)
|
||||
@@ -159,7 +149,7 @@ class Swift_Transport_Esmtp_Auth_NTLMAuthenticator implements Swift_Transport_Es
|
||||
|
||||
$length = strlen($block);
|
||||
$offset = 0;
|
||||
$data = array();
|
||||
$data = [];
|
||||
while ($offset < $length) {
|
||||
$blockLength = hexdec(substr(substr($block, $offset, 8), -4)) / 256;
|
||||
$offset += 8;
|
||||
@@ -167,7 +157,7 @@ class Swift_Transport_Esmtp_Auth_NTLMAuthenticator implements Swift_Transport_Es
|
||||
$offset += $blockLength * 2;
|
||||
}
|
||||
|
||||
if (count($data) == 3) {
|
||||
if (3 == count($data)) {
|
||||
$data[] = $data[2];
|
||||
$data[2] = '';
|
||||
}
|
||||
@@ -180,13 +170,12 @@ class Swift_Transport_Esmtp_Auth_NTLMAuthenticator implements Swift_Transport_Es
|
||||
/**
|
||||
* 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 Swift_Transport_SmtpAgent $agent
|
||||
* @param bool $v2 Use version2 of the protocol
|
||||
* @param string $response Message 1 response (message 2)
|
||||
* @param string $username
|
||||
* @param string $password
|
||||
* @param string $timestamp
|
||||
* @param string $client
|
||||
* @param bool $v2 Use version2 of the protocol
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
@@ -210,7 +199,7 @@ class Swift_Transport_Esmtp_Auth_NTLMAuthenticator implements Swift_Transport_Es
|
||||
|
||||
$message = $this->createMessage3($domain, $username, $workstation, $lmResponse, $ntlmResponse);
|
||||
|
||||
return $agent->executeCommand(sprintf("%s\r\n", base64_encode($message)), array(235));
|
||||
return $agent->executeCommand(sprintf("%s\r\n", base64_encode($message)), [235]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -294,18 +283,18 @@ class Swift_Transport_Esmtp_Auth_NTLMAuthenticator implements Swift_Transport_Es
|
||||
*/
|
||||
protected function getDomainAndUsername($name)
|
||||
{
|
||||
if (strpos($name, '\\') !== false) {
|
||||
if (false !== strpos($name, '\\')) {
|
||||
return explode('\\', $name);
|
||||
}
|
||||
|
||||
if (false !== strpos($name, '@')) {
|
||||
list($user, $domain) = explode('@', $name);
|
||||
|
||||
return array($domain, $user);
|
||||
return [$domain, $user];
|
||||
}
|
||||
|
||||
// no domain passed
|
||||
return array('', $name);
|
||||
return ['', $name];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -436,7 +425,7 @@ class Swift_Transport_Esmtp_Auth_NTLMAuthenticator implements Swift_Transport_Es
|
||||
|
||||
protected function createDesKey($key)
|
||||
{
|
||||
$material = array(bin2hex($key[0]));
|
||||
$material = [bin2hex($key[0])];
|
||||
$len = strlen($key);
|
||||
for ($i = 1; $i < $len; ++$i) {
|
||||
list($high, $low) = str_split(bin2hex($key[$i]));
|
||||
@@ -448,9 +437,9 @@ class Swift_Transport_Esmtp_Auth_NTLMAuthenticator implements Swift_Transport_Es
|
||||
// odd parity
|
||||
foreach ($material as $k => $v) {
|
||||
$b = $this->castToByte(hexdec($v));
|
||||
$needsParity = (($this->uRShift($b, 7) ^ $this->uRShift($b, 6) ^ $this->uRShift($b, 5)
|
||||
$needsParity = 0 == (($this->uRShift($b, 7) ^ $this->uRShift($b, 6) ^ $this->uRShift($b, 5)
|
||||
^ $this->uRShift($b, 4) ^ $this->uRShift($b, 3) ^ $this->uRShift($b, 2)
|
||||
^ $this->uRShift($b, 1)) & 0x01) == 0;
|
||||
^ $this->uRShift($b, 1)) & 0x01);
|
||||
|
||||
list($high, $low) = str_split($v);
|
||||
if ($needsParity) {
|
||||
@@ -495,7 +484,7 @@ class Swift_Transport_Esmtp_Auth_NTLMAuthenticator implements Swift_Transport_Es
|
||||
$length = floor(hexdec(substr($value, 0, 4)) / 256) * 2;
|
||||
$offset = floor(hexdec(substr($value, 8, 4)) / 256) * 2;
|
||||
|
||||
return array($length, $offset);
|
||||
return [$length, $offset];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -521,7 +510,7 @@ class Swift_Transport_Esmtp_Auth_NTLMAuthenticator implements Swift_Transport_Es
|
||||
*/
|
||||
protected function uRShift($a, $b)
|
||||
{
|
||||
if ($b == 0) {
|
||||
if (0 == $b) {
|
||||
return $a;
|
||||
}
|
||||
|
||||
@@ -592,7 +581,7 @@ class Swift_Transport_Esmtp_Auth_NTLMAuthenticator implements Swift_Transport_Es
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @see http://php.net/manual/en/ref.hash.php
|
||||
* @see https://secure.php.net/manual/en/ref.hash.php
|
||||
*/
|
||||
protected function md4Encrypt($input)
|
||||
{
|
||||
@@ -623,8 +612,8 @@ class Swift_Transport_Esmtp_Auth_NTLMAuthenticator implements Swift_Transport_Es
|
||||
echo substr($message, 0, 16)." NTLMSSP Signature<br />\n";
|
||||
echo $messageId." Type Indicator<br />\n";
|
||||
|
||||
if ($messageId == '02000000') {
|
||||
$map = array(
|
||||
if ('02000000' == $messageId) {
|
||||
$map = [
|
||||
'Challenge',
|
||||
'Context',
|
||||
'Target Information Security Buffer',
|
||||
@@ -635,14 +624,14 @@ class Swift_Transport_Esmtp_Auth_NTLMAuthenticator implements Swift_Transport_Es
|
||||
'DNS Server Name',
|
||||
'BLOB',
|
||||
'Target Information Terminator',
|
||||
);
|
||||
];
|
||||
|
||||
$data = $this->parseMessage2(hex2bin($message));
|
||||
|
||||
foreach ($map as $key => $value) {
|
||||
echo bin2hex($data[$key]).' - '.$data[$key].' ||| '.$value."<br />\n";
|
||||
}
|
||||
} elseif ($messageId == '03000000') {
|
||||
} elseif ('03000000' == $messageId) {
|
||||
$i = 0;
|
||||
$data[$i++] = substr($message, 24, 16);
|
||||
list($lmLength, $lmOffset) = $this->readSecurityBuffer($data[$i - 1]);
|
||||
@@ -667,7 +656,7 @@ class Swift_Transport_Esmtp_Auth_NTLMAuthenticator implements Swift_Transport_Es
|
||||
$data[$i++] = substr($message, $lmOffset, $lmLength);
|
||||
$data[$i] = substr($message, $ntmlOffset, $ntmlLength);
|
||||
|
||||
$map = array(
|
||||
$map = [
|
||||
'LM Response Security Buffer',
|
||||
'NTLM Response Security Buffer',
|
||||
'Target Name Security Buffer',
|
||||
@@ -680,7 +669,7 @@ class Swift_Transport_Esmtp_Auth_NTLMAuthenticator implements Swift_Transport_Es
|
||||
'Workstation Name Data',
|
||||
'LM Response Data',
|
||||
'NTLM Response Data',
|
||||
);
|
||||
];
|
||||
|
||||
foreach ($map as $key => $value) {
|
||||
echo $data[$key].' - '.hex2bin($data[$key]).' ||| '.$value."<br />\n";
|
||||
|
||||
@@ -26,25 +26,19 @@ class Swift_Transport_Esmtp_Auth_PlainAuthenticator implements Swift_Transport_E
|
||||
}
|
||||
|
||||
/**
|
||||
* Try to authenticate the user with $username and $password.
|
||||
*
|
||||
* @param Swift_Transport_SmtpAgent $agent
|
||||
* @param string $username
|
||||
* @param string $password
|
||||
*
|
||||
* @return bool
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function authenticate(Swift_Transport_SmtpAgent $agent, $username, $password)
|
||||
{
|
||||
try {
|
||||
$message = base64_encode($username.chr(0).$username.chr(0).$password);
|
||||
$agent->executeCommand(sprintf("AUTH PLAIN %s\r\n", $message), array(235));
|
||||
$agent->executeCommand(sprintf("AUTH PLAIN %s\r\n", $message), [235]);
|
||||
|
||||
return true;
|
||||
} catch (Swift_TransportException $e) {
|
||||
$agent->executeCommand("RSET\r\n", array(250));
|
||||
$agent->executeCommand("RSET\r\n", [250]);
|
||||
|
||||
return false;
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,25 +36,19 @@ class Swift_Transport_Esmtp_Auth_XOAuth2Authenticator implements Swift_Transport
|
||||
}
|
||||
|
||||
/**
|
||||
* Try to authenticate the user with $email and $token.
|
||||
*
|
||||
* @param Swift_Transport_SmtpAgent $agent
|
||||
* @param string $email
|
||||
* @param string $token
|
||||
*
|
||||
* @return bool
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function authenticate(Swift_Transport_SmtpAgent $agent, $email, $token)
|
||||
{
|
||||
try {
|
||||
$param = $this->constructXOAuth2Params($email, $token);
|
||||
$agent->executeCommand('AUTH XOAUTH2 '.$param."\r\n", array(235));
|
||||
$agent->executeCommand('AUTH XOAUTH2 '.$param."\r\n", [235]);
|
||||
|
||||
return true;
|
||||
} catch (Swift_TransportException $e) {
|
||||
$agent->executeCommand("RSET\r\n", array(250));
|
||||
$agent->executeCommand("RSET\r\n", [250]);
|
||||
|
||||
return false;
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user