1
0
mirror of https://github.com/mailcow/mailcow-dockerized.git synced 2026-07-23 05:03:29 +00:00

[Web] Prepare for oauth2

[Web] Some lib updates
[Web] Allow to add a footer
This commit is contained in:
andryyy
2019-09-28 20:00:04 +02:00
parent 3811866ea0
commit 7a85abdb42
176 changed files with 18448 additions and 504 deletions
@@ -2,6 +2,8 @@
namespace PhpMimeMailParser;
use function var_dump;
/**
* Attachment of php-mime-mail-parser
*
@@ -237,7 +239,9 @@ class Attachment
// Determine filename
switch ($filenameStrategy) {
case Parser::ATTACHMENT_RANDOM_FILENAME:
$attachment_path = tempnam($attach_dir, '');
$fileInfo = pathinfo($this->getFilename());
$extension = empty($fileInfo['extension']) ? '' : '.'.$fileInfo['extension'];
$attachment_path = $attach_dir.uniqid().$extension;
break;
case Parser::ATTACHMENT_DUPLICATE_THROW:
case Parser::ATTACHMENT_DUPLICATE_SUFFIX:
@@ -326,7 +326,7 @@ class Charset implements CharsetManager
return mb_convert_encoding($encodedString, 'utf-8', 'iso-2022-jp-ms');
}
if (array_search($charset, array_map('strtolower', mb_list_encodings()))) {
if (array_search($charset, $this->getSupportedEncodings())) {
return mb_convert_encoding($encodedString, 'utf-8', $charset);
}
}
@@ -347,4 +347,24 @@ class Charset implements CharsetManager
return 'us-ascii';
}
private function getSupportedEncodings()
{
return
array_map(
'strtolower',
array_unique(
array_merge(
$enc = mb_list_encodings(),
call_user_func_array(
'array_merge',
array_map(
"mb_encoding_aliases",
$enc
)
)
)
)
);
}
}
@@ -84,9 +84,9 @@ class MimePart implements \ArrayAccess
{
if (is_null($offset)) {
$this->part[] = $value;
} else {
$this->part[$offset] = $value;
return;
}
$this->part[$offset] = $value;
}
/**
@@ -268,7 +268,7 @@ class Parser
{
if (isset($this->parts[1])) {
$headers = $this->getPart('headers', $this->parts[1]);
foreach ($headers as $name => &$value) {
foreach ($headers as &$value) {
if (is_array($value)) {
foreach ($value as &$v) {
$v = $this->decodeSingleHeader($v);
@@ -514,20 +514,17 @@ class Parser
if (isset($part['disposition-filename'])) {
$filename = $this->decodeHeader($part['disposition-filename']);
// Escape all potentially unsafe characters from the filename
$filename = preg_replace('((^\.)|\/|(\.$))', '_', $filename);
} elseif (isset($part['content-name'])) {
// if we have no disposition but we have a content-name, it's a valid attachment.
// we simulate the presence of an attachment disposition with a disposition filename
$filename = $this->decodeHeader($part['content-name']);
// Escape all potentially unsafe characters from the filename
$filename = preg_replace('((^\.)|\/|(\.$))', '_', $filename);
$disposition = 'attachment';
} elseif (in_array($part['content-type'], $non_attachment_types, true)
&& $disposition !== 'attachment') {
// it is a message body, no attachment
continue;
} elseif (substr($part['content-type'], 0, 10) !== 'multipart/') {
} elseif (substr($part['content-type'], 0, 10) !== 'multipart/'
&& $part['content-type'] !== 'text/plain; (error)') {
// if we cannot get it by getMessageBody(), we assume it is an attachment
$disposition = 'attachment';
}
@@ -539,6 +536,9 @@ class Parser
if ($filename == 'noname') {
$nonameIter++;
$filename = 'noname'.$nonameIter;
} else {
// Escape all potentially unsafe characters from the filename
$filename = preg_replace('((^\.)|\/|[\n|\r|\n\r]|(\.$))', '_', $filename);
}
$headersAttachments = $this->getPart('headers', $part);