From 153a7665cb14de417ce3fd7707e1552682e0cb25 Mon Sep 17 00:00:00 2001 From: Jared Hancock <jared@osticket.com> Date: Mon, 28 Apr 2014 17:46:55 -0500 Subject: [PATCH] storage: Support de-duplication in the mail channel (again) --- include/class.file.php | 3 ++- include/class.mailfetch.php | 1 + include/class.mailparse.php | 7 +++++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/include/class.file.php b/include/class.file.php index c0dbc3056..a2ce70bfa 100644 --- a/include/class.file.php +++ b/include/class.file.php @@ -394,8 +394,9 @@ class AttachmentFile { $file['size'] = $size; // Prefer mb_strlen, because mbstring.func_overload will // automatically prefer it if configured. - elseif (function_exists('mb_strlen')) + elseif (extension_loaded('mbstring')) $file['size'] = mb_strlen($file['data'], '8bit'); + // bootstrap.php include a compat version of mb_strlen else $file['size'] = strlen($file['data']); diff --git a/include/class.mailfetch.php b/include/class.mailfetch.php index 644d86663..0b739e7c8 100644 --- a/include/class.mailfetch.php +++ b/include/class.mailfetch.php @@ -462,6 +462,7 @@ class MailFetcher { array( 'name' => $this->mime_decode($filename), 'type' => $this->getMimeType($part), + 'size' => $part->bytes ?: null, 'encoding' => $part->encoding, 'index' => ($index?$index:1), 'cid' => $content_id, diff --git a/include/class.mailparse.php b/include/class.mailparse.php index f3feaf25d..378c68c19 100644 --- a/include/class.mailparse.php +++ b/include/class.mailparse.php @@ -396,6 +396,13 @@ class Mail_Parse { else $file['data'] = $part->body; + // Capture filesize in order to support de-duplication + if (extension_loaded('mbstring')) + $file['size'] = mb_strlen($file['data'], '8bit'); + // bootstrap.php include a compat version of mb_strlen + else + $file['size'] = strlen($file['data']); + if(!$this->decode_bodies && $part->headers['content-transfer-encoding']) $file['encoding'] = $part->headers['content-transfer-encoding']; -- GitLab