From d519ef8a0a24e5cfcc13f136047dcabb504e9c1d Mon Sep 17 00:00:00 2001
From: alecpl <alec@alec.pl>
Date: Sun, 01 Mar 2009 02:55:39 -0500
Subject: [PATCH] - Fix attaching more than nine inline images (#1485759)

---
 CHANGELOG                       |    4 ++++
 program/steps/mail/sendmail.inc |    6 +++---
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/CHANGELOG b/CHANGELOG
index 946b25e..9a6b572 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,6 +1,10 @@
 CHANGELOG RoundCube Webmail
 ---------------------------
 
+2009/03/01 (alec)
+----------
+- Fix attaching more than nine inline images (#1485759)
+
 2009/02/27 (thomasb)
 ----------
 - Fix mime-type detection using a hard-coded map (#1485311)
diff --git a/program/steps/mail/sendmail.inc b/program/steps/mail/sendmail.inc
index b162260..eb81fc9 100644
--- a/program/steps/mail/sendmail.inc
+++ b/program/steps/mail/sendmail.inc
@@ -337,11 +337,11 @@
 if (is_array($_SESSION['compose']['attachments']))
   foreach ($_SESSION['compose']['attachments'] as $id => $attachment)
   {
-    $dispurl = '/\ssrc\s*=\s*[\'"]?\S+display-attachment\S+file=rcmfile' . $id . '[\'"]?/';
-    $match = preg_match($dispurl, $message_body);
+    $dispurl = '/\ssrc\s*=\s*[\'"]*\S+display-attachment\S+file=rcmfile' . $id . '[\s\'"]\s*/';
+    $match = preg_match($dispurl, $message_body, $matches);
     if ($isHtml && ($match > 0))
     {
-      $message_body = preg_replace($dispurl, ' src="'.$attachment['name'].'"', $message_body);
+      $message_body = preg_replace($dispurl, ' src="'.$attachment['name'].'" ', $message_body);
       $MAIL_MIME->setHTMLBody($message_body. ($footer ? "\r\n<pre>".$footer.'</pre>' : ''));
       $MAIL_MIME->addHTMLImage($attachment['path'], $attachment['mimetype'], $attachment['name']);
     }

--
Gitblit v1.9.1