mirror of
https://github.com/the-djmaze/snappymail.git
synced 2024-11-10 09:02:45 +08:00
Cleanup attachment filenames
This commit is contained in:
parent
94bfe09f63
commit
7df3ed665d
3 changed files with 7 additions and 6 deletions
|
@ -9,6 +9,7 @@ const
|
|||
msOffice = app+'vnd.openxmlformats-officedocument.',
|
||||
openDoc = app+'vnd.oasis.opendocument.',
|
||||
sizes = ['B', 'KiB', 'MiB', 'GiB', 'TiB'],
|
||||
lowerCase = text => text.toLowerCase().trim(),
|
||||
|
||||
exts = {
|
||||
eml: 'message/rfc822',
|
||||
|
@ -123,13 +124,13 @@ export const FileInfo = {
|
|||
* @returns {string}
|
||||
*/
|
||||
getExtension: fileName => {
|
||||
fileName = fileName.toLowerCase().trim();
|
||||
fileName = lowerCase(fileName);
|
||||
const result = fileName.split('.').pop();
|
||||
return result === fileName ? '' : result;
|
||||
},
|
||||
|
||||
getContentType: fileName => {
|
||||
fileName = fileName.toLowerCase().trim();
|
||||
fileName = lowerCase(fileName);
|
||||
if ('winmail.dat' === fileName) {
|
||||
return app + 'ms-tnef';
|
||||
}
|
||||
|
@ -158,8 +159,8 @@ export const FileInfo = {
|
|||
* @returns {string}
|
||||
*/
|
||||
getType: (ext, mimeType) => {
|
||||
ext = ext.toLowerCase().trim();
|
||||
mimeType = mimeType.toLowerCase().trim().replace('csv/plain', 'text/csv');
|
||||
ext = lowerCase(ext);
|
||||
mimeType = lowerCase(mimeType).replace('csv/plain', 'text/csv');
|
||||
|
||||
let key = ext + mimeType;
|
||||
if (cache[key]) {
|
||||
|
|
|
@ -67,7 +67,7 @@ class Attachment implements \JsonSerializable
|
|||
if ($this->oBodyStructure)
|
||||
{
|
||||
$sFileName = $this->oBodyStructure->FileName();
|
||||
if ($bCalculateOnEmpty && 0 === \strlen(trim($sFileName)))
|
||||
if ($bCalculateOnEmpty && !\strlen(\trim($sFileName)))
|
||||
{
|
||||
$sMimeType = \strtolower(\trim($this->MimeType()));
|
||||
if ('message/rfc822' === $sMimeType)
|
||||
|
|
|
@ -29,7 +29,7 @@ class AttachmentCollection extends \MailSo\Base\Collection
|
|||
foreach ($this as $oAttachment) {
|
||||
$aResult[] = array(
|
||||
'@Object' => 'Object/Attachment',
|
||||
'FileName' => $oAttachment->FileName(true),
|
||||
'FileName' => $oAttachment->FileName(),
|
||||
'MimeType' => $oAttachment->MimeType(),
|
||||
'IsInline' => $oAttachment->IsInline()
|
||||
);
|
||||
|
|
Loading…
Reference in a new issue