From b5f7bdff788b7abce0a1930fbaa135ee7abab694 Mon Sep 17 00:00:00 2001
From: Jared Hancock <jared@osticket.com>
Date: Fri, 4 Oct 2013 18:30:12 +0000
Subject: [PATCH] Fix parsing of attachments

If the body is declared with inline disposition and no filename, the parser
engine would create an incorrect attachments list.
---
 include/class.mailparse.php | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/include/class.mailparse.php b/include/class.mailparse.php
index 1132073d0..039a48b74 100644
--- a/include/class.mailparse.php
+++ b/include/class.mailparse.php
@@ -201,9 +201,6 @@ class Mail_Parse {
 
     function getAttachments($part=null){
 
-        if($part==null)
-            $part=$this->getStruct();
-
         /* Consider this part as an attachment if
          *   * It has a Content-Disposition header
          *     * AND it is specified as either 'attachment' or 'inline'
@@ -254,6 +251,9 @@ class Mail_Parse {
             return array($file);
         }
 
+        if($part==null)
+            $part=$this->getStruct();
+
         $files=array();
         if($part->parts){
             foreach($part->parts as $k=>$p){
-- 
GitLab