mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-03 14:37:02 +03:00
Small fixes
This commit is contained in:
parent
76c21b82b3
commit
fd58f4dcd5
18 changed files with 491 additions and 429 deletions
|
|
@ -38,11 +38,10 @@ class HtmlUtils
|
|||
|
||||
$oDom = new \DOMDocument('1.0', 'utf-8');
|
||||
$oDom->encoding = 'UTF-8';
|
||||
$oDom->formatOutput = false;
|
||||
|
||||
@$oDom->loadHTML(
|
||||
'<'.'?xml version="1.0" encoding="utf-8"?'.'>'.
|
||||
'<html '.$sHtmlAttrs.'><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body '.$sBodyAttrs.'>'.$sText.'</body></html>'
|
||||
);
|
||||
@$oDom->loadHTML('<'.'?xml version="1.0" encoding="utf-8"?'.'>'.
|
||||
'<html '.$sHtmlAttrs.'><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body '.$sBodyAttrs.'>'.$sText.'</body></html>');
|
||||
|
||||
return $oDom;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -373,7 +373,7 @@ class Http
|
|||
CURLOPT_SSL_VERIFYPEER => false,
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_POST => true,
|
||||
CURLOPT_POSTFIELDS => $aPost,
|
||||
CURLOPT_POSTFIELDS => \http_build_query($aPost, '', '&'),
|
||||
CURLOPT_TIMEOUT => (int) $iTimeout
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -93,15 +93,31 @@ class Utils
|
|||
*/
|
||||
public static function IsIconvSupported()
|
||||
{
|
||||
return \MailSo\Base\Utils::FunctionExistsAndEnabled('iconv');
|
||||
return \MailSo\Capa::$ICONV &&
|
||||
\MailSo\Base\Utils::FunctionExistsAndEnabled('iconv');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public static function IsLibIconvSupported()
|
||||
public static function IsIconvIgnoreSupported()
|
||||
{
|
||||
return \MailSo\Base\Utils::FunctionExistsAndEnabled('libiconv');
|
||||
static $bCache = null;
|
||||
if (null !== $bCache)
|
||||
{
|
||||
return $bCache;
|
||||
}
|
||||
|
||||
$bCache = false;
|
||||
if (\MailSo\Base\Utils::IsIconvSupported())
|
||||
{
|
||||
if (false !== @\iconv('', '//IGNORE', ''))
|
||||
{
|
||||
$bCache = true;
|
||||
}
|
||||
}
|
||||
|
||||
return $bCache;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -109,7 +125,8 @@ class Utils
|
|||
*/
|
||||
public static function IsMbStringSupported()
|
||||
{
|
||||
return \MailSo\Base\Utils::FunctionExistsAndEnabled('mb_convert_encoding');
|
||||
return \MailSo\Capa::$MBSTRING &&
|
||||
\MailSo\Base\Utils::FunctionExistsAndEnabled('mb_convert_encoding');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -124,6 +141,46 @@ class Utils
|
|||
\in_array($sCharset, \MailSo\Base\Utils::$SuppostedCharsets));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sInputString
|
||||
* @param string $sInputFromEncoding
|
||||
* @param string $sInputToEncoding
|
||||
*
|
||||
* @return string|bool
|
||||
*/
|
||||
public static function IconvConvertEncoding($sInputString, $sInputFromEncoding, $sInputToEncoding)
|
||||
{
|
||||
$sIconvIgnorOption = '';
|
||||
if (\MailSo\Base\Utils::IsIconvIgnoreSupported())
|
||||
{
|
||||
$sIconvIgnorOption = '//IGNORE';
|
||||
}
|
||||
|
||||
return @\iconv(\strtoupper($sInputFromEncoding), \strtoupper($sInputToEncoding).$sIconvIgnorOption, $sInputString);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sInputString
|
||||
* @param string $sInputFromEncoding
|
||||
* @param string $sInputToEncoding
|
||||
*
|
||||
* @return string|bool
|
||||
*/
|
||||
public static function MbConvertEncoding($sInputString, $sInputFromEncoding, $sInputToEncoding)
|
||||
{
|
||||
static $sMbstringSubCh = null;
|
||||
if (null === $sMbstringSubCh)
|
||||
{
|
||||
$sMbstringSubCh = \mb_substitute_character();
|
||||
}
|
||||
|
||||
\mb_substitute_character('none');
|
||||
$sResult = @\mb_convert_encoding($sInputString, \strtoupper($sInputToEncoding), \strtoupper($sInputFromEncoding));
|
||||
\mb_substitute_character($sMbstringSubCh);
|
||||
|
||||
return $sResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sInputString
|
||||
* @param string $sInputFromEncoding
|
||||
|
|
@ -197,15 +254,11 @@ class Utils
|
|||
|
||||
if (\MailSo\Base\Utils::IsIconvSupported())
|
||||
{
|
||||
$sResult = @\iconv(\strtoupper($sFromEncoding), \strtoupper($sToEncoding).'//IGNORE', $sResult);
|
||||
$sResult = \MailSo\Base\Utils::IconvConvertEncoding($sResult, $sFromEncoding, $sToEncoding);
|
||||
}
|
||||
else if (\MailSo\Base\Utils::IsMbStringSupported())
|
||||
{
|
||||
$sResult = @\mb_convert_encoding($sResult, \strtoupper($sToEncoding), \strtoupper($sFromEncoding));
|
||||
}
|
||||
else if (\MailSo\Base\Utils::IsLibIconvSupported())
|
||||
{
|
||||
$sResult = @\libiconv(\strtoupper($sFromEncoding), \strtoupper($sToEncoding), $sResult);
|
||||
$sResult = \MailSo\Base\Utils::MbConvertEncoding($sResult, $sFromEncoding, $sToEncoding);
|
||||
}
|
||||
|
||||
$sResult = (false !== $sResult) ? $sResult : $sInputString;
|
||||
|
|
@ -428,54 +481,12 @@ class Utils
|
|||
* @param string $sEncodeType
|
||||
* @param string $sEncodeCharset
|
||||
* @param string $sValue
|
||||
* @param string $sHeaderName = ''
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function EncodeHeaderValue($sEncodeType, $sEncodeCharset, $sValue, $sHeaderName = '')
|
||||
public static function EncodeHeaderValue($sEncodeType, $sEncodeCharset, $sValue)
|
||||
{
|
||||
$sValue = \trim($sValue);
|
||||
|
||||
// return \mb_encode_mimeheader($sValue,
|
||||
// \MailSo\Base\Enumerations\Charset::UTF_8, 'Q',
|
||||
// \MailSo\Mime\Enumerations\Constants::CRLF);
|
||||
|
||||
// $splitWords = true;
|
||||
// if ($splitWords) {
|
||||
// $words = \array_map(function($word) use ($sEncodeCharset) {
|
||||
// $header = \iconv_mime_encode('Header', $word, array(
|
||||
// 'scheme' => 'Q',
|
||||
// 'line-length' => 78,
|
||||
// 'output-charset' => $sEncodeCharset,
|
||||
// ));
|
||||
// return \str_replace('Header: ', '', $header);
|
||||
// }, \explode(' ', $sValue));
|
||||
// return \implode("\r\n ", $words);
|
||||
// }
|
||||
//
|
||||
// $header = \iconv_mime_encode('Header', $sValue, array(
|
||||
// 'scheme' => 'Q',
|
||||
// 'line-length' => 998,
|
||||
// 'output-charset' => $sEncodeCharset,
|
||||
// ));
|
||||
// return \str_replace('Header: ', '', $header);
|
||||
//
|
||||
// $aPreferences = array(
|
||||
// 'input-charset' => \MailSo\Base\Enumerations\Charset::UTF_8,
|
||||
// 'output-charset' => $sEncodeCharset,
|
||||
// 'line-length' => \MailSo\Mime\Enumerations\Constants::LINE_LENGTH,
|
||||
// 'line-break-chars' => \MailSo\Mime\Enumerations\Constants::CRLF
|
||||
// );
|
||||
//
|
||||
// if (\in_array(\strtoupper($sEncodeType), array('B', 'Q')))
|
||||
// {
|
||||
// $aPreferences['scheme'] = \strtoupper($sEncodeType);
|
||||
// }
|
||||
//
|
||||
// $sHeaderName = 0 === \strlen($sHeaderName) ? 'X-Header' : $sHeaderName;
|
||||
// $sValue = \iconv_mime_encode($sHeaderName, $sValue, $aPreferences);
|
||||
// return \trim(substr($sValue, \strlen($sHeaderName) + 1));
|
||||
|
||||
if (0 < \strlen($sValue) && !\MailSo\Base\Utils::IsAscii($sValue))
|
||||
{
|
||||
switch (\strtoupper($sEncodeType))
|
||||
|
|
@ -807,7 +818,7 @@ class Utils
|
|||
static $bValidateAction = null;
|
||||
if (null === $bValidateAction)
|
||||
{
|
||||
$bValidateAction = !((bool) @\ini_get('safe_mode')) &&
|
||||
$bValidateAction = !((bool) \ini_get('safe_mode')) &&
|
||||
\MailSo\Base\Utils::FunctionExistsAndEnabled('set_time_limit');
|
||||
}
|
||||
|
||||
|
|
@ -1113,8 +1124,21 @@ class Utils
|
|||
return $sUtfString;
|
||||
}
|
||||
|
||||
$sUtfString = @\iconv('UTF-8', 'UTF-8//IGNORE', $sUtfString);
|
||||
$sNewUtfString = false;
|
||||
if (\MailSo\Base\Utils::IsIconvSupported())
|
||||
{
|
||||
$sNewUtfString = \MailSo\Base\Utils::IconvConvertEncoding($sUtfString, 'UTF-8', 'UTF-8');
|
||||
}
|
||||
else if (\MailSo\Base\Utils::IsMbStringSupported())
|
||||
{
|
||||
$sNewUtfString = \MailSo\Base\Utils::MbConvertEncoding($sUtfString, 'UTF-8', 'UTF-8');
|
||||
}
|
||||
|
||||
if (false !== $sNewUtfString)
|
||||
{
|
||||
$sUtfString = $sNewUtfString;
|
||||
}
|
||||
|
||||
$sUtfString = \preg_replace(
|
||||
'/[\x00-\x08\x10\x0B\x0C\x0E-\x1F\x7F]'.
|
||||
'|[\x00-\x7F][\x80-\xBF]+'.
|
||||
|
|
@ -1704,7 +1728,8 @@ class Utils
|
|||
$mResult = '';
|
||||
if (!\MailSo\Base\Utils::IsAscii($sStr))
|
||||
{
|
||||
$mResult = \MailSo\Base\Utils::FunctionExistsAndEnabled('mb_detect_encoding') ?
|
||||
$mResult = \MailSo\Base\Utils::IsMbStringSupported() &&
|
||||
\MailSo\Base\Utils::FunctionExistsAndEnabled('mb_detect_encoding') ?
|
||||
@\mb_detect_encoding($sStr, 'auto', true) : false;
|
||||
|
||||
if (false === $mResult && \MailSo\Base\Utils::IsIconvSupported())
|
||||
|
|
|
|||
19
rainloop/v/0.0.0/app/libraries/MailSo/Capa.php
Normal file
19
rainloop/v/0.0.0/app/libraries/MailSo/Capa.php
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
<?php
|
||||
|
||||
namespace MailSo;
|
||||
|
||||
/**
|
||||
* @category MailSo
|
||||
*/
|
||||
final class Capa
|
||||
{
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
static $ICONV = true;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
static $MBSTRING = true;
|
||||
}
|
||||
|
|
@ -203,7 +203,9 @@ class Header
|
|||
|
||||
if ($this->IsSubject())
|
||||
{
|
||||
if (!\MailSo\Base\Utils::IsAscii($sResult) && \function_exists('iconv_mime_encode'))
|
||||
if (!\MailSo\Base\Utils::IsAscii($sResult) &&
|
||||
\MailSo\Base\Utils::IsIconvSupported() &&
|
||||
\function_exists('iconv_mime_encode'))
|
||||
{
|
||||
$aPreferences = array(
|
||||
// 'scheme' => \MailSo\Base\Enumerations\Encoding::QUOTED_PRINTABLE_SHORT,
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ final class Version
|
|||
/**
|
||||
* @var string
|
||||
*/
|
||||
const APP_VERSION = '1.3.0';
|
||||
const APP_VERSION = '1.3.1';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
|
|
@ -38,7 +38,13 @@ final class Version
|
|||
*/
|
||||
public static function Signature()
|
||||
{
|
||||
$oPhar = new \Phar('mailso.phar');
|
||||
return $oPhar->getSignature();
|
||||
$sSignature = '';
|
||||
if (\defined('MAILSO_LIBRARY_USE_PHAR'))
|
||||
{
|
||||
$oPhar = new \Phar('mailso.phar');
|
||||
$sSignature = $oPhar->getSignature();
|
||||
}
|
||||
|
||||
return $sSignature;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5199,14 +5199,18 @@ class Actions
|
|||
}
|
||||
|
||||
$aHeaders = $mRow;
|
||||
|
||||
foreach ($aHeaders as $iIndex => $sHeaderValue)
|
||||
{
|
||||
$aHeaders[$iIndex] = \MailSo\Base\Utils::Utf8Clear($sHeaderValue);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$aNewItem = array();
|
||||
foreach ($aHeaders as $iIndex => $sHeaderValue)
|
||||
{
|
||||
$aNewItem[@\iconv('utf-8', 'utf-8//IGNORE', $sHeaderValue)] =
|
||||
isset($mRow[$iIndex]) ? $mRow[$iIndex] : '';
|
||||
$aNewItem[$sHeaderValue] = isset($mRow[$iIndex]) ? $mRow[$iIndex] : '';
|
||||
}
|
||||
|
||||
$aData[] = $aNewItem;
|
||||
|
|
|
|||
|
|
@ -214,6 +214,7 @@ Enables caching in the system'),
|
|||
'autocreate_system_folders' => array(true),
|
||||
'allow_message_append' => array(false),
|
||||
'determine_user_language' => array(true),
|
||||
'disable_iconv_if_mbstring_supported' => array(false),
|
||||
'login_fault_delay' => array(1),
|
||||
'log_ajax_response_write_limit' => array(300),
|
||||
'allow_html_editor_source_button' => array(false),
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ if (!function_exists('mb_strtoupper'))
|
|||
else $encoding = strtoupper($encoding);
|
||||
|
||||
if ('UTF-8' === $encoding || 'UTF8' === $encoding) $encoding = INF;
|
||||
else $s = iconv($encoding, 'UTF-8//IGNORE', $s);
|
||||
else $s = function_exists('iconv') ? iconv($encoding, 'UTF-8//IGNORE', $s) : $s;
|
||||
|
||||
static $upper;
|
||||
isset($upper) || $upper = unserialize(base64_decode('YToxMDUxOntzOjE6ImEiO3M6MToiQSI7czoxOiJiIjtzOjE6IkIiO3M6MToiYyI7czoxOiJDIjtz
|
||||
|
|
@ -400,7 +400,7 @@ czo0OiLwkJCmIjtzOjQ6IvCQkY8iO3M6NDoi8JCQpyI7fQ=='));
|
|||
}
|
||||
|
||||
if (INF === $encoding) return $s;
|
||||
else return iconv('UTF-8', $encoding, $s);
|
||||
else return function_exists('iconv') ? iconv('UTF-8', $encoding, $s) : $s;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -37,6 +37,12 @@ class Service
|
|||
\ini_set('display_errors', 1);
|
||||
}
|
||||
|
||||
if ($this->oActions->Config()->Get('labs', 'disable_iconv_if_mbstring_supported') &&
|
||||
\class_exists('MailSo\Capa') && \MailSo\Base\Utils::IsMbStringSupported())
|
||||
{
|
||||
\MailSo\Capa::$ICONV = false;
|
||||
}
|
||||
|
||||
$sServer = \trim($this->oActions->Config()->Get('security', 'custom_server_signature', ''));
|
||||
if (0 < \strlen($sServer))
|
||||
{
|
||||
|
|
@ -91,7 +97,7 @@ class Service
|
|||
{
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
$this->oActions->ParseQueryAuthString();
|
||||
|
||||
if (defined('APP_INSTALLED_START') && defined('APP_INSTALLED_VERSION') &&
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue