Skip to content

Commit

Permalink
[+]: use "Swift::strtolowerWithStaticCache()" for header-names e.g. "…
Browse files Browse the repository at this point in the history
…Content-Disposition"
  • Loading branch information
voku committed May 28, 2016
1 parent 8011906 commit 0498721
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ public function init()
*/
public function getReaderFor($charset)
{
$charset = trim(strtolower($charset));
$charset = Swift::strtolowerWithStaticCache(trim($charset));

foreach (self::$_map as $pattern => $spec) {
$re = '/^' . $pattern . '$/D';
if (preg_match($re, $charset)) {
Expand Down
2 changes: 1 addition & 1 deletion lib/classes/Swift/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ protected function saveMessage()
protected function saveHeaders(array $altered)
{
foreach ($altered as $head) {
$lc = strtolower($head);
$lc = Swift::strtolowerWithStaticCache($head);

if (!isset($this->savedMessage['headers'][$lc])) {
$this->savedMessage['headers'][$lc] = $this->getHeaders()->getAll($head);
Expand Down
2 changes: 1 addition & 1 deletion lib/classes/Swift/Mime/SimpleHeaderFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public function createTextHeader($name, $value = null)
public function createParameterizedHeader($name, $value = null, $params = array())
{
$parameterEncoding = null;
if (strtolower($name) === 'content-disposition') {
if (Swift::strtolowerWithStaticCache($name) === 'content-disposition') {
$parameterEncoding = $this->_paramEncoder;
}

Expand Down
2 changes: 1 addition & 1 deletion lib/classes/Swift/Plugins/PopBeforeSmtpPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ private function _assertOk($response)
private function _getHostString()
{
$host = $this->_host;
switch (strtolower($this->_crypto)) {
switch (Swift::strtolowerWithStaticCache($this->_crypto)) {
case 'ssl':
$host = 'ssl://' . $host;
break;
Expand Down
4 changes: 2 additions & 2 deletions lib/classes/Swift/Signers/DKIMSigner.php
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,7 @@ public function getAlteredHeaders()
*/
public function ignoreHeader($header_name)
{
$this->_ignoredHeaders[strtolower($header_name)] = true;
$this->_ignoredHeaders[Swift::strtolowerWithStaticCache($header_name)] = true;

return $this;
}
Expand All @@ -521,7 +521,7 @@ public function setHeaders(Swift_Mime_HeaderSet $headers)
$listHeaders = $headers->listAll();
foreach ($listHeaders as $hName) {
// Check if we need to ignore Header
if (!isset($this->_ignoredHeaders[strtolower($hName)])) {
if (!isset($this->_ignoredHeaders[Swift::strtolowerWithStaticCache($hName)])) {
if ($headers->has($hName)) {
$tmp = $headers->getAll($hName);
foreach ($tmp as $header) {
Expand Down
4 changes: 2 additions & 2 deletions lib/classes/Swift/Signers/DomainKeySigner.php
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ public function getAlteredHeaders()
*/
public function ignoreHeader($header_name)
{
$this->_ignoredHeaders[strtolower($header_name)] = true;
$this->_ignoredHeaders[Swift::strtolowerWithStaticCache($header_name)] = true;

return $this;
}
Expand All @@ -395,7 +395,7 @@ public function setHeaders(Swift_Mime_HeaderSet $headers)
$listHeaders = $headers->listAll();
foreach ($listHeaders as $hName) {
// Check if we need to ignore Header
if (!isset($this->_ignoredHeaders[strtolower($hName)])) {
if (!isset($this->_ignoredHeaders[Swift::strtolowerWithStaticCache($hName)])) {
if ($headers->has($hName)) {
$tmp = $headers->getAll($hName);
foreach ($tmp as $header) {
Expand Down
2 changes: 1 addition & 1 deletion lib/classes/Swift/Signers/OpenDKIMSigner.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public function setHeaders(Swift_Mime_HeaderSet $headers)
$listHeaders = $headers->listAll();
foreach ($listHeaders as $hName) {
// Check if we need to ignore Header
if (!isset($this->_ignoredHeaders[strtolower($hName)])) {
if (!isset($this->_ignoredHeaders[Swift::strtolowerWithStaticCache($hName)])) {
$tmp = $headers->getAll($hName);
if ($headers->has($hName)) {
foreach ($tmp as $header) {
Expand Down
13 changes: 8 additions & 5 deletions lib/classes/Swift/Transport/Esmtp/AuthHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,15 +164,17 @@ public function setKeywordParams(array $parameters)
* Runs immediately after a EHLO has been issued.
*
* @param Swift_Transport_SmtpAgent $agent to read/write
*
* @throws Swift_TransportException
*/
public function afterEhlo(Swift_Transport_SmtpAgent $agent)
{
if ($this->_username) {
$count = 0;
foreach ($this->_getAuthenticatorsForAgent() as $authenticator) {
if (in_array(
strtolower($authenticator->getAuthKeyword()),
array_map('strtolower', $this->_esmtpParams),
Swift::strtolowerWithStaticCache($authenticator->getAuthKeyword()),
array_map(array('Swift', 'strtolowerWithStaticCache'), $this->_esmtpParams),
true
)) {
++$count;
Expand All @@ -181,10 +183,11 @@ public function afterEhlo(Swift_Transport_SmtpAgent $agent)
}
}
}

throw new Swift_TransportException(
'Failed to authenticate on SMTP server with username "' .
$this->_username . '" using ' . $count . ' possible authenticators'
);
);
}
}

Expand Down Expand Up @@ -250,12 +253,12 @@ public function resetState()
*/
protected function _getAuthenticatorsForAgent()
{
if (!$mode = strtolower($this->_auth_mode)) {
if (!$mode = Swift::strtolowerWithStaticCache($this->_auth_mode)) {
return $this->_authenticators;
}

foreach ($this->_authenticators as $authenticator) {
if (strtolower($authenticator->getAuthKeyword()) === $mode) {
if (Swift::strtolowerWithStaticCache($authenticator->getAuthKeyword()) === $mode) {
return array($authenticator);
}
}
Expand Down
6 changes: 3 additions & 3 deletions lib/classes/Swift/Transport/EsmtpTransport.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public function getTimeout()
*/
public function setEncryption($encryption)
{
$encryption = strtolower($encryption);
$encryption = Swift::strtolowerWithStaticCache($encryption);

if ('tls' === $encryption) {
$this->_params['protocol'] = 'tcp';
Expand Down Expand Up @@ -286,8 +286,8 @@ public function __call($method, $args)
foreach ($this->_handlers as $handler) {

$inArray = in_array(
strtolower($method),
array_map('strtolower', (array)$handler->exposeMixinMethods()),
Swift::strtolowerWithStaticCache($method),
array_map(array('Swift', 'strtolowerWithStaticCache'), (array)$handler->exposeMixinMethods()),
true
);

Expand Down

0 comments on commit 0498721

Please sign in to comment.