From 87972399ed1401d29250c2473f45141053673648 Mon Sep 17 00:00:00 2001
From: Peter Rotich <peter@osticket.com>
Date: Wed, 25 Jul 2012 11:56:04 -0400
Subject: [PATCH] Switch attachment type validation to the new routine

---
 api/pipe.php                | 14 ++++----------
 include/class.mailfetch.php |  6 ++++--
 2 files changed, 8 insertions(+), 12 deletions(-)

diff --git a/api/pipe.php b/api/pipe.php
index a35d2af20..2c43e5681 100644
--- a/api/pipe.php
+++ b/api/pipe.php
@@ -100,8 +100,6 @@ if(preg_match ("[[#][0-9]{1,10}]",$var['subject'],$regs)) {
 $errors=array();
 $msgid=0;
 if(!$ticket){ //New tickets...
-    # Apply filters against the new ticket
-    $ef = new EmailFilter($var); $ef->apply($var);
     $ticket=Ticket::create($var,$errors,'email');
     if(!is_object($ticket) || $errors){
         api_exit(EX_DATAERR,'Ticket create Failed '.implode("\n",$errors)."\n\n");
@@ -118,14 +116,10 @@ if(!$ticket){ //New tickets...
     }
 }
 //Ticket created...save attachments if enabled.
-if($cfg->allowEmailAttachments()) {                   
-    if($attachments=$parser->getAttachments()){
-        //print_r($attachments);
-        foreach($attachments as $k=>$attachment){
-            if($attachment['filename'] && $cfg->canUploadFileType($attachment['filename'])) {
-                $ticket->saveAttachment(array('name' => $attachment['filename'], 'data' => $attachment['body']),$msgid,'M');
-            }
-        }
+if($cfg->allowEmailAttachments() && ($attachments=$parser->getAttachments())) {
+    foreach($attachments as $k=>$attachment) {
+        if($attachment['filename'] && $ost->isFileTypeAllowed($attachment['filename']))
+            $ticket->saveAttachment(array('name' => $attachment['filename'], 'data' => $attachment['body']), $msgid, 'M');
     }
 }
 api_exit(EX_SUCCESS);
diff --git a/include/class.mailfetch.php b/include/class.mailfetch.php
index 248a6ba81..fb17d8a26 100644
--- a/include/class.mailfetch.php
+++ b/include/class.mailfetch.php
@@ -323,11 +323,13 @@ class MailFetcher {
     }
 
     function saveAttachments($ticket,$mid,$part,$index=0) {
-        global $cfg;
+        global $ost;
 
         if($part && $part->ifdparameters && ($filename=$part->dparameters[0]->value)){ //attachment
             $index=$index?$index:1;
-            if($ticket && $cfg->canUploadFileType($filename) && $cfg->getMaxFileSize()>=$part->bytes) {
+            if($ticket 
+                    && $ost->isFileTypeAllowed($filename) 
+                    && $ost->getConfig()->getMaxFileSize()>=$part->bytes) {
                 //extract the attachments...and do the magic.
                 $data=$this->decode($part->encoding, imap_fetchbody($this->mbox,$mid,$index));
                 $ticket->saveAttachment(array('name'=>$filename, 'data'=>$data),$ticket->getLastMsgId(),'M');
-- 
GitLab