forked from Wavyzz/dolibarr
FIX: Update swiftmailer librairies
This commit is contained in:
@@ -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'];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -337,7 +332,7 @@ class Swift_Signers_DomainKeySigner implements Swift_Signers_HeaderSigner
|
||||
*/
|
||||
public function ignoreHeader($header_name)
|
||||
{
|
||||
$this->ignoredHeaders[strtolower($header_name)] = true;
|
||||
$this->ignoredHeaders[strtolower($header_name ?? '')] = true;
|
||||
|
||||
return $this;
|
||||
}
|
||||
@@ -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)
|
||||
@@ -357,11 +350,11 @@ class Swift_Signers_DomainKeySigner implements Swift_Signers_HeaderSigner
|
||||
$listHeaders = $headers->listAll();
|
||||
foreach ($listHeaders as $hName) {
|
||||
// Check if we need to ignore Header
|
||||
if (!isset($this->ignoredHeaders[strtolower($hName)])) {
|
||||
if (!isset($this->ignoredHeaders[strtolower($hName ?? '')])) {
|
||||
if ($headers->has($hName)) {
|
||||
$tmp = $headers->getAll($hName);
|
||||
foreach ($tmp as $header) {
|
||||
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
|
||||
}
|
||||
@@ -420,9 +412,9 @@ class Swift_Signers_DomainKeySigner implements Swift_Signers_HeaderSigner
|
||||
|
||||
protected function canonicalizeBody($string)
|
||||
{
|
||||
$len = strlen($string);
|
||||
$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);
|
||||
@@ -469,10 +462,9 @@ class Swift_Signers_DomainKeySigner implements Swift_Signers_HeaderSigner
|
||||
|
||||
protected function endOfBody()
|
||||
{
|
||||
if (strlen($this->bodyCanonLine) > 0) {
|
||||
if (\strlen($this->bodyCanonLine) > 0) {
|
||||
$this->addToHash("\r\n");
|
||||
}
|
||||
$this->hash = hash_final($this->hashHandler, true);
|
||||
}
|
||||
|
||||
private function addToHash($string)
|
||||
|
||||
Reference in New Issue
Block a user