mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-07 00:17:03 +03:00
Resolve Issue #144
This commit is contained in:
parent
8abf8844bc
commit
fd28e65ed6
2 changed files with 55 additions and 52 deletions
|
|
@ -771,59 +771,53 @@ END;
|
||||||
|
|
||||||
public static function ContentTypeType(string $sContentType, string $sFileName) : string
|
public static function ContentTypeType(string $sContentType, string $sFileName) : string
|
||||||
{
|
{
|
||||||
$sResult = '';
|
|
||||||
$sContentType = \strtolower($sContentType);
|
$sContentType = \strtolower($sContentType);
|
||||||
if (0 === \strpos($sContentType, 'image/'))
|
if (0 === \strpos($sContentType, 'image/')) {
|
||||||
{
|
return 'image';
|
||||||
$sResult = 'image';
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
switch ($sContentType)
|
|
||||||
{
|
|
||||||
case 'application/zip':
|
|
||||||
case 'application/x-7z-compressed':
|
|
||||||
case 'application/x-rar-compressed':
|
|
||||||
case 'application/x-msdownload':
|
|
||||||
case 'application/vnd.ms-cab-compressed':
|
|
||||||
case 'application/x-gzip':
|
|
||||||
case 'application/x-bzip':
|
|
||||||
case 'application/x-bzip2':
|
|
||||||
case 'application/x-debian-package':
|
|
||||||
$sResult = 'archive';
|
|
||||||
break;
|
|
||||||
case 'application/msword':
|
|
||||||
case 'application/rtf':
|
|
||||||
case 'application/vnd.ms-excel':
|
|
||||||
case 'application/vnd.ms-powerpoint':
|
|
||||||
case 'application/vnd.openxmlformats-officedocument.wordprocessingml.document':
|
|
||||||
case 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet':
|
|
||||||
case 'application/vnd.openxmlformats-officedocument.wordprocessingml.template':
|
|
||||||
case 'application/vnd.openxmlformats-officedocument.presentationml.presentation':
|
|
||||||
case 'application/vnd.oasis.opendocument.text':
|
|
||||||
case 'application/vnd.oasis.opendocument.spreadsheet':
|
|
||||||
$sResult = 'doc';
|
|
||||||
break;
|
|
||||||
case 'application/pdf':
|
|
||||||
case 'application/x-pdf':
|
|
||||||
$sResult = 'pdf';
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ('' === $sResult)
|
|
||||||
{
|
|
||||||
switch (\strtolower(static::GetFileExtension($sFileName)))
|
|
||||||
{
|
|
||||||
case 'zip':
|
|
||||||
case '7z':
|
|
||||||
case 'rar':
|
|
||||||
$sResult = 'archive';
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $sResult;
|
switch ($sContentType)
|
||||||
|
{
|
||||||
|
case 'application/zip':
|
||||||
|
case 'application/x-7z-compressed':
|
||||||
|
case 'application/x-rar-compressed':
|
||||||
|
case 'application/x-msdownload':
|
||||||
|
case 'application/vnd.ms-cab-compressed':
|
||||||
|
case 'application/x-gzip':
|
||||||
|
case 'application/x-bzip':
|
||||||
|
case 'application/x-bzip2':
|
||||||
|
case 'application/x-debian-package':
|
||||||
|
return 'archive';
|
||||||
|
|
||||||
|
case 'application/msword':
|
||||||
|
case 'application/rtf':
|
||||||
|
case 'application/vnd.ms-excel':
|
||||||
|
case 'application/vnd.ms-powerpoint':
|
||||||
|
case 'application/vnd.openxmlformats-officedocument.wordprocessingml.document':
|
||||||
|
case 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet':
|
||||||
|
case 'application/vnd.openxmlformats-officedocument.wordprocessingml.template':
|
||||||
|
case 'application/vnd.openxmlformats-officedocument.presentationml.presentation':
|
||||||
|
case 'application/vnd.oasis.opendocument.text':
|
||||||
|
case 'application/vnd.oasis.opendocument.spreadsheet':
|
||||||
|
return 'doc';
|
||||||
|
|
||||||
|
case 'application/pdf':
|
||||||
|
case 'application/x-pdf':
|
||||||
|
return 'pdf';
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (\strtolower(static::GetFileExtension($sFileName)))
|
||||||
|
{
|
||||||
|
case 'zip':
|
||||||
|
case '7z':
|
||||||
|
case 'rar':
|
||||||
|
return 'archive';
|
||||||
|
|
||||||
|
case 'pdf':
|
||||||
|
return 'pdf';
|
||||||
|
}
|
||||||
|
|
||||||
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -147,8 +147,12 @@ trait Raw
|
||||||
|
|
||||||
$oAccount = $this->getAccountFromToken();
|
$oAccount = $this->getAccountFromToken();
|
||||||
|
|
||||||
$sContentTypeOut = empty($sContentTypeIn) ?
|
// https://github.com/the-djmaze/snappymail/issues/144
|
||||||
\MailSo\Base\Utils::MimeContentType($sFileNameIn) : $sContentTypeIn;
|
if ('.pdf' === \substr($sFileNameIn,-4)) {
|
||||||
|
$sContentTypeOut = 'application/pdf'; // application/octet-stream
|
||||||
|
} else {
|
||||||
|
$sContentTypeOut = $sContentTypeIn ?: \MailSo\Base\Utils::MimeContentType($sFileNameIn);
|
||||||
|
}
|
||||||
|
|
||||||
$sFileNameOut = $this->MainClearFileName($sFileNameIn, $sContentTypeIn, $sMimeIndex);
|
$sFileNameOut = $this->MainClearFileName($sFileNameIn, $sContentTypeIn, $sMimeIndex);
|
||||||
|
|
||||||
|
|
@ -204,6 +208,11 @@ trait Raw
|
||||||
$sFileNameOut = $sFileName;
|
$sFileNameOut = $sFileName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://github.com/the-djmaze/snappymail/issues/144
|
||||||
|
if ('.pdf' === \substr($sFileNameOut,-4)) {
|
||||||
|
$sContentTypeOut = 'application/pdf';
|
||||||
|
}
|
||||||
|
|
||||||
$sFileNameOut = $self->MainClearFileName($sFileNameOut, $sContentTypeOut, $sMimeIndex);
|
$sFileNameOut = $self->MainClearFileName($sFileNameOut, $sContentTypeOut, $sMimeIndex);
|
||||||
|
|
||||||
$self->cacheByKey($sRawKey);
|
$self->cacheByKey($sRawKey);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue