Index: mimemail.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/mimemail/mimemail.inc,v
retrieving revision 1.29
diff -r1.29 mimemail.inc
89,90c89,91
<   $pattern = '/(<link[^>]+href="?|<object[^>]+codebase="?|@import |src="?)\/?([^"]+)("?)/emis';
<   $html = preg_replace($pattern, '"\\1". _mimemail_file("\\2") ."\\3"', $html);
---
>   $pattern = '/(<link[^>]+href=[\'"]?|<object[^>]+codebase=[\'"]?|@import |src=[\'"]?)([^\'>"]+)([\'"]?)/emis';
>   $replace = 'stripslashes("\\1")._mimemail_file("\\2").stripslashes("\\3")'; 
>   $html = preg_replace($pattern, $replace, $html);
106c107
<  * @param $file a link to a file
---
>  * @param $url a URL to a file
110c111
< function _mimemail_file($file = NULL, $name = '', $type = '', $disposition = 'related') {
---
> function _mimemail_file($url = NULL, $name = '', $type = '', $disposition = 'related') {
113,114c114,115
<   if ($file && !preg_match('@://|mailto:@', $file) && file_exists($file)) {
<     $content_id = md5($file) .'@'. $_SERVER['HTTP_HOST'];
---
>   if ($url) {
>     $url = _mimemail_url($url, 'TRUE');
116,117c117,119
<     if (!$name) {
<       $name = substr($file, strrpos($file, '/') + 1);
---
>     // If the $url is absolute, we're done here.
>     if (strpos($url, '://') || preg_match('!mailto:!', $url)) {
>       return $url;
118a121,125
>     else {
>     // The $url is a relative file path, continue processing.
>       $file = $url;
>     }
>   }
120c127,133
<     $new_file = array('name' => $name,
---
>   if ($file && file_exists($file)) {
>     $content_id = md5($file) .'@'. $_SERVER['HTTP_HOST'];
> 
>     if (!$name) $name = substr($file, strrpos($file, '/') + 1);
> 
>     $new_file = array(
>       'name' => $name,
132,135d144
<   if ($file) {
<     return $file;
<   }
< 
469,483d477
<  */
< function _mimemail_uri($href, $link) {
<   $href = _mimemail_url($href);
<   if ($href == $link) {
<     $output = '['. $href .']';
<   }
<   else {
<     $output = $link .' ['. $href .']';
<   }
<   return $output;
< }
< 
< /**
<  * Helper function to format urls
<  *
488,491c482,483
< function _mimemail_url($url) {
<   if (strpos($url, '://')) {
<     return $url;
<   }
---
> function _mimemail_url($url, $embed_file = NULL) {
>   $url = urldecode($url); 
493,494c485,487
<   if (preg_match('!mailto:!i', $url)) {
<     return $url;
---
>   // If the URL is absolute or a mailto, return it as-is.
>   if (strpos($url, '://') || preg_match('!mailto:!', $url)) {
>     return str_replace(" ", "%20", $url);
497c490,494
<   $url = preg_replace( '!'. base_path() .'!', '', $url, 1);
---
>   $url = preg_replace( '!^'. base_path() .'!', '', $url, 1);
> 
>   // If we're processing to embed the file, we're done here so return.
>   if ($embed_file) return $url;
> 
505,529c502,505
< 
<   return url($path, $query, $fragment, TRUE);
< }
< 
< /**
<  * Helper function to store processed urls.
<  *
<  * @param $url Optional.
<  * @param $refresh Optional. If TRUE refresh the cache.
<  *
<  * @return a count of stored if $url evaluates to false, the stored urls ortherwise.
<  */
< function _mimemail_urls($url = 0, $refresh = FALSE) {
<   static $urls = array();
< 
<   if ($refresh) {
<     $urls = array();
<   }
< 
<   if ($url) {
<     $urls[] = _mimemail_url($url);
<     return count($urls);
<   }
< 
<   return $urls;
---
>   
>   $url = url($path, $query, $fragment, TRUE);
>   $url = str_replace("+", "%20", $url);
>   return $url; 
