update v 1.0.7.5
This commit is contained in:
23
vendor/swiftmailer/swiftmailer/.travis.yml
vendored
23
vendor/swiftmailer/swiftmailer/.travis.yml
vendored
@@ -1,17 +1,13 @@
|
||||
language: php
|
||||
|
||||
php:
|
||||
- 5.3
|
||||
- 5.4
|
||||
- 5.5
|
||||
- 5.6
|
||||
- hhvm-nightly
|
||||
sudo: false
|
||||
|
||||
before_script:
|
||||
- cp tests/acceptance.conf.php.default tests/acceptance.conf.php
|
||||
- cp tests/smoke.conf.php.default tests/smoke.conf.php
|
||||
- composer self-update
|
||||
- composer update --no-interaction --prefer-source
|
||||
- gem install mime-types -v 2.99.1
|
||||
- gem install mailcatcher
|
||||
- mailcatcher --smtp-port 4456
|
||||
|
||||
@@ -19,7 +15,14 @@ script:
|
||||
- phpunit --verbose
|
||||
|
||||
matrix:
|
||||
allow_failures:
|
||||
- php: 5.6
|
||||
- php: hhvm-nightly
|
||||
fast_finish: true
|
||||
include:
|
||||
- php: 5.3
|
||||
- php: 5.4
|
||||
- php: 5.5
|
||||
- php: 5.6
|
||||
- php: 7.0
|
||||
- php: hhvm
|
||||
allow_failures:
|
||||
- php: 7.0
|
||||
- php: hhvm
|
||||
fast_finish: true
|
||||
|
15
vendor/swiftmailer/swiftmailer/CHANGES
vendored
15
vendor/swiftmailer/swiftmailer/CHANGES
vendored
@@ -1,6 +1,21 @@
|
||||
Changelog
|
||||
=========
|
||||
|
||||
5.4.2 (2016-05-01)
|
||||
------------------
|
||||
|
||||
* fixed support for IPv6 sockets
|
||||
* added auto-retry when sending messages from the memory spool
|
||||
* fixed consecutive read calls in Swift_ByteStream_FileByteStream
|
||||
* added support for iso-8859-15 encoding
|
||||
* fixed PHP mail extra params on missing reversePath
|
||||
* added methods to set custom stream context options
|
||||
* fixed charset changes in QpContentEncoderProxy
|
||||
* added return-path header to the ignoredHeaders list of DKIMSigner
|
||||
* fixed crlf for subject using mail
|
||||
* fixed add soft line break only when necessary
|
||||
* fixed escaping command-line args to Sendmail
|
||||
|
||||
5.4.1 (2015-06-06)
|
||||
------------------
|
||||
|
||||
|
2
vendor/swiftmailer/swiftmailer/LICENSE
vendored
2
vendor/swiftmailer/swiftmailer/LICENSE
vendored
@@ -1,4 +1,4 @@
|
||||
Copyright (c) 2013 Fabien Potencier
|
||||
Copyright (c) 2013-2016 Fabien Potencier
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
1
vendor/swiftmailer/swiftmailer/README
vendored
1
vendor/swiftmailer/swiftmailer/README
vendored
@@ -6,7 +6,6 @@ It is released under the MIT license.
|
||||
|
||||
Homepage: http://swiftmailer.org
|
||||
Documentation: http://swiftmailer.org/docs
|
||||
Mailing List: http://groups.google.com/group/swiftmailer
|
||||
Bugs: https://github.com/swiftmailer/swiftmailer/issues
|
||||
Repository: https://github.com/swiftmailer/swiftmailer
|
||||
|
||||
|
2
vendor/swiftmailer/swiftmailer/VERSION
vendored
2
vendor/swiftmailer/swiftmailer/VERSION
vendored
@@ -1 +1 @@
|
||||
Swift-5.4.1
|
||||
Swift-5.4.2
|
||||
|
5
vendor/swiftmailer/swiftmailer/composer.json
vendored
5
vendor/swiftmailer/swiftmailer/composer.json
vendored
@@ -23,6 +23,11 @@
|
||||
"autoload": {
|
||||
"files": ["lib/swift_required.php"]
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-0": {
|
||||
"Swift_": "tests/unit"
|
||||
}
|
||||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "5.4-dev"
|
||||
|
@@ -21,11 +21,11 @@ System Requirements
|
||||
The basic requirements to operate Swift Mailer are extremely minimal and
|
||||
easily achieved. Historically, Swift Mailer has supported both PHP 4 and PHP 5
|
||||
by following a parallel development workflow. Now in it's fourth major
|
||||
version, and Swift Mailer operates on servers running PHP 5.2 or higher.
|
||||
version, and Swift Mailer operates on servers running PHP 5.3.3 or higher.
|
||||
|
||||
The library aims to work with as many PHP 5 projects as possible:
|
||||
|
||||
* PHP 5.2 or higher, with the SPL extension (standard)
|
||||
* PHP 5.3.3 or higher, with the SPL extension (standard)
|
||||
|
||||
* Limited network access to connect to remote SMTP servers
|
||||
|
||||
|
@@ -22,6 +22,8 @@ abstract class Swift_ByteStream_AbstractFilterableInputStream implements Swift_I
|
||||
|
||||
/**
|
||||
* StreamFilters.
|
||||
*
|
||||
* @var Swift_StreamFilter[]
|
||||
*/
|
||||
private $_filters = array();
|
||||
|
||||
|
@@ -82,9 +82,7 @@ class Swift_ByteStream_ArrayByteStream implements Swift_InputByteStream, Swift_O
|
||||
|
||||
// Don't use array slice
|
||||
$end = $length + $this->_offset;
|
||||
$end = $this->_arraySize < $end
|
||||
? $this->_arraySize
|
||||
: $end;
|
||||
$end = $this->_arraySize < $end ? $this->_arraySize : $end;
|
||||
$ret = '';
|
||||
for (; $this->_offset < $end; ++$this->_offset) {
|
||||
$ret .= $this->_array[$this->_offset];
|
||||
|
@@ -139,11 +139,13 @@ class Swift_ByteStream_FileByteStream extends Swift_ByteStream_AbstractFilterabl
|
||||
private function _getReadHandle()
|
||||
{
|
||||
if (!isset($this->_reader)) {
|
||||
if (!$this->_reader = fopen($this->_path, 'rb')) {
|
||||
$pointer = @fopen($this->_path, 'rb');
|
||||
if (!$pointer) {
|
||||
throw new Swift_IoException(
|
||||
'Unable to open file for reading ['.$this->_path.']'
|
||||
);
|
||||
}
|
||||
$this->_reader = $pointer;
|
||||
if ($this->_offset != 0) {
|
||||
$this->_getReadStreamSeekableStatus();
|
||||
$this->_seekReadStreamToPosition($this->_offset);
|
||||
|
@@ -82,7 +82,7 @@ class Swift_CharacterReader_GenericFixedWidthReader implements Swift_CharacterRe
|
||||
{
|
||||
$needed = $this->_width - $size;
|
||||
|
||||
return ($needed > -1) ? $needed : -1;
|
||||
return $needed > -1 ? $needed : -1;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -67,9 +67,9 @@ class Swift_CharacterReader_UsAsciiReader implements Swift_CharacterReader
|
||||
$byte = reset($bytes);
|
||||
if (1 == count($bytes) && $byte >= 0x00 && $byte <= 0x7F) {
|
||||
return 0;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -161,10 +161,7 @@ class Swift_CharacterReader_Utf8Reader implements Swift_CharacterReader
|
||||
}
|
||||
$needed = self::$length_map[$bytes[0]] - $size;
|
||||
|
||||
return ($needed > -1)
|
||||
? $needed
|
||||
: -1
|
||||
;
|
||||
return $needed > -1 ? $needed : -1;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -165,9 +165,7 @@ class Swift_CharacterStream_NgCharacterStream implements Swift_CharacterStream
|
||||
return false;
|
||||
}
|
||||
$ret = false;
|
||||
$length = ($this->_currentPos + $length > $this->_charCount)
|
||||
? $this->_charCount - $this->_currentPos
|
||||
: $length;
|
||||
$length = $this->_currentPos + $length > $this->_charCount ? $this->_charCount - $this->_currentPos : $length;
|
||||
switch ($this->_mapType) {
|
||||
case Swift_CharacterReader::MAP_TYPE_FIXED_LEN:
|
||||
$len = $length * $this->_map;
|
||||
@@ -178,10 +176,6 @@ class Swift_CharacterStream_NgCharacterStream implements Swift_CharacterStream
|
||||
break;
|
||||
|
||||
case Swift_CharacterReader::MAP_TYPE_INVALID:
|
||||
$end = $this->_currentPos + $length;
|
||||
$end = $end > $this->_charCount
|
||||
? $this->_charCount
|
||||
: $end;
|
||||
$ret = '';
|
||||
for (; $this->_currentPos < $length; ++$this->_currentPos) {
|
||||
if (isset($this->_map[$this->_currentPos])) {
|
||||
@@ -194,9 +188,7 @@ class Swift_CharacterStream_NgCharacterStream implements Swift_CharacterStream
|
||||
|
||||
case Swift_CharacterReader::MAP_TYPE_POSITIONS:
|
||||
$end = $this->_currentPos + $length;
|
||||
$end = $end > $this->_charCount
|
||||
? $this->_charCount
|
||||
: $end;
|
||||
$end = $end > $this->_charCount ? $this->_charCount : $end;
|
||||
$ret = '';
|
||||
$start = 0;
|
||||
if ($this->_currentPos > 0) {
|
||||
|
@@ -311,9 +311,9 @@ class Swift_DependencyContainer
|
||||
return $reflector->newInstanceArgs(
|
||||
$this->createDependenciesFor($itemName)
|
||||
);
|
||||
} else {
|
||||
return $reflector->newInstance();
|
||||
}
|
||||
|
||||
return $reflector->newInstance();
|
||||
}
|
||||
|
||||
/** Create and register a shared instance of $itemName */
|
||||
@@ -366,8 +366,8 @@ class Swift_DependencyContainer
|
||||
}
|
||||
|
||||
return $collection;
|
||||
} else {
|
||||
return $this->lookup($item);
|
||||
}
|
||||
|
||||
return $this->lookup($item);
|
||||
}
|
||||
}
|
||||
|
@@ -198,14 +198,25 @@ class Swift_Encoder_QpEncoder implements Swift_Encoder
|
||||
}
|
||||
|
||||
$enc = $this->_encodeByteSequence($bytes, $size);
|
||||
if ($currentLine && $lineLen + $size >= $thisLineLength) {
|
||||
|
||||
$i = strpos($enc, '=0D=0A');
|
||||
$newLineLength = $lineLen + ($i === false ? $size : $i);
|
||||
|
||||
if ($currentLine && $newLineLength >= $thisLineLength) {
|
||||
$lines[$lNo] = '';
|
||||
$currentLine = &$lines[$lNo++];
|
||||
$thisLineLength = $maxLineLength;
|
||||
$lineLen = 0;
|
||||
}
|
||||
$lineLen += $size;
|
||||
|
||||
$currentLine .= $enc;
|
||||
|
||||
if ($i === false) {
|
||||
$lineLen += $size;
|
||||
} else {
|
||||
// 6 is the length of '=0D=0A'.
|
||||
$lineLen = $size - strrpos($enc, '=0D=0A') - 6;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->_standardize(implode("=\r\n", $lines));
|
||||
|
@@ -39,7 +39,7 @@ class Swift_FileSpool extends Swift_ConfigurableSpool
|
||||
|
||||
if (!file_exists($this->_path)) {
|
||||
if (!mkdir($this->_path, 0777, true)) {
|
||||
throw new Swift_IoException('Unable to create Path ['.$this->_path.']');
|
||||
throw new Swift_IoException(sprintf('Unable to create path "%s".', $this->_path));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -108,7 +108,7 @@ class Swift_FileSpool extends Swift_ConfigurableSpool
|
||||
}
|
||||
}
|
||||
|
||||
throw new Swift_IoException('Unable to create a file for enqueuing Message');
|
||||
throw new Swift_IoException(sprintf('Unable to create a file for enqueuing Message in "%s".', $this->_path));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -289,10 +289,7 @@ class Swift_KeyCache_DiskKeyCache implements Swift_KeyCache
|
||||
private function _getHandle($nsKey, $itemKey, $position)
|
||||
{
|
||||
if (!isset($this->_keys[$nsKey][$itemKey])) {
|
||||
$openMode = $this->hasKey($nsKey, $itemKey)
|
||||
? 'r+b'
|
||||
: 'w+b'
|
||||
;
|
||||
$openMode = $this->hasKey($nsKey, $itemKey) ? 'r+b' : 'w+b';
|
||||
$fp = fopen($this->_path.'/'.$nsKey.'/'.$itemKey, $openMode);
|
||||
$this->_keys[$nsKey][$itemKey] = $fp;
|
||||
}
|
||||
|
@@ -69,7 +69,7 @@ class Swift_Mailer
|
||||
* @param Swift_Mime_Message $message
|
||||
* @param array $failedRecipients An array of failures by-reference
|
||||
*
|
||||
* @return int
|
||||
* @return int The number of successful recipients. Can be 0 which indicates failure
|
||||
*/
|
||||
public function send(Swift_Mime_Message $message, &$failedRecipients = null)
|
||||
{
|
||||
|
@@ -16,6 +16,7 @@
|
||||
class Swift_MemorySpool implements Swift_Spool
|
||||
{
|
||||
protected $messages = array();
|
||||
private $flushRetries = 3;
|
||||
|
||||
/**
|
||||
* Tests if this Transport mechanism has started.
|
||||
@@ -41,6 +42,14 @@ class Swift_MemorySpool implements Swift_Spool
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $retries
|
||||
*/
|
||||
public function setFlushRetries($retries)
|
||||
{
|
||||
$this->flushRetries = $retries;
|
||||
}
|
||||
|
||||
/**
|
||||
* Stores a message in the queue.
|
||||
*
|
||||
@@ -75,8 +84,25 @@ class Swift_MemorySpool implements Swift_Spool
|
||||
}
|
||||
|
||||
$count = 0;
|
||||
while ($message = array_pop($this->messages)) {
|
||||
$count += $transport->send($message, $failedRecipients);
|
||||
$retries = $this->flushRetries;
|
||||
while ($retries--) {
|
||||
try {
|
||||
while ($message = array_pop($this->messages)) {
|
||||
$count += $transport->send($message, $failedRecipients);
|
||||
}
|
||||
} catch (Swift_TransportException $exception) {
|
||||
if ($retries) {
|
||||
// re-queue the message at the end of the queue to give a chance
|
||||
// to the other messages to be sent, in case the failure was due to
|
||||
// this message and not just the transport failing
|
||||
array_unshift($this->messages, $message);
|
||||
|
||||
// wait half a second before we try again
|
||||
usleep(500000);
|
||||
} else {
|
||||
throw $exception;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $count;
|
||||
|
@@ -69,9 +69,7 @@ class Swift_Mime_Attachment extends Swift_Mime_SimpleMimeEntity
|
||||
public function setDisposition($disposition)
|
||||
{
|
||||
if (!$this->_setHeaderFieldModel('Content-Disposition', $disposition)) {
|
||||
$this->getHeaders()->addParameterizedHeader(
|
||||
'Content-Disposition', $disposition
|
||||
);
|
||||
$this->getHeaders()->addParameterizedHeader('Content-Disposition', $disposition);
|
||||
}
|
||||
|
||||
return $this;
|
||||
@@ -139,9 +137,7 @@ class Swift_Mime_Attachment extends Swift_Mime_SimpleMimeEntity
|
||||
$this->setFilename(basename($file->getPath()));
|
||||
$this->setBody($file, $contentType);
|
||||
if (!isset($contentType)) {
|
||||
$extension = strtolower(substr(
|
||||
$file->getPath(), strrpos($file->getPath(), '.') + 1
|
||||
));
|
||||
$extension = strtolower(substr($file->getPath(), strrpos($file->getPath(), '.') + 1));
|
||||
|
||||
if (array_key_exists($extension, $this->_mimeTypes)) {
|
||||
$this->setContentType($this->_mimeTypes[$extension]);
|
||||
|
@@ -95,15 +95,26 @@ class Swift_Mime_ContentEncoder_QpContentEncoder extends Swift_Encoder_QpEncoder
|
||||
}
|
||||
|
||||
$enc = $this->_encodeByteSequence($bytes, $size);
|
||||
if ($currentLine && $lineLen + $size >= $thisLineLength) {
|
||||
|
||||
$i = strpos($enc, '=0D=0A');
|
||||
$newLineLength = $lineLen + ($i === false ? $size : $i);
|
||||
|
||||
if ($currentLine && $newLineLength >= $thisLineLength) {
|
||||
$is->write($prepend.$this->_standardize($currentLine));
|
||||
$currentLine = '';
|
||||
$prepend = "=\r\n";
|
||||
$thisLineLength = $maxLineLength;
|
||||
$lineLen = 0;
|
||||
}
|
||||
$lineLen += $size;
|
||||
|
||||
$currentLine .= $enc;
|
||||
|
||||
if ($i === false) {
|
||||
$lineLen += $size;
|
||||
} else {
|
||||
// 6 is the length of '=0D=0A'.
|
||||
$lineLen = $size - strrpos($enc, '=0D=0A') - 6;
|
||||
}
|
||||
}
|
||||
if (strlen($currentLine)) {
|
||||
$is->write($prepend.$this->_standardize($currentLine));
|
||||
|
@@ -61,6 +61,7 @@ class Swift_Mime_ContentEncoder_QpContentEncoderProxy implements Swift_Mime_Cont
|
||||
public function charsetChanged($charset)
|
||||
{
|
||||
$this->charset = $charset;
|
||||
$this->safeEncoder->charsetChanged($charset);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -129,11 +129,11 @@ class Swift_Mime_Grammar
|
||||
{
|
||||
if (array_key_exists($name, self::$_grammar)) {
|
||||
return self::$_grammar[$name];
|
||||
} else {
|
||||
throw new Swift_RfcComplianceException(
|
||||
"No such grammar '".$name."' defined."
|
||||
);
|
||||
}
|
||||
|
||||
throw new Swift_RfcComplianceException(
|
||||
"No such grammar '".$name."' defined."
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -98,9 +98,7 @@ class Swift_Mime_Headers_ParameterizedHeader extends Swift_Mime_Headers_Unstruct
|
||||
{
|
||||
$params = $this->getParameters();
|
||||
|
||||
return array_key_exists($parameter, $params)
|
||||
? $params[$parameter]
|
||||
: null;
|
||||
return array_key_exists($parameter, $params) ? $params[$parameter] : null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -128,9 +128,7 @@ class Swift_Mime_MimePart extends Swift_Mime_SimpleMimeEntity
|
||||
*/
|
||||
public function getDelSp()
|
||||
{
|
||||
return ($this->_getHeaderParameter('Content-Type', 'delsp') == 'yes')
|
||||
? true
|
||||
: false;
|
||||
return 'yes' == $this->_getHeaderParameter('Content-Type', 'delsp') ? true : false;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -196,7 +194,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', ''))) {
|
||||
if (!in_array($charset, array('utf-8', 'iso-8859-1', 'iso-8859-15', ''))) {
|
||||
// mb_convert_encoding must be the first one to check, since iconv cannot convert some words.
|
||||
if (function_exists('mb_convert_encoding')) {
|
||||
$string = mb_convert_encoding($string, $charset, 'utf-8');
|
||||
|
@@ -112,12 +112,7 @@ class Swift_Mime_SimpleHeaderFactory implements Swift_Mime_HeaderFactory
|
||||
public function createParameterizedHeader($name, $value = null,
|
||||
$params = array())
|
||||
{
|
||||
$header = new Swift_Mime_Headers_ParameterizedHeader($name,
|
||||
$this->_encoder, (strtolower($name) == 'content-disposition')
|
||||
? $this->_paramEncoder
|
||||
: null,
|
||||
$this->_grammar
|
||||
);
|
||||
$header = new Swift_Mime_Headers_ParameterizedHeader($name, $this->_encoder, strtolower($name) == 'content-disposition' ? $this->_paramEncoder : null, $this->_grammar);
|
||||
if (isset($value)) {
|
||||
$header->setFieldBodyModel($value);
|
||||
}
|
||||
|
@@ -349,12 +349,13 @@ class Swift_Mime_SimpleHeaderSet implements Swift_Mime_HeaderSet
|
||||
{
|
||||
$lowerA = strtolower($a);
|
||||
$lowerB = strtolower($b);
|
||||
$aPos = array_key_exists($lowerA, $this->_order)
|
||||
? $this->_order[$lowerA]
|
||||
: -1;
|
||||
$bPos = array_key_exists($lowerB, $this->_order)
|
||||
? $this->_order[$lowerB]
|
||||
: -1;
|
||||
$aPos = array_key_exists($lowerA, $this->_order) ? $this->_order[$lowerA] : -1;
|
||||
$bPos = array_key_exists($lowerB, $this->_order) ? $this->_order[$lowerB] : -1;
|
||||
|
||||
if (-1 === $aPos && -1 === $bPos) {
|
||||
// just be sure to be determinist here
|
||||
return $a > $b ? -1 : 1;
|
||||
}
|
||||
|
||||
if ($aPos == -1) {
|
||||
return 1;
|
||||
@@ -362,7 +363,7 @@ class Swift_Mime_SimpleHeaderSet implements Swift_Mime_HeaderSet
|
||||
return -1;
|
||||
}
|
||||
|
||||
return ($aPos < $bPos) ? -1 : 1;
|
||||
return $aPos < $bPos ? -1 : 1;
|
||||
}
|
||||
|
||||
/** Test if the given Header is always displayed */
|
||||
|
@@ -253,7 +253,7 @@ class Swift_Mime_SimpleMessage extends Swift_Mime_MimePart implements Swift_Mime
|
||||
* If $name is passed and the first parameter is a string, this name will be
|
||||
* associated with the address.
|
||||
*
|
||||
* @param string $addresses
|
||||
* @param mixed $addresses
|
||||
* @param string $name optional
|
||||
*
|
||||
* @return Swift_Mime_SimpleMessage
|
||||
|
@@ -282,11 +282,7 @@ class Swift_Mime_SimpleMimeEntity implements Swift_Mime_MimeEntity
|
||||
{
|
||||
// TODO: Try to refactor this logic
|
||||
|
||||
$compoundLevel = isset($compoundLevel)
|
||||
? $compoundLevel
|
||||
: $this->_getCompoundLevel($children)
|
||||
;
|
||||
|
||||
$compoundLevel = isset($compoundLevel) ? $compoundLevel : $this->_getCompoundLevel($children);
|
||||
$immediateChildren = array();
|
||||
$grandchildren = array();
|
||||
$newContentType = $this->_userContentType;
|
||||
@@ -311,15 +307,15 @@ class Swift_Mime_SimpleMimeEntity implements Swift_Mime_MimeEntity
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($immediateChildren)) {
|
||||
if ($immediateChildren) {
|
||||
$lowestLevel = $this->_getNeededChildLevel($immediateChildren[0], $compoundLevel);
|
||||
|
||||
// Determine which composite media type is needed to accommodate the
|
||||
// immediate children
|
||||
foreach ($this->_compositeRanges as $mediaType => $range) {
|
||||
if ($lowestLevel > $range[0]
|
||||
&& $lowestLevel <= $range[1]) {
|
||||
if ($lowestLevel > $range[0] && $lowestLevel <= $range[1]) {
|
||||
$newContentType = $mediaType;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -349,9 +345,7 @@ class Swift_Mime_SimpleMimeEntity implements Swift_Mime_MimeEntity
|
||||
*/
|
||||
public function getBody()
|
||||
{
|
||||
return ($this->_body instanceof Swift_OutputByteStream)
|
||||
? $this->_readStream($this->_body)
|
||||
: $this->_body;
|
||||
return $this->_body instanceof Swift_OutputByteStream ? $this->_readStream($this->_body) : $this->_body;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -486,12 +480,8 @@ class Swift_Mime_SimpleMimeEntity implements Swift_Mime_MimeEntity
|
||||
if ($this->_cache->hasKey($this->_cacheKey, 'body')) {
|
||||
$body = $this->_cache->getString($this->_cacheKey, 'body');
|
||||
} else {
|
||||
$body = "\r\n".$this->_encoder->encodeString($this->getBody(), 0,
|
||||
$this->getMaxLineLength()
|
||||
);
|
||||
$this->_cache->setString($this->_cacheKey, 'body', $body,
|
||||
Swift_KeyCache::MODE_WRITE
|
||||
);
|
||||
$body = "\r\n".$this->_encoder->encodeString($this->getBody(), 0, $this->getMaxLineLength());
|
||||
$this->_cache->setString($this->_cacheKey, 'body', $body, Swift_KeyCache::MODE_WRITE);
|
||||
}
|
||||
$string .= $body;
|
||||
}
|
||||
@@ -602,9 +592,9 @@ class Swift_Mime_SimpleMimeEntity implements Swift_Mime_MimeEntity
|
||||
$this->_headers->get($field)->setFieldBodyModel($model);
|
||||
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -626,9 +616,9 @@ class Swift_Mime_SimpleMimeEntity implements Swift_Mime_MimeEntity
|
||||
$this->_headers->get($field)->setParameter($parameter, $value);
|
||||
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -716,9 +706,7 @@ class Swift_Mime_SimpleMimeEntity implements Swift_Mime_MimeEntity
|
||||
|
||||
private function _assertValidBoundary($boundary)
|
||||
{
|
||||
if (!preg_match(
|
||||
'/^[a-z0-9\'\(\)\+_\-,\.\/:=\?\ ]{0,69}[a-z0-9\'\(\)\+_\-,\.\/:=\?]$/Di',
|
||||
$boundary)) {
|
||||
if (!preg_match('/^[a-z0-9\'\(\)\+_\-,\.\/:=\?\ ]{0,69}[a-z0-9\'\(\)\+_\-,\.\/:=\?]$/Di', $boundary)) {
|
||||
throw new Swift_RfcComplianceException('Mime boundary set is not RFC 2046 compliant.');
|
||||
}
|
||||
}
|
||||
@@ -757,18 +745,16 @@ class Swift_Mime_SimpleMimeEntity implements Swift_Mime_MimeEntity
|
||||
$realLevel = $child->getNestingLevel();
|
||||
$lowercaseType = strtolower($child->getContentType());
|
||||
|
||||
if (isset($filter[$realLevel])
|
||||
&& isset($filter[$realLevel][$lowercaseType])) {
|
||||
if (isset($filter[$realLevel]) && isset($filter[$realLevel][$lowercaseType])) {
|
||||
return $filter[$realLevel][$lowercaseType];
|
||||
} else {
|
||||
return $realLevel;
|
||||
}
|
||||
|
||||
return $realLevel;
|
||||
}
|
||||
|
||||
private function _createChild()
|
||||
{
|
||||
return new self($this->_headers->newInstance(),
|
||||
$this->_encoder, $this->_cache, $this->_grammar);
|
||||
return new self($this->_headers->newInstance(), $this->_encoder, $this->_cache, $this->_grammar);
|
||||
}
|
||||
|
||||
private function _notifyEncoderChanged(Swift_Mime_ContentEncoder $encoder)
|
||||
@@ -807,17 +793,13 @@ class Swift_Mime_SimpleMimeEntity implements Swift_Mime_MimeEntity
|
||||
private function _childSortAlgorithm($a, $b)
|
||||
{
|
||||
$typePrefs = array();
|
||||
$types = array(
|
||||
strtolower($a->getContentType()),
|
||||
strtolower($b->getContentType()),
|
||||
);
|
||||
$types = array(strtolower($a->getContentType()), strtolower($b->getContentType()));
|
||||
|
||||
foreach ($types as $type) {
|
||||
$typePrefs[] = (array_key_exists($type, $this->_alternativePartOrder))
|
||||
? $this->_alternativePartOrder[$type]
|
||||
: (max($this->_alternativePartOrder) + 1);
|
||||
$typePrefs[] = array_key_exists($type, $this->_alternativePartOrder) ? $this->_alternativePartOrder[$type] : max($this->_alternativePartOrder) + 1;
|
||||
}
|
||||
|
||||
return ($typePrefs[0] >= $typePrefs[1]) ? 1 : -1;
|
||||
return $typePrefs[0] >= $typePrefs[1] ? 1 : -1;
|
||||
}
|
||||
|
||||
// -- Destructor
|
||||
@@ -839,14 +821,8 @@ class Swift_Mime_SimpleMimeEntity implements Swift_Mime_MimeEntity
|
||||
*/
|
||||
private function _assertValidId($id)
|
||||
{
|
||||
if (!preg_match(
|
||||
'/^'.$this->_grammar->getDefinition('id-left').'@'.
|
||||
$this->_grammar->getDefinition('id-right').'$/D',
|
||||
$id
|
||||
)) {
|
||||
throw new Swift_RfcComplianceException(
|
||||
'Invalid ID given <'.$id.'>'
|
||||
);
|
||||
if (!preg_match('/^'.$this->_grammar->getDefinition('id-left').'@'.$this->_grammar->getDefinition('id-right').'$/D', $id)) {
|
||||
throw new Swift_RfcComplianceException('Invalid ID given <'.$id.'>');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -857,7 +833,7 @@ class Swift_Mime_SimpleMimeEntity implements Swift_Mime_MimeEntity
|
||||
{
|
||||
$this->_headers = clone $this->_headers;
|
||||
$this->_encoder = clone $this->_encoder;
|
||||
$this->_cacheKey = uniqid();
|
||||
$this->_cacheKey = md5(uniqid(getmypid().mt_rand(), true));
|
||||
$children = array();
|
||||
foreach ($this->_children as $pos => $child) {
|
||||
$children[$pos] = clone $child;
|
||||
|
@@ -157,12 +157,9 @@ class Swift_Plugins_DecoratorPlugin implements Swift_Events_SendListener, Swift_
|
||||
{
|
||||
if ($this->_replacements instanceof Swift_Plugins_Decorator_Replacements) {
|
||||
return $this->_replacements->getReplacementsFor($address);
|
||||
} else {
|
||||
return isset($this->_replacements[$address])
|
||||
? $this->_replacements[$address]
|
||||
: null
|
||||
;
|
||||
}
|
||||
|
||||
return isset($this->_replacements[$address]) ? $this->_replacements[$address] : null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -49,25 +49,13 @@ class Swift_Plugins_ReporterPlugin implements Swift_Events_SendListener
|
||||
$message = $evt->getMessage();
|
||||
$failures = array_flip($evt->getFailedRecipients());
|
||||
foreach ((array) $message->getTo() as $address => $null) {
|
||||
$this->_reporter->notify(
|
||||
$message, $address, (array_key_exists($address, $failures)
|
||||
? Swift_Plugins_Reporter::RESULT_FAIL
|
||||
: Swift_Plugins_Reporter::RESULT_PASS)
|
||||
);
|
||||
$this->_reporter->notify($message, $address, array_key_exists($address, $failures) ? Swift_Plugins_Reporter::RESULT_FAIL : Swift_Plugins_Reporter::RESULT_PASS);
|
||||
}
|
||||
foreach ((array) $message->getCc() as $address => $null) {
|
||||
$this->_reporter->notify(
|
||||
$message, $address, (array_key_exists($address, $failures)
|
||||
? Swift_Plugins_Reporter::RESULT_FAIL
|
||||
: Swift_Plugins_Reporter::RESULT_PASS)
|
||||
);
|
||||
$this->_reporter->notify($message, $address, array_key_exists($address, $failures) ? Swift_Plugins_Reporter::RESULT_FAIL : Swift_Plugins_Reporter::RESULT_PASS);
|
||||
}
|
||||
foreach ((array) $message->getBcc() as $address => $null) {
|
||||
$this->_reporter->notify(
|
||||
$message, $address, (array_key_exists($address, $failures)
|
||||
? Swift_Plugins_Reporter::RESULT_FAIL
|
||||
: Swift_Plugins_Reporter::RESULT_PASS)
|
||||
);
|
||||
$this->_reporter->notify($message, $address, array_key_exists($address, $failures) ? Swift_Plugins_Reporter::RESULT_FAIL : Swift_Plugins_Reporter::RESULT_PASS);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -151,9 +151,9 @@ class Swift_Plugins_ThrottlerPlugin extends Swift_Plugins_BandwidthMonitorPlugin
|
||||
{
|
||||
if (isset($this->_timer)) {
|
||||
return $this->_timer->getTimestamp();
|
||||
} else {
|
||||
return time();
|
||||
}
|
||||
|
||||
return time();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -62,12 +62,12 @@ class Swift_Signers_DKIMSigner implements Swift_Signers_HeaderSigner
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $_ignoredHeaders = array();
|
||||
protected $_ignoredHeaders = array('return-path' => true);
|
||||
|
||||
/**
|
||||
* Signer identity.
|
||||
*
|
||||
* @var unknown_type
|
||||
* @var string
|
||||
*/
|
||||
protected $_signerIdentity;
|
||||
|
||||
@@ -143,13 +143,6 @@ class Swift_Signers_DKIMSigner implements Swift_Signers_HeaderSigner
|
||||
*/
|
||||
protected $_dkimHeader;
|
||||
|
||||
/**
|
||||
* Hash Handler.
|
||||
*
|
||||
* @var hash_ressource
|
||||
*/
|
||||
private $_headerHashHandler;
|
||||
|
||||
private $_bodyHashHandler;
|
||||
|
||||
private $_headerHash;
|
||||
@@ -206,7 +199,6 @@ class Swift_Signers_DKIMSigner implements Swift_Signers_HeaderSigner
|
||||
{
|
||||
$this->_headerHash = null;
|
||||
$this->_signedHeaders = array();
|
||||
$this->_headerHashHandler = null;
|
||||
$this->_bodyHash = null;
|
||||
$this->_bodyHashHandler = null;
|
||||
$this->_bodyCanonIgnoreStart = 2;
|
||||
@@ -381,7 +373,7 @@ class Swift_Signers_DKIMSigner implements Swift_Signers_HeaderSigner
|
||||
$this->_showLen = true;
|
||||
$this->_maxLen = PHP_INT_MAX;
|
||||
} elseif ($len === false) {
|
||||
$this->showLen = false;
|
||||
$this->_showLen = false;
|
||||
$this->_maxLen = PHP_INT_MAX;
|
||||
} else {
|
||||
$this->_showLen = true;
|
||||
@@ -394,7 +386,7 @@ class Swift_Signers_DKIMSigner implements Swift_Signers_HeaderSigner
|
||||
/**
|
||||
* Set the signature timestamp.
|
||||
*
|
||||
* @param timestamp $time
|
||||
* @param int $time A timestamp
|
||||
*
|
||||
* @return Swift_Signers_DKIMSigner
|
||||
*/
|
||||
@@ -408,7 +400,7 @@ class Swift_Signers_DKIMSigner implements Swift_Signers_HeaderSigner
|
||||
/**
|
||||
* Set the signature expiration timestamp.
|
||||
*
|
||||
* @param timestamp $time
|
||||
* @param int $time A timestamp
|
||||
*
|
||||
* @return Swift_Signers_DKIMSigner
|
||||
*/
|
||||
@@ -588,9 +580,13 @@ class Swift_Signers_DKIMSigner implements Swift_Signers_HeaderSigner
|
||||
$this->_addToHeaderHash($header);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated This method is currently useless in this class but it must be
|
||||
* kept for BC reasons due to its "protected" scope. This method
|
||||
* might be overriden by custom client code.
|
||||
*/
|
||||
protected function _endOfHeaders()
|
||||
{
|
||||
//$this->_headerHash=hash_final($this->_headerHashHandler, true);
|
||||
}
|
||||
|
||||
protected function _canonicalizeBody($string)
|
||||
|
@@ -141,7 +141,7 @@ class Swift_Signers_DomainKeySigner implements Swift_Signers_HeaderSigner
|
||||
/**
|
||||
* Resets internal states.
|
||||
*
|
||||
* @return Swift_Signers_DomainKeysSigner
|
||||
* @return Swift_Signers_DomainKeySigner
|
||||
*/
|
||||
public function reset()
|
||||
{
|
||||
@@ -170,7 +170,7 @@ class Swift_Signers_DomainKeySigner implements Swift_Signers_HeaderSigner
|
||||
* @throws Swift_IoException
|
||||
*
|
||||
* @return int
|
||||
* @return Swift_Signers_DomainKeysSigner
|
||||
* @return Swift_Signers_DomainKeySigner
|
||||
*/
|
||||
public function write($bytes)
|
||||
{
|
||||
@@ -188,7 +188,7 @@ class Swift_Signers_DomainKeySigner implements Swift_Signers_HeaderSigner
|
||||
*
|
||||
* @throws Swift_IoException
|
||||
*
|
||||
* @return Swift_Signers_DomainKeysSigner
|
||||
* @return Swift_Signers_DomainKeySigner
|
||||
*/
|
||||
public function commit()
|
||||
{
|
||||
@@ -203,7 +203,7 @@ class Swift_Signers_DomainKeySigner implements Swift_Signers_HeaderSigner
|
||||
*
|
||||
* @param Swift_InputByteStream $is
|
||||
*
|
||||
* @return Swift_Signers_DomainKeysSigner
|
||||
* @return Swift_Signers_DomainKeySigner
|
||||
*/
|
||||
public function bind(Swift_InputByteStream $is)
|
||||
{
|
||||
@@ -221,7 +221,7 @@ class Swift_Signers_DomainKeySigner implements Swift_Signers_HeaderSigner
|
||||
*
|
||||
* @param Swift_InputByteStream $is
|
||||
*
|
||||
* @return Swift_Signers_DomainKeysSigner
|
||||
* @return Swift_Signers_DomainKeySigner
|
||||
*/
|
||||
public function unbind(Swift_InputByteStream $is)
|
||||
{
|
||||
@@ -243,7 +243,7 @@ class Swift_Signers_DomainKeySigner implements Swift_Signers_HeaderSigner
|
||||
*
|
||||
* @throws Swift_IoException
|
||||
*
|
||||
* @return Swift_Signers_DomainKeysSigner
|
||||
* @return Swift_Signers_DomainKeySigner
|
||||
*/
|
||||
public function flushBuffers()
|
||||
{
|
||||
@@ -257,7 +257,7 @@ class Swift_Signers_DomainKeySigner implements Swift_Signers_HeaderSigner
|
||||
*
|
||||
* @param string $hash
|
||||
*
|
||||
* @return Swift_Signers_DomainKeysSigner
|
||||
* @return Swift_Signers_DomainKeySigner
|
||||
*/
|
||||
public function setHashAlgorithm($hash)
|
||||
{
|
||||
@@ -271,7 +271,7 @@ class Swift_Signers_DomainKeySigner implements Swift_Signers_HeaderSigner
|
||||
*
|
||||
* @param string $canon simple | nofws defaults to simple
|
||||
*
|
||||
* @return Swift_Signers_DomainKeysSigner
|
||||
* @return Swift_Signers_DomainKeySigner
|
||||
*/
|
||||
public function setCanon($canon)
|
||||
{
|
||||
@@ -336,9 +336,9 @@ class Swift_Signers_DomainKeySigner implements Swift_Signers_HeaderSigner
|
||||
{
|
||||
if ($this->_debugHeaders) {
|
||||
return array('DomainKey-Signature', 'X-DebugHash');
|
||||
} else {
|
||||
return array('DomainKey-Signature');
|
||||
}
|
||||
|
||||
return array('DomainKey-Signature');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -502,7 +502,7 @@ class Swift_Signers_DomainKeySigner implements Swift_Signers_HeaderSigner
|
||||
$this->_hashHandler = hash_init('sha1');
|
||||
break;
|
||||
}
|
||||
$this->_canonLine = '';
|
||||
$this->_bodyCanonLine = '';
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -29,11 +29,12 @@ class Swift_Signers_OpenDKIMSigner extends Swift_Signers_DKIMSigner
|
||||
|
||||
public function __construct($privateKey, $domainName, $selector)
|
||||
{
|
||||
if (extension_loaded('opendkim')) {
|
||||
$this->_peclLoaded = true;
|
||||
} else {
|
||||
if (!extension_loaded('opendkim')) {
|
||||
throw new Swift_SwiftException('php-opendkim extension not found');
|
||||
}
|
||||
|
||||
$this->_peclLoaded = true;
|
||||
|
||||
parent::__construct($privateKey, $domainName, $selector);
|
||||
}
|
||||
|
||||
@@ -61,9 +62,9 @@ class Swift_Signers_OpenDKIMSigner extends Swift_Signers_DKIMSigner
|
||||
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;
|
||||
$hash = $this->_hashAlgorithm == 'rsa-sha1' ? OpenDKIMSign::ALG_RSASHA1 : OpenDKIMSign::ALG_RSASHA256;
|
||||
$bodyCanon = $this->_bodyCanon == 'simple' ? OpenDKIMSign::CANON_SIMPLE : OpenDKIMSign::CANON_RELAXED;
|
||||
$headerCanon = $this->_headerCanon == 'simple' ? OpenDKIMSign::CANON_SIMPLE : OpenDKIMSign::CANON_RELAXED;
|
||||
$this->_dkimHandler = new OpenDKIMSign($this->_privateKey, $this->_selector, $this->_domainName, $headerCanon, $bodyCanon, $hash, $bodyLen);
|
||||
// Hardcode signature Margin for now
|
||||
$this->_dkimHandler->setMargin(78);
|
||||
@@ -130,7 +131,7 @@ class Swift_Signers_OpenDKIMSigner extends Swift_Signers_DKIMSigner
|
||||
/**
|
||||
* Set the signature timestamp.
|
||||
*
|
||||
* @param timestamp $time
|
||||
* @param int $time
|
||||
*
|
||||
* @return Swift_Signers_DKIMSigner
|
||||
*/
|
||||
@@ -144,7 +145,7 @@ class Swift_Signers_OpenDKIMSigner extends Swift_Signers_DKIMSigner
|
||||
/**
|
||||
* Set the signature expiration timestamp.
|
||||
*
|
||||
* @param timestamp $time
|
||||
* @param int $time
|
||||
*
|
||||
* @return Swift_Signers_DKIMSigner
|
||||
*/
|
||||
|
@@ -41,9 +41,9 @@ class Swift_Signers_SMimeSigner implements Swift_Signers_BodySigner
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $certificate
|
||||
* @param string $privateKey
|
||||
* @param string $encryptCertificate
|
||||
* @param string|null $signCertificate
|
||||
* @param string|null $signPrivateKey
|
||||
* @param string|null $encryptCertificate
|
||||
*/
|
||||
public function __construct($signCertificate = null, $signPrivateKey = null, $encryptCertificate = null)
|
||||
{
|
||||
@@ -167,7 +167,7 @@ class Swift_Signers_SMimeSigner implements Swift_Signers_BodySigner
|
||||
* But some older mail clients, namely Microsoft Outlook 2000 will work when the message first encrypted.
|
||||
* As this goes against the official specs, its recommended to only use 'encryption -> signing' when specifically targeting these 'broken' clients.
|
||||
*
|
||||
* @param string $signThenEncrypt
|
||||
* @param bool $signThenEncrypt
|
||||
*
|
||||
* @return Swift_Signers_SMimeSigner
|
||||
*/
|
||||
@@ -400,7 +400,6 @@ class Swift_Signers_SMimeSigner implements Swift_Signers_BodySigner
|
||||
}
|
||||
|
||||
$boundary = trim($contentTypeData['1'], '"');
|
||||
$boundaryLen = strlen($boundary);
|
||||
|
||||
// Skip the header and CRLF CRLF
|
||||
$fromStream->setReadPointer($headersPosEnd + 4);
|
||||
|
@@ -417,7 +417,7 @@ abstract class Swift_Transport_AbstractSmtpTransport implements Swift_Transport
|
||||
foreach ($recipients as $forwardPath) {
|
||||
try {
|
||||
$this->_doRcptToCommand($forwardPath);
|
||||
$sent++;
|
||||
++$sent;
|
||||
} catch (Swift_TransportException $e) {
|
||||
$failedRecipients[] = $forwardPath;
|
||||
}
|
||||
@@ -461,11 +461,17 @@ abstract class Swift_Transport_AbstractSmtpTransport implements Swift_Transport
|
||||
/** Try to determine the hostname of the server this is run on */
|
||||
private function _lookupHostname()
|
||||
{
|
||||
if (!empty($_SERVER['SERVER_NAME'])
|
||||
&& $this->_isFqdn($_SERVER['SERVER_NAME'])) {
|
||||
if (!empty($_SERVER['SERVER_NAME']) && $this->_isFqdn($_SERVER['SERVER_NAME'])) {
|
||||
$this->_domain = $_SERVER['SERVER_NAME'];
|
||||
} elseif (!empty($_SERVER['SERVER_ADDR'])) {
|
||||
$this->_domain = sprintf('[%s]', $_SERVER['SERVER_ADDR']);
|
||||
// Set the address literal tag (See RFC 5321, section: 4.1.3)
|
||||
if (false === strpos($_SERVER['SERVER_ADDR'], ':')) {
|
||||
$prefix = ''; // IPv4 addresses are not tagged.
|
||||
} else {
|
||||
$prefix = 'IPv6:'; // Adding prefix in case of IPv6.
|
||||
}
|
||||
|
||||
$this->_domain = sprintf('[%s%s]', $prefix, $_SERVER['SERVER_ADDR']);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -475,9 +481,9 @@ abstract class Swift_Transport_AbstractSmtpTransport implements Swift_Transport
|
||||
// We could do a really thorough check, but there's really no point
|
||||
if (false !== $dotPos = strpos($hostname, '.')) {
|
||||
return ($dotPos > 0) && ($dotPos != strlen($hostname) - 1);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -373,7 +373,7 @@ class Swift_Transport_Esmtp_Auth_NTLMAuthenticator implements Swift_Transport_Es
|
||||
|
||||
$binary = $this->si2bin($time, 64); // create 64 bit binary string
|
||||
$timestamp = '';
|
||||
for ($i = 0; $i < 8; $i++) {
|
||||
for ($i = 0; $i < 8; ++$i) {
|
||||
$timestamp .= chr(bindec(substr($binary, -(($i + 1) * 8), 8)));
|
||||
}
|
||||
|
||||
@@ -437,7 +437,7 @@ class Swift_Transport_Esmtp_Auth_NTLMAuthenticator implements Swift_Transport_Es
|
||||
{
|
||||
$material = array(bin2hex($key[0]));
|
||||
$len = strlen($key);
|
||||
for ($i = 1; $i < $len; $i++) {
|
||||
for ($i = 1; $i < $len; ++$i) {
|
||||
list($high, $low) = str_split(bin2hex($key[$i]));
|
||||
$v = $this->castToByte(ord($key[$i - 1]) << (7 + 1 - $i) | $this->uRShift(hexdec(dechex(hexdec($high) & 0xf).dechex(hexdec($low) & 0xf)), $i));
|
||||
$material[] = str_pad(substr(dechex($v), -2), 2, '0', STR_PAD_LEFT); // cast to byte
|
||||
|
@@ -172,7 +172,7 @@ class Swift_Transport_Esmtp_AuthHandler implements Swift_Transport_EsmtpHandler
|
||||
foreach ($this->_getAuthenticatorsForAgent() as $authenticator) {
|
||||
if (in_array(strtolower($authenticator->getAuthKeyword()),
|
||||
array_map('strtolower', $this->_esmtpParams))) {
|
||||
$count++;
|
||||
++$count;
|
||||
if ($authenticator->authenticate($agent, $this->_username, $this->_password)) {
|
||||
return;
|
||||
}
|
||||
|
@@ -42,6 +42,7 @@ class Swift_Transport_EsmtpTransport extends Swift_Transport_AbstractSmtpTranspo
|
||||
'blocking' => 1,
|
||||
'tls' => false,
|
||||
'type' => Swift_Transport_IoBuffer::TYPE_SOCKET,
|
||||
'stream_context_options' => array(),
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -139,6 +140,7 @@ class Swift_Transport_EsmtpTransport extends Swift_Transport_AbstractSmtpTranspo
|
||||
*/
|
||||
public function setEncryption($encryption)
|
||||
{
|
||||
$encryption = strtolower($encryption);
|
||||
if ('tls' == $encryption) {
|
||||
$this->_params['protocol'] = 'tcp';
|
||||
$this->_params['tls'] = true;
|
||||
@@ -160,6 +162,30 @@ class Swift_Transport_EsmtpTransport extends Swift_Transport_AbstractSmtpTranspo
|
||||
return $this->_params['tls'] ? 'tls' : $this->_params['protocol'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the stream context options.
|
||||
*
|
||||
* @param array $options
|
||||
*
|
||||
* @return Swift_Transport_EsmtpTransport
|
||||
*/
|
||||
public function setStreamOptions($options)
|
||||
{
|
||||
$this->_params['stream_context_options'] = $options;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the stream context options.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getStreamOptions()
|
||||
{
|
||||
return $this->_params['stream_context_options'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the source IP.
|
||||
*
|
||||
@@ -197,7 +223,8 @@ class Swift_Transport_EsmtpTransport extends Swift_Transport_AbstractSmtpTranspo
|
||||
foreach ($handlers as $handler) {
|
||||
$assoc[$handler->getHandledKeyword()] = $handler;
|
||||
}
|
||||
uasort($assoc, array($this, '_sortHandlers'));
|
||||
|
||||
@uasort($assoc, array($this, '_sortHandlers'));
|
||||
$this->_handlers = $assoc;
|
||||
$this->_setHandlerParams();
|
||||
|
||||
|
@@ -22,9 +22,7 @@ class Swift_Transport_FailoverTransport extends Swift_Transport_LoadBalancedTran
|
||||
*/
|
||||
private $_currentTransport;
|
||||
|
||||
/**
|
||||
* Creates a new FailoverTransport.
|
||||
*/
|
||||
// needed as __construct is called from elsewhere explicitly
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
@@ -45,6 +43,7 @@ class Swift_Transport_FailoverTransport extends Swift_Transport_LoadBalancedTran
|
||||
{
|
||||
$maxTransports = count($this->_transports);
|
||||
$sent = 0;
|
||||
$this->_lastUsedTransport = null;
|
||||
|
||||
for ($i = 0; $i < $maxTransports
|
||||
&& $transport = $this->_getNextTransport(); ++$i) {
|
||||
@@ -53,7 +52,11 @@ class Swift_Transport_FailoverTransport extends Swift_Transport_LoadBalancedTran
|
||||
$transport->start();
|
||||
}
|
||||
|
||||
return $transport->send($message, $failedRecipients);
|
||||
if ($sent = $transport->send($message, $failedRecipients)) {
|
||||
$this->_lastUsedTransport = $transport;
|
||||
|
||||
return $sent;
|
||||
}
|
||||
} catch (Swift_TransportException $e) {
|
||||
$this->_killCurrentTransport();
|
||||
}
|
||||
|
@@ -30,8 +30,13 @@ class Swift_Transport_LoadBalancedTransport implements Swift_Transport
|
||||
protected $_transports = array();
|
||||
|
||||
/**
|
||||
* Creates a new LoadBalancedTransport.
|
||||
* The Transport used in the last successful send operation.
|
||||
*
|
||||
* @var Swift_Transport
|
||||
*/
|
||||
protected $_lastUsedTransport = null;
|
||||
|
||||
// needed as __construct is called from elsewhere explicitly
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
@@ -57,6 +62,16 @@ class Swift_Transport_LoadBalancedTransport implements Swift_Transport
|
||||
return array_merge($this->_transports, $this->_deadTransports);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Transport used in the last successful send operation.
|
||||
*
|
||||
* @return Swift_Transport
|
||||
*/
|
||||
public function getLastUsedTransport()
|
||||
{
|
||||
return $this->_lastUsedTransport;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if this Transport mechanism has started.
|
||||
*
|
||||
@@ -100,6 +115,7 @@ class Swift_Transport_LoadBalancedTransport implements Swift_Transport
|
||||
{
|
||||
$maxTransports = count($this->_transports);
|
||||
$sent = 0;
|
||||
$this->_lastUsedTransport = null;
|
||||
|
||||
for ($i = 0; $i < $maxTransports
|
||||
&& $transport = $this->_getNextTransport(); ++$i) {
|
||||
@@ -108,6 +124,7 @@ class Swift_Transport_LoadBalancedTransport implements Swift_Transport
|
||||
$transport->start();
|
||||
}
|
||||
if ($sent = $transport->send($message, $failedRecipients)) {
|
||||
$this->_lastUsedTransport = $transport;
|
||||
break;
|
||||
}
|
||||
} catch (Swift_TransportException $e) {
|
||||
|
@@ -156,15 +156,16 @@ class Swift_Transport_MailTransport implements Swift_Transport
|
||||
if ("\r\n" != PHP_EOL) {
|
||||
// Non-windows (not using SMTP)
|
||||
$headers = str_replace("\r\n", PHP_EOL, $headers);
|
||||
$subject = str_replace("\r\n", PHP_EOL, $subject);
|
||||
$body = str_replace("\r\n", PHP_EOL, $body);
|
||||
} else {
|
||||
// Windows, using SMTP
|
||||
$headers = str_replace("\r\n.", "\r\n..", $headers);
|
||||
$subject = str_replace("\r\n.", "\r\n..", $subject);
|
||||
$body = str_replace("\r\n.", "\r\n..", $body);
|
||||
}
|
||||
|
||||
if ($this->_invoker->mail($to, $subject, $body, $headers,
|
||||
sprintf($this->_extraParams, $reversePath))) {
|
||||
if ($this->_invoker->mail($to, $subject, $body, $headers, $this->_formatExtraParams($this->_extraParams, $reversePath))) {
|
||||
if ($evt) {
|
||||
$evt->setResult(Swift_Events_SendEvent::RESULT_SUCCESS);
|
||||
$evt->setFailedRecipients($failedRecipients);
|
||||
@@ -234,4 +235,21 @@ class Swift_Transport_MailTransport implements Swift_Transport
|
||||
|
||||
return $path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return php mail extra params to use for invoker->mail.
|
||||
*
|
||||
* @param $extraParams
|
||||
* @param $reversePath
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
private function _formatExtraParams($extraParams, $reversePath)
|
||||
{
|
||||
if (false !== strpos($extraParams, '-f%s')) {
|
||||
$extraParams = empty($reversePath) ? str_replace('-f%s', '', $extraParams) : sprintf($extraParams, escapeshellarg($reversePath));
|
||||
}
|
||||
|
||||
return !empty($extraParams) ? $extraParams : null;
|
||||
}
|
||||
}
|
||||
|
@@ -102,6 +102,7 @@ class Swift_Transport_SendmailTransport extends Swift_Transport_AbstractSmtpTran
|
||||
$failedRecipients = (array) $failedRecipients;
|
||||
$command = $this->getCommand();
|
||||
$buffer = $this->getBuffer();
|
||||
$count = 0;
|
||||
|
||||
if (false !== strpos($command, ' -t')) {
|
||||
if ($evt = $this->_eventDispatcher->createSendEvent($this, $message)) {
|
||||
|
@@ -32,8 +32,8 @@ class Swift_Transport_SimpleMailInvoker implements Swift_Transport_MailInvoker
|
||||
{
|
||||
if (!ini_get('safe_mode')) {
|
||||
return @mail($to, $subject, $body, $headers, $extraParams);
|
||||
} else {
|
||||
return @mail($to, $subject, $body, $headers);
|
||||
}
|
||||
|
||||
return @mail($to, $subject, $body, $headers);
|
||||
}
|
||||
}
|
||||
|
@@ -260,7 +260,11 @@ class Swift_Transport_StreamBuffer extends Swift_ByteStream_AbstractFilterableIn
|
||||
if (!empty($this->_params['sourceIp'])) {
|
||||
$options['socket']['bindto'] = $this->_params['sourceIp'].':0';
|
||||
}
|
||||
$this->_stream = @stream_socket_client($host.':'.$this->_params['port'], $errno, $errstr, $timeout, STREAM_CLIENT_CONNECT, stream_context_create($options));
|
||||
if (isset($this->_params['stream_context_options'])) {
|
||||
$options = array_merge($options, $this->_params['stream_context_options']);
|
||||
}
|
||||
$streamContext = stream_context_create($options);
|
||||
$this->_stream = @stream_socket_client($host.':'.$this->_params['port'], $errno, $errstr, $timeout, STREAM_CLIENT_CONNECT, $streamContext);
|
||||
if (false === $this->_stream) {
|
||||
throw new Swift_TransportException(
|
||||
'Connection could not be established with host '.$this->_params['host'].
|
||||
|
@@ -32,6 +32,6 @@
|
||||
</testsuites>
|
||||
|
||||
<listeners>
|
||||
<listener class="\Mockery\Adapter\Phpunit\TestListener"></listener>
|
||||
<listener class="Mockery\Adapter\Phpunit\TestListener"/>
|
||||
</listeners>
|
||||
</phpunit>
|
||||
|
@@ -36,6 +36,10 @@ class Swift_Encoder_QpEncoderAcceptanceTest extends \PHPUnit_Framework_TestCase
|
||||
$text = file_get_contents($sampleDir.'/'.$sampleFile);
|
||||
$encodedText = $encoder->encodeString($text);
|
||||
|
||||
foreach (explode("\r\n", $encodedText) as $line) {
|
||||
$this->assertLessThanOrEqual(76, strlen($line));
|
||||
}
|
||||
|
||||
$this->assertEquals(
|
||||
quoted_printable_decode($encodedText), $text,
|
||||
'%s: Encoded string should decode back to original string for sample '.
|
||||
|
@@ -2,6 +2,8 @@
|
||||
|
||||
class Swift_Mime_ContentEncoder_NativeQpContentEncoderAcceptanceTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
protected $_samplesDir;
|
||||
|
||||
/**
|
||||
* @var Swift_Mime_ContentEncoder_NativeQpContentEncoder
|
||||
*/
|
||||
|
@@ -35,8 +35,8 @@ class Swift_Mime_EmbeddedFileAcceptanceTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertEquals(
|
||||
'Content-Type: application/pdf'."\r\n".
|
||||
'Content-Transfer-Encoding: base64'."\r\n".
|
||||
'Content-Disposition: inline'."\r\n".
|
||||
'Content-ID: <foo@bar>'."\r\n",
|
||||
'Content-ID: <foo@bar>'."\r\n".
|
||||
'Content-Disposition: inline'."\r\n",
|
||||
$file->toString()
|
||||
);
|
||||
}
|
||||
@@ -50,8 +50,8 @@ class Swift_Mime_EmbeddedFileAcceptanceTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertEquals(
|
||||
'Content-Type: application/pdf'."\r\n".
|
||||
'Content-Transfer-Encoding: base64'."\r\n".
|
||||
'Content-Disposition: attachment'."\r\n".
|
||||
'Content-ID: <'.$id.'>'."\r\n",
|
||||
'Content-ID: <'.$id.'>'."\r\n".
|
||||
'Content-Disposition: attachment'."\r\n",
|
||||
$file->toString()
|
||||
);
|
||||
}
|
||||
@@ -65,8 +65,8 @@ class Swift_Mime_EmbeddedFileAcceptanceTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertEquals(
|
||||
'Content-Type: application/pdf; name=foo.pdf'."\r\n".
|
||||
'Content-Transfer-Encoding: base64'."\r\n".
|
||||
'Content-Disposition: inline; filename=foo.pdf'."\r\n".
|
||||
'Content-ID: <'.$id.'>'."\r\n",
|
||||
'Content-ID: <'.$id.'>'."\r\n".
|
||||
'Content-Disposition: inline; filename=foo.pdf'."\r\n",
|
||||
$file->toString()
|
||||
);
|
||||
}
|
||||
@@ -80,8 +80,8 @@ class Swift_Mime_EmbeddedFileAcceptanceTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertEquals(
|
||||
'Content-Type: application/pdf'."\r\n".
|
||||
'Content-Transfer-Encoding: base64'."\r\n".
|
||||
'Content-Disposition: inline; size=12340'."\r\n".
|
||||
'Content-ID: <'.$id.'>'."\r\n",
|
||||
'Content-ID: <'.$id.'>'."\r\n".
|
||||
'Content-Disposition: inline; size=12340'."\r\n",
|
||||
$file->toString()
|
||||
);
|
||||
}
|
||||
@@ -93,11 +93,12 @@ class Swift_Mime_EmbeddedFileAcceptanceTest extends \PHPUnit_Framework_TestCase
|
||||
$file->setContentType('application/pdf');
|
||||
$file->setFilename('foo.pdf');
|
||||
$file->setSize(12340);
|
||||
|
||||
$this->assertEquals(
|
||||
'Content-Type: application/pdf; name=foo.pdf'."\r\n".
|
||||
'Content-Transfer-Encoding: base64'."\r\n".
|
||||
'Content-Disposition: inline; filename=foo.pdf; size=12340'."\r\n".
|
||||
'Content-ID: <'.$id.'>'."\r\n",
|
||||
'Content-ID: <'.$id.'>'."\r\n".
|
||||
'Content-Disposition: inline; filename=foo.pdf; size=12340'."\r\n",
|
||||
$file->toString()
|
||||
);
|
||||
}
|
||||
@@ -113,8 +114,8 @@ class Swift_Mime_EmbeddedFileAcceptanceTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertEquals(
|
||||
'Content-Type: application/pdf; name=foo.pdf'."\r\n".
|
||||
'Content-Transfer-Encoding: base64'."\r\n".
|
||||
'Content-Disposition: inline; filename=foo.pdf; size=12340'."\r\n".
|
||||
'Content-ID: <'.$id.'>'."\r\n".
|
||||
'Content-Disposition: inline; filename=foo.pdf; size=12340'."\r\n".
|
||||
"\r\n".
|
||||
base64_encode('abcd'),
|
||||
$file->toString()
|
||||
|
@@ -778,8 +778,8 @@ class Swift_Mime_SimpleMessageAcceptanceTest extends \PHPUnit_Framework_TestCase
|
||||
'--\\2'."\r\n".
|
||||
'Content-Type: image/jpeg; name=myimage.jpg'."\r\n".
|
||||
'Content-Transfer-Encoding: base64'."\r\n".
|
||||
'Content-Disposition: inline; filename=myimage.jpg'."\r\n".
|
||||
'Content-ID: <'.$cid.'>'."\r\n".
|
||||
'Content-Disposition: inline; filename=myimage.jpg'."\r\n".
|
||||
"\r\n".
|
||||
preg_quote(base64_encode('<image data>'), '~').
|
||||
"\r\n\r\n".
|
||||
@@ -857,8 +857,8 @@ class Swift_Mime_SimpleMessageAcceptanceTest extends \PHPUnit_Framework_TestCase
|
||||
'--\\1'."\r\n".
|
||||
'Content-Type: image/jpeg; name=myimage.jpg'."\r\n".
|
||||
'Content-Transfer-Encoding: base64'."\r\n".
|
||||
'Content-Disposition: inline; filename=myimage.jpg'."\r\n".
|
||||
'Content-ID: <'.$cid.'>'."\r\n".
|
||||
'Content-Disposition: inline; filename=myimage.jpg'."\r\n".
|
||||
"\r\n".
|
||||
preg_quote(base64_encode('<image data>'), '~').
|
||||
"\r\n\r\n".
|
||||
@@ -938,8 +938,8 @@ class Swift_Mime_SimpleMessageAcceptanceTest extends \PHPUnit_Framework_TestCase
|
||||
'--\\1'."\r\n".
|
||||
'Content-Type: image/jpeg; name=myimage.jpg'."\r\n".
|
||||
'Content-Transfer-Encoding: base64'."\r\n".
|
||||
'Content-Disposition: inline; filename=myimage.jpg'."\r\n".
|
||||
'Content-ID: <'.$cid.'>'."\r\n".
|
||||
'Content-Disposition: inline; filename=myimage.jpg'."\r\n".
|
||||
"\r\n".
|
||||
preg_quote(base64_encode('<image data>'), '~').
|
||||
"\r\n\r\n".
|
||||
|
@@ -29,6 +29,6 @@ class Swift_Transport_StreamBuffer_BasicSocketAcceptanceTest
|
||||
'protocol' => 'tcp',
|
||||
'blocking' => 1,
|
||||
'timeout' => 15,
|
||||
));
|
||||
));
|
||||
}
|
||||
}
|
||||
|
@@ -4,6 +4,8 @@ class Swift_Transport_StreamBuffer_SocketTimeoutTest extends \PHPUnit_Framework_
|
||||
{
|
||||
protected $_buffer;
|
||||
|
||||
protected $_randomHighPort;
|
||||
|
||||
protected $_server;
|
||||
|
||||
public function setUp()
|
||||
@@ -41,7 +43,7 @@ class Swift_Transport_StreamBuffer_SocketTimeoutTest extends \PHPUnit_Framework_
|
||||
'protocol' => 'tcp',
|
||||
'blocking' => 1,
|
||||
'timeout' => 1,
|
||||
));
|
||||
));
|
||||
}
|
||||
|
||||
public function testTimeoutException()
|
||||
|
@@ -36,6 +36,6 @@ class Swift_Transport_StreamBuffer_SslSocketAcceptanceTest
|
||||
'protocol' => 'ssl',
|
||||
'blocking' => 1,
|
||||
'timeout' => 15,
|
||||
));
|
||||
));
|
||||
}
|
||||
}
|
||||
|
@@ -1,11 +1,13 @@
|
||||
<?php
|
||||
|
||||
$autoloader = require_once dirname(__DIR__).'/vendor/autoload.php';
|
||||
$autoloader->add('Swift_', __DIR__.'/unit');
|
||||
require_once dirname(__DIR__).'/vendor/autoload.php';
|
||||
|
||||
// Disable garbage collector to prevent segfaults
|
||||
gc_disable();
|
||||
|
||||
set_include_path(get_include_path().PATH_SEPARATOR.dirname(__DIR__).'/lib');
|
||||
|
||||
\Mockery::getConfiguration()->allowMockingNonExistentMethods(false);
|
||||
Mockery::getConfiguration()->allowMockingNonExistentMethods(false);
|
||||
|
||||
if (is_file(__DIR__.'/acceptance.conf.php')) {
|
||||
require_once __DIR__.'/acceptance.conf.php';
|
||||
|
@@ -2,14 +2,14 @@
|
||||
|
||||
class Swift_Bug274Test extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testEmptyFileNameAsAttachement()
|
||||
public function testEmptyFileNameAsAttachment()
|
||||
{
|
||||
$message = new Swift_Message();
|
||||
$this->setExpectedException('Swift_IoException', 'The path cannot be empty');
|
||||
$message->attach(Swift_Attachment::fromPath(''));
|
||||
}
|
||||
|
||||
public function testNonEmptyFileNameAsAttachement()
|
||||
public function testNonEmptyFileNameAsAttachment()
|
||||
{
|
||||
$message = new Swift_Message();
|
||||
try {
|
||||
|
@@ -60,8 +60,8 @@ class Swift_Bug34Test extends \PHPUnit_Framework_TestCase
|
||||
'--\\1'."\r\n".
|
||||
'Content-Type: image/gif; name=image.gif'."\r\n".
|
||||
'Content-Transfer-Encoding: base64'."\r\n".
|
||||
'Content-Disposition: inline; filename=image.gif'."\r\n".
|
||||
'Content-ID: <'.$cidVal.'>'."\r\n".
|
||||
'Content-Disposition: inline; filename=image.gif'."\r\n".
|
||||
"\r\n".
|
||||
preg_quote(base64_encode('<image data>'), '~').
|
||||
"\r\n\r\n".
|
||||
|
@@ -57,8 +57,8 @@ class Swift_Bug38Test extends \PHPUnit_Framework_TestCase
|
||||
'--'.$boundary."\r\n".
|
||||
'Content-Type: image/gif; name=image.gif'."\r\n".
|
||||
'Content-Transfer-Encoding: base64'."\r\n".
|
||||
'Content-Disposition: inline; filename=image.gif'."\r\n".
|
||||
'Content-ID: <'.preg_quote($imgId, '~').'>'."\r\n".
|
||||
'Content-Disposition: inline; filename=image.gif'."\r\n".
|
||||
"\r\n".
|
||||
preg_quote(base64_encode('<data>'), '~').
|
||||
"\r\n\r\n".
|
||||
@@ -106,8 +106,8 @@ class Swift_Bug38Test extends \PHPUnit_Framework_TestCase
|
||||
'--'.$boundary."\r\n".
|
||||
'Content-Type: image/gif; name=image.gif'."\r\n".
|
||||
'Content-Transfer-Encoding: base64'."\r\n".
|
||||
'Content-Disposition: inline; filename=image.gif'."\r\n".
|
||||
'Content-ID: <'.preg_quote($imgId, '~').'>'."\r\n".
|
||||
'Content-Disposition: inline; filename=image.gif'."\r\n".
|
||||
"\r\n".
|
||||
preg_quote(base64_encode('<data>'), '~').
|
||||
"\r\n\r\n".
|
||||
|
19
vendor/swiftmailer/swiftmailer/tests/bug/Swift/BugFileByteStreamConsecutiveReadCallsTest.php
vendored
Normal file
19
vendor/swiftmailer/swiftmailer/tests/bug/Swift/BugFileByteStreamConsecutiveReadCallsTest.php
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
|
||||
class Swift_FileByteStreamConsecutiveReadCalls extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @test
|
||||
* @expectedException \Swift_IoException
|
||||
*/
|
||||
public function shouldThrowExceptionOnConsecutiveRead()
|
||||
{
|
||||
$fbs = new \Swift_ByteStream_FileByteStream('does not exist');
|
||||
try {
|
||||
$fbs->read(100);
|
||||
} catch (\Swift_IoException $exc) {
|
||||
$fbs->read(100);
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,10 +0,0 @@
|
||||
<?php
|
||||
|
||||
class EsmtpTransportFixture extends Swift_Transport_EsmtpTransport
|
||||
{
|
||||
/** This is so Mockery doesn't throw a fit. */
|
||||
private function _sortHandlers($a, $b)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
}
|
@@ -5,6 +5,8 @@
|
||||
*/
|
||||
class Swift_Smoke_AttachmentSmokeTest extends SwiftMailerSmokeTestCase
|
||||
{
|
||||
private $_attFile;
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
$this->_attFile = __DIR__.'/../../../_samples/files/textfile.zip';
|
||||
|
@@ -5,6 +5,8 @@
|
||||
*/
|
||||
class Swift_Smoke_HtmlWithAttachmentSmokeTest extends SwiftMailerSmokeTestCase
|
||||
{
|
||||
private $_attFile;
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
$this->_attFile = __DIR__.'/../../../_samples/files/textfile.zip';
|
||||
|
@@ -5,6 +5,8 @@
|
||||
*/
|
||||
class Swift_Smoke_InternationalSmokeTest extends SwiftMailerSmokeTestCase
|
||||
{
|
||||
private $_attFile;
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
$this->_attFile = __DIR__.'/../../../_samples/files/textfile.zip';
|
||||
|
@@ -54,9 +54,7 @@ class Swift_ByteStream_ArrayByteStreamTest extends \PHPUnit_Framework_TestCase
|
||||
public function testResettingPointerAfterExhaustion()
|
||||
{
|
||||
$input = array('a', 'b', 'c');
|
||||
$bs = $this->_createArrayStream($input);
|
||||
|
||||
while (false !== $bs->read(1));
|
||||
$bs = $this->_createArrayStream($input); while (false !== $bs->read(1));
|
||||
|
||||
$bs->setReadPointer(0);
|
||||
$this->assertEquals('a', $bs->read(1),
|
||||
|
@@ -372,10 +372,31 @@ class Swift_Encoder_QpEncoderTest extends \SwiftMailerTestCase
|
||||
);
|
||||
}
|
||||
|
||||
public function testTextIsPreWrapped()
|
||||
{
|
||||
$encoder = $this->createEncoder();
|
||||
|
||||
$input = str_repeat('a', 70)."\r\n".
|
||||
str_repeat('a', 70)."\r\n".
|
||||
str_repeat('a', 70);
|
||||
|
||||
$this->assertEquals(
|
||||
$input, $encoder->encodeString($input)
|
||||
);
|
||||
}
|
||||
|
||||
// -- Creation methods
|
||||
|
||||
private function _createCharStream()
|
||||
{
|
||||
return $this->getMockery('Swift_CharacterStream')->shouldIgnoreMissing();
|
||||
}
|
||||
|
||||
private function createEncoder()
|
||||
{
|
||||
$factory = new Swift_CharacterReaderFactory_SimpleCharacterReaderFactory();
|
||||
$charStream = new Swift_CharacterStream_NgCharacterStream($factory, 'utf-8');
|
||||
|
||||
return new Swift_Encoder_QpEncoder($charStream);
|
||||
}
|
||||
}
|
||||
|
@@ -140,11 +140,6 @@ class Swift_MailerTest extends \SwiftMailerTestCase
|
||||
return $this->getMockery('Swift_Mime_Message')->shouldIgnoreMissing();
|
||||
}
|
||||
|
||||
private function _createIterator()
|
||||
{
|
||||
return $this->getMockery('Swift_Mailer_RecipientIterator')->shouldIgnoreMissing();
|
||||
}
|
||||
|
||||
private function _createMailer(Swift_Transport $transport)
|
||||
{
|
||||
return new Swift_Mailer($transport);
|
||||
|
@@ -379,7 +379,7 @@ abstract class Swift_Mime_AbstractMimeEntityTest extends \SwiftMailerTestCase
|
||||
$this->_createEncoder(), $this->_createCache()
|
||||
);
|
||||
$firstBoundary = $entity->getBoundary();
|
||||
for ($i = 0; $i < 10; $i++) {
|
||||
for ($i = 0; $i < 10; ++$i) {
|
||||
$this->assertEquals($firstBoundary, $entity->getBoundary());
|
||||
}
|
||||
}
|
||||
@@ -540,13 +540,13 @@ abstract class Swift_Mime_AbstractMimeEntityTest extends \SwiftMailerTestCase
|
||||
$child1 = new MimeEntityFixture(Swift_Mime_MimeEntity::LEVEL_ALTERNATIVE,
|
||||
"Content-Type: text/plain\r\n".
|
||||
"\r\n".
|
||||
'foobar'
|
||||
'foobar', 'text/plain'
|
||||
);
|
||||
|
||||
$child2 = new MimeEntityFixture(Swift_Mime_MimeEntity::LEVEL_ALTERNATIVE,
|
||||
"Content-Type: text/html\r\n".
|
||||
"\r\n".
|
||||
'<b>foobar</b>'
|
||||
'<b>foobar</b>', 'text/html'
|
||||
);
|
||||
|
||||
$headers->shouldReceive('toString')
|
||||
@@ -623,7 +623,7 @@ abstract class Swift_Mime_AbstractMimeEntityTest extends \SwiftMailerTestCase
|
||||
"\r\n".
|
||||
'data'.
|
||||
"\r\n\r\n--xxx--\r\n".
|
||||
"\$~",
|
||||
'$~',
|
||||
$entity->toString()
|
||||
);
|
||||
}
|
||||
|
@@ -50,7 +50,7 @@ class Swift_Mime_ContentEncoder_PlainContentEncoderTest extends \SwiftMailerTest
|
||||
$encoder = $this->_getEncoder('7bit');
|
||||
|
||||
$chars = array();
|
||||
for ($i = 0; $i < 50; $i++) {
|
||||
for ($i = 0; $i < 50; ++$i) {
|
||||
$chars[] = 'a';
|
||||
}
|
||||
$input = implode(' ', $chars); //99 chars long
|
||||
@@ -75,7 +75,7 @@ class Swift_Mime_ContentEncoder_PlainContentEncoderTest extends \SwiftMailerTest
|
||||
->zeroOrMoreTimes()
|
||||
->andReturnUsing($collection);
|
||||
|
||||
for ($i = 0; $i < 50; $i++) {
|
||||
for ($i = 0; $i < 50; ++$i) {
|
||||
$os->shouldReceive('read')
|
||||
->once()
|
||||
->andReturn('a ');
|
||||
|
@@ -472,6 +472,25 @@ class Swift_Mime_ContentEncoder_QpContentEncoderTest extends \SwiftMailerTestCas
|
||||
$encoder->charsetChanged('windows-1252');
|
||||
}
|
||||
|
||||
public function testTextIsPreWrapped()
|
||||
{
|
||||
$encoder = $this->createEncoder();
|
||||
|
||||
$input = str_repeat('a', 70)."\r\n".
|
||||
str_repeat('a', 70)."\r\n".
|
||||
str_repeat('a', 70);
|
||||
|
||||
$os = new Swift_ByteStream_ArrayByteStream();
|
||||
$is = new Swift_ByteStream_ArrayByteStream();
|
||||
$is->write($input);
|
||||
|
||||
$encoder->encodeByteStream($is, $os);
|
||||
|
||||
$this->assertEquals(
|
||||
$input, $os->read(PHP_INT_MAX)
|
||||
);
|
||||
}
|
||||
|
||||
// -- Creation Methods
|
||||
|
||||
private function _createCharacterStream($stub = false)
|
||||
@@ -479,9 +498,12 @@ class Swift_Mime_ContentEncoder_QpContentEncoderTest extends \SwiftMailerTestCas
|
||||
return $this->getMockery('Swift_CharacterStream')->shouldIgnoreMissing();
|
||||
}
|
||||
|
||||
private function _createEncoder($charStream)
|
||||
private function createEncoder()
|
||||
{
|
||||
return new Swift_Mime_HeaderEncoder_QpHeaderEncoder($charStream);
|
||||
$factory = new Swift_CharacterReaderFactory_SimpleCharacterReaderFactory();
|
||||
$charStream = new Swift_CharacterStream_NgCharacterStream($factory, 'utf-8');
|
||||
|
||||
return new Swift_Mime_ContentEncoder_QpContentEncoder($charStream);
|
||||
}
|
||||
|
||||
private function _createOutputByteStream($stub = false)
|
||||
|
@@ -29,7 +29,7 @@ class Swift_Plugins_AntiFloodPluginTest extends \PHPUnit_Framework_TestCase
|
||||
$evt = $this->_createSendEvent($transport);
|
||||
|
||||
$plugin = new Swift_Plugins_AntiFloodPlugin(10);
|
||||
for ($i = 0; $i < 12; $i++) {
|
||||
for ($i = 0; $i < 12; ++$i) {
|
||||
$plugin->sendPerformed($evt);
|
||||
}
|
||||
}
|
||||
@@ -45,7 +45,7 @@ class Swift_Plugins_AntiFloodPluginTest extends \PHPUnit_Framework_TestCase
|
||||
$evt = $this->_createSendEvent($transport);
|
||||
|
||||
$plugin = new Swift_Plugins_AntiFloodPlugin(2);
|
||||
for ($i = 0; $i < 11; $i++) {
|
||||
for ($i = 0; $i < 11; ++$i) {
|
||||
$plugin->sendPerformed($evt);
|
||||
}
|
||||
}
|
||||
@@ -66,7 +66,7 @@ class Swift_Plugins_AntiFloodPluginTest extends \PHPUnit_Framework_TestCase
|
||||
$evt = $this->_createSendEvent($transport);
|
||||
|
||||
$plugin = new Swift_Plugins_AntiFloodPlugin(99, 10, $sleeper);
|
||||
for ($i = 0; $i < 101; $i++) {
|
||||
for ($i = 0; $i < 101; ++$i) {
|
||||
$plugin->sendPerformed($evt);
|
||||
}
|
||||
}
|
||||
|
@@ -2,6 +2,10 @@
|
||||
|
||||
class Swift_Plugins_BandwidthMonitorPluginTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
private $_monitor;
|
||||
|
||||
private $_bytes = 0;
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
$this->_monitor = new Swift_Plugins_BandwidthMonitorPlugin();
|
||||
@@ -117,7 +121,6 @@ class Swift_Plugins_BandwidthMonitorPluginTest extends \PHPUnit_Framework_TestCa
|
||||
return $msg;
|
||||
}
|
||||
|
||||
private $_bytes = 0;
|
||||
public function _write($is)
|
||||
{
|
||||
for ($i = 0; $i < $this->_bytes; ++$i) {
|
||||
|
@@ -1,7 +1,6 @@
|
||||
<?php
|
||||
|
||||
require_once dirname(__DIR__).'/EsmtpTransportTest.php';
|
||||
require_once dirname(dirname(dirname(dirname(__DIR__)))).'/fixtures/EsmtpTransportFixture.php';
|
||||
|
||||
interface Swift_Transport_EsmtpHandlerMixin extends Swift_Transport_EsmtpHandler
|
||||
{
|
||||
@@ -9,8 +8,7 @@ interface Swift_Transport_EsmtpHandlerMixin extends Swift_Transport_EsmtpHandler
|
||||
public function setPassword($pass);
|
||||
}
|
||||
|
||||
class Swift_Transport_EsmtpTransport_ExtensionSupportTest
|
||||
extends Swift_Transport_EsmtpTransportTest
|
||||
class Swift_Transport_EsmtpTransport_ExtensionSupportTest extends Swift_Transport_EsmtpTransportTest
|
||||
{
|
||||
public function testExtensionHandlersAreSortedAsNeeded()
|
||||
{
|
||||
@@ -25,7 +23,7 @@ class Swift_Transport_EsmtpTransport_ExtensionSupportTest
|
||||
$ext1->shouldReceive('getPriorityOver')
|
||||
->zeroOrMoreTimes()
|
||||
->with('STARTTLS')
|
||||
->andReturn(0);
|
||||
->andReturn(1);
|
||||
$ext2->shouldReceive('getHandledKeyword')
|
||||
->zeroOrMoreTimes()
|
||||
->andReturn('STARTTLS');
|
||||
@@ -142,7 +140,7 @@ class Swift_Transport_EsmtpTransport_ExtensionSupportTest
|
||||
{
|
||||
$buf = $this->_getBuffer();
|
||||
$dispatcher = $this->_createEventDispatcher();
|
||||
$smtp = new EsmtpTransportFixture($buf, array(), $dispatcher);
|
||||
$smtp = new Swift_Transport_EsmtpTransport($buf, array(), $dispatcher);
|
||||
$ext1 = $this->getMockery('Swift_Transport_EsmtpHandler')->shouldIgnoreMissing();
|
||||
$ext2 = $this->getMockery('Swift_Transport_EsmtpHandler')->shouldIgnoreMissing();
|
||||
$ext3 = $this->getMockery('Swift_Transport_EsmtpHandler')->shouldIgnoreMissing();
|
||||
@@ -228,7 +226,7 @@ class Swift_Transport_EsmtpTransport_ExtensionSupportTest
|
||||
{
|
||||
$buf = $this->_getBuffer();
|
||||
$dispatcher = $this->_createEventDispatcher();
|
||||
$smtp = new EsmtpTransportFixture($buf, array(), $dispatcher);
|
||||
$smtp = new Swift_Transport_EsmtpTransport($buf, array(), $dispatcher);
|
||||
$ext1 = $this->getMockery('Swift_Transport_EsmtpHandler')->shouldIgnoreMissing();
|
||||
$ext2 = $this->getMockery('Swift_Transport_EsmtpHandler')->shouldIgnoreMissing();
|
||||
$ext3 = $this->getMockery('Swift_Transport_EsmtpHandler')->shouldIgnoreMissing();
|
||||
|
@@ -84,6 +84,108 @@ class Swift_Transport_MailTransportTest extends \SwiftMailerTestCase
|
||||
$transport->send($message);
|
||||
}
|
||||
|
||||
public function testTransportSettingUsingReturnPathForExtraParams()
|
||||
{
|
||||
$invoker = $this->_createInvoker();
|
||||
$dispatcher = $this->_createEventDispatcher();
|
||||
$transport = $this->_createTransport($invoker, $dispatcher);
|
||||
|
||||
$headers = $this->_createHeaders();
|
||||
$message = $this->_createMessage($headers);
|
||||
|
||||
$message->shouldReceive('getReturnPath')
|
||||
->zeroOrMoreTimes()
|
||||
->andReturn(
|
||||
'foo@bar'
|
||||
);
|
||||
$invoker->shouldReceive('mail')
|
||||
->once()
|
||||
->with(\Mockery::any(), \Mockery::any(), \Mockery::any(), \Mockery::any(), '-f\'foo@bar\'');
|
||||
|
||||
$transport->send($message);
|
||||
}
|
||||
|
||||
public function testTransportSettingEmptyExtraParams()
|
||||
{
|
||||
$invoker = $this->_createInvoker();
|
||||
$dispatcher = $this->_createEventDispatcher();
|
||||
$transport = $this->_createTransport($invoker, $dispatcher);
|
||||
|
||||
$headers = $this->_createHeaders();
|
||||
$message = $this->_createMessage($headers);
|
||||
|
||||
$message->shouldReceive('getReturnPath')
|
||||
->zeroOrMoreTimes()
|
||||
->andReturn(null);
|
||||
$message->shouldReceive('getSender')
|
||||
->zeroOrMoreTimes()
|
||||
->andReturn(null);
|
||||
$message->shouldReceive('getFrom')
|
||||
->zeroOrMoreTimes()
|
||||
->andReturn(null);
|
||||
$invoker->shouldReceive('mail')
|
||||
->once()
|
||||
->with(\Mockery::any(), \Mockery::any(), \Mockery::any(), \Mockery::any(), null);
|
||||
|
||||
$transport->send($message);
|
||||
}
|
||||
|
||||
public function testTransportSettingSettingExtraParamsWithF()
|
||||
{
|
||||
$invoker = $this->_createInvoker();
|
||||
$dispatcher = $this->_createEventDispatcher();
|
||||
$transport = $this->_createTransport($invoker, $dispatcher);
|
||||
$transport->setExtraParams('-x\'foo\' -f%s');
|
||||
|
||||
$headers = $this->_createHeaders();
|
||||
$message = $this->_createMessage($headers);
|
||||
|
||||
$message->shouldReceive('getReturnPath')
|
||||
->zeroOrMoreTimes()
|
||||
->andReturn(
|
||||
'foo@bar'
|
||||
);
|
||||
$message->shouldReceive('getSender')
|
||||
->zeroOrMoreTimes()
|
||||
->andReturn(null);
|
||||
$message->shouldReceive('getFrom')
|
||||
->zeroOrMoreTimes()
|
||||
->andReturn(null);
|
||||
$invoker->shouldReceive('mail')
|
||||
->once()
|
||||
->with(\Mockery::any(), \Mockery::any(), \Mockery::any(), \Mockery::any(), '-x\'foo\' -f\'foo@bar\'');
|
||||
|
||||
$transport->send($message);
|
||||
}
|
||||
|
||||
public function testTransportSettingSettingExtraParamsWithoutF()
|
||||
{
|
||||
$invoker = $this->_createInvoker();
|
||||
$dispatcher = $this->_createEventDispatcher();
|
||||
$transport = $this->_createTransport($invoker, $dispatcher);
|
||||
$transport->setExtraParams('-x\'foo\'');
|
||||
|
||||
$headers = $this->_createHeaders();
|
||||
$message = $this->_createMessage($headers);
|
||||
|
||||
$message->shouldReceive('getReturnPath')
|
||||
->zeroOrMoreTimes()
|
||||
->andReturn(
|
||||
'foo@bar'
|
||||
);
|
||||
$message->shouldReceive('getSender')
|
||||
->zeroOrMoreTimes()
|
||||
->andReturn(null);
|
||||
$message->shouldReceive('getFrom')
|
||||
->zeroOrMoreTimes()
|
||||
->andReturn(null);
|
||||
$invoker->shouldReceive('mail')
|
||||
->once()
|
||||
->with(\Mockery::any(), \Mockery::any(), \Mockery::any(), \Mockery::any(), '-x\'foo\'');
|
||||
|
||||
$transport->send($message);
|
||||
}
|
||||
|
||||
public function testTransportUsesHeadersFromMessage()
|
||||
{
|
||||
$invoker = $this->_createInvoker();
|
||||
@@ -94,15 +196,15 @@ class Swift_Transport_MailTransportTest extends \SwiftMailerTestCase
|
||||
$message = $this->_createMessage($headers);
|
||||
|
||||
$message->shouldReceive('toString')
|
||||
->zeroOrMoreTimes()
|
||||
->andReturn(
|
||||
->zeroOrMoreTimes()
|
||||
->andReturn(
|
||||
"Subject: Stuff\r\n".
|
||||
"\r\n".
|
||||
'This body'
|
||||
);
|
||||
);
|
||||
$invoker->shouldReceive('mail')
|
||||
->once()
|
||||
->with(\Mockery::any(), \Mockery::any(), \Mockery::any(), 'Subject: Stuff'.PHP_EOL, \Mockery::any());
|
||||
->once()
|
||||
->with(\Mockery::any(), \Mockery::any(), \Mockery::any(), 'Subject: Stuff'.PHP_EOL, \Mockery::any());
|
||||
|
||||
$transport->send($message);
|
||||
}
|
||||
@@ -249,6 +351,45 @@ class Swift_Transport_MailTransportTest extends \SwiftMailerTestCase
|
||||
$transport->send($message);
|
||||
}
|
||||
|
||||
public function testMessageHeadersOnlyHavePHPEolsDuringSending()
|
||||
{
|
||||
$invoker = $this->_createInvoker();
|
||||
$dispatcher = $this->_createEventDispatcher();
|
||||
$transport = $this->_createTransport($invoker, $dispatcher);
|
||||
|
||||
$subject = $this->_createHeader();
|
||||
$subject->shouldReceive('getFieldBody')->andReturn("Foo\r\nBar");
|
||||
|
||||
$headers = $this->_createHeaders(array(
|
||||
'Subject' => $subject,
|
||||
));
|
||||
$message = $this->_createMessage($headers);
|
||||
$message->shouldReceive('toString')
|
||||
->zeroOrMoreTimes()
|
||||
->andReturn(
|
||||
"From: Foo\r\n<foo@bar>\r\n".
|
||||
"\r\n".
|
||||
"This\r\n".
|
||||
'body'
|
||||
);
|
||||
|
||||
if ("\r\n" != PHP_EOL) {
|
||||
$expectedHeaders = "From: Foo\n<foo@bar>\n";
|
||||
$expectedSubject = "Foo\nBar";
|
||||
$expectedBody = "This\nbody";
|
||||
} else {
|
||||
$expectedHeaders = "From: Foo\r\n<foo@bar>\r\n";
|
||||
$expectedSubject = "Foo\r\nBar";
|
||||
$expectedBody = "This\r\nbody";
|
||||
}
|
||||
|
||||
$invoker->shouldReceive('mail')
|
||||
->once()
|
||||
->with(\Mockery::any(), $expectedSubject, $expectedBody, $expectedHeaders, \Mockery::any());
|
||||
|
||||
$transport->send($message);
|
||||
}
|
||||
|
||||
// -- Creation Methods
|
||||
|
||||
private function _createTransport($invoker, $dispatcher)
|
||||
|
Reference in New Issue
Block a user