Index: mimemail.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/mimemail/mimemail.inc,v
retrieving revision 1.31.2.3
diff -u -p -r1.31.2.3 mimemail.inc
--- mimemail.inc	14 Apr 2009 23:08:59 -0000	1.31.2.3
+++ mimemail.inc	14 Aug 2009 10:37:32 -0000
@@ -123,7 +123,7 @@ function _mimemail_file($url = NULL, $na
     }
   }
 
-  if ($file && file_exists($file)) {
+  if (!empty($file) && file_exists($file)) {
     // Prevent duplicate items
     if (isset($filenames[$file])) return 'cid:'. $filenames[$file];
     
@@ -210,7 +210,7 @@ function mimemail_multipart_body($parts,
       $part_headers['Content-Disposition'] = 'inline';
     }
 
-    if ($part['Content-Transfer-Encoding']) {
+    if (isset($part['Content-Transfer-Encoding'])) {
       $part_headers['Content-Transfer-Encoding'] = $part['Content-Transfer-Encoding'];
     }
 
@@ -273,7 +273,7 @@ function mimemail_html_body($body, $subj
     // todo: remove this preg_replace once filter_xss() is properly handling
     // direct descendant css selectors '>' in inline CSS. For now this cleans
     // up our plain text part. See mimemail #364198, drupal #370903
-    $text = preg_replace('|<style.*</style>|mis', '', $body);
+    $text = preg_replace('|<style.*?</style>|mis', '', $body);
     $text = drupal_html_to_text($text);
   }
   if ($plaintext) {
@@ -374,7 +374,7 @@ function mimemail_parse($message) {
 
   // Make sure our text and html parts are accounted for
   if (isset($mail['html']) && !isset($mail['text'])) {
-    $mail['text'] = preg_replace('|<style.*</style>|mis', '', $mail['html']);
+    $mail['text'] = preg_replace('|<style.*?</style>|mis', '', $mail['html']);
     $mail['text'] = drupal_html_to_text($mail['text']);
   }
   elseif (isset($mail['text']) && !isset($mail['html'])) {
@@ -508,8 +508,8 @@ function _mimemail_url($url, $embed_file
   }
 
   $url = str_replace('?q=', '', $url);
-  list($url, $fragment) = explode('#', $url, 2);
-  list($path, $query) = explode('?', $url, 2);
+  list($url, $fragment) = explode('#', $url .'#', 2);
+  list($path, $query) = explode('?', $url .'?', 2);
 
   // If we're dealing with an intra-document reference, return it.
   if (empty($path) && !empty($fragment)) {
