Login   Register  
PHP Classes
elePHPant
Icontem

_getAutoMimeType method bugfix

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us

      All In One - dSendMail2  >  All threads  >  _getAutoMimeType method bugfix  >  (Un) Subscribe thread alerts  
Subject:_getAutoMimeType method bugfix
Summary:_getAutoMimeType doesn't correctly extract file extension
Messages:1
Author:Michael Hosford
Date:2010-11-01 02:43:25
 

  1. _getAutoMimeType method bugfix   Reply   Report abuse  
Picture of Michael Hosford
Michael Hosford
2010-11-01 02:43:25
Hi,

When I auto-attached an image to be embedded in an HTML email, it got MIME-typed as 'application/octet-stream'. The email still displayed properly, but I noticed that the Spamassassin spam score was higher than it should be because of the mis-typed image.

Around line 546 of dSendMail2.inc.php (at the beginning of the _getAutoMimeType() function), is the line:
$ext = strtolower(substr($filename, -3));

The problems with using substr() to grab the last 3 characters of the filename is that (1) not all of the extensions are 3 chars long, and (2) all of the comparison strings in the case statement include the '.', so most of them are 4 chars long. The following correction works for extensions of any length, and fixes the problem:
$ext = strtolower(strrchr($filename,'.'));

Thanks--
Michael Hosford