From 864ea4d164baa019f135464033ff6129767e2831 Mon Sep 17 00:00:00 2001
From: Jared Hancock <jared@osticket.com>
Date: Thu, 1 May 2014 09:59:18 -0500
Subject: [PATCH] tnef: Send size of attachments for de-duplication

---
 include/class.mailfetch.php | 1 +
 include/class.mailparse.php | 1 +
 include/tnef_decoder.php    | 5 +++++
 3 files changed, 7 insertions(+)

diff --git a/include/class.mailfetch.php b/include/class.mailfetch.php
index 0b739e7c8..b4156ce7a 100644
--- a/include/class.mailfetch.php
+++ b/include/class.mailfetch.php
@@ -655,6 +655,7 @@ class MailFetcher {
                     $attachments[] = array(
                         'cid' => @$at->AttachContentId ?: false,
                         'data' => $at,
+                        'size' => @$at->DataSize ?: null,
                         'type' => @$at->AttachMimeTag ?: false,
                         'name' => $at->getName(),
                     );
diff --git a/include/class.mailparse.php b/include/class.mailparse.php
index 378c68c19..a17890c17 100644
--- a/include/class.mailparse.php
+++ b/include/class.mailparse.php
@@ -418,6 +418,7 @@ class Mail_Parse {
                 $files[] = array(
                     'cid' => @$at->AttachContentId ?: false,
                     'data' => $at->getData(),
+                    'size' => @$at->DataSize ?: null,
                     'type' => @$at->AttachMimeTag ?: false,
                     'name' => $at->getName(),
                 );
diff --git a/include/tnef_decoder.php b/include/tnef_decoder.php
index 45ee5b5c0..e0f7869ba 100644
--- a/include/tnef_decoder.php
+++ b/include/tnef_decoder.php
@@ -491,6 +491,7 @@ class TnefStreamParser {
                 break;
             case self::attAttachData:
                 $attach->_setData($info['data']);
+                $attach->_setDataSize($info['length']);
                 break;
             }
         }
@@ -557,6 +558,10 @@ class TnefAttachment extends AbstractTnefObject {
         $this->Data = $data;
     }
 
+    function _setDataSize($size) {
+        $this->DataSize = $size;
+    }
+
     function getData() {
         if (isset($this->Data))
             return $this->Data;
-- 
GitLab