From a9bfe21ba6329cf413b8965c8ce225308bcb6e57 Mon Sep 17 00:00:00 2001
From: alecpl <alec@alec.pl>
Date: Mon, 12 Oct 2009 05:44:04 -0400
Subject: [PATCH] - Fix importing/sending to email address with whitespace (#1486214)

---
 CHANGELOG                       |    3 ++-
 program/include/main.inc        |    6 +++---
 program/include/rcube_vcard.php |    1 +
 3 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/CHANGELOG b/CHANGELOG
index 05ca7b0..2975822 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,7 +1,8 @@
 CHANGELOG RoundCube Webmail
 ===========================
 
-- Added XIMSS (Communigate) driver for Password plugin
+- Fix importing/sending to email address with whitespace (#1486214)
+- Added XIMSS (CommuniGate) driver for Password plugin
 - Fix newly attached files are not saved in drafts w/o editing any text (#1486202)
 - Added attachment upload indicator with parallel upload (#1486058)
 - Use default_charset for bodies of messages without charset definition (#1486187)
diff --git a/program/include/main.inc b/program/include/main.inc
index 6e4cbe1..e968400 100644
--- a/program/include/main.inc
+++ b/program/include/main.inc
@@ -946,7 +946,7 @@
 
 
 /**
- * Compose a valid representaion of name and e-mail address
+ * Compose a valid representation of name and e-mail address
  *
  * @param string E-mail address
  * @param string Person name
@@ -957,10 +957,10 @@
   if ($name && $name != $email)
     {
     // Special chars as defined by RFC 822 need to in quoted string (or escaped).
-    return sprintf('%s <%s>', preg_match('/[\(\)\<\>\\\.\[\]@,;:"]/', $name) ? '"'.addcslashes($name, '"').'"' : $name, $email);
+    return sprintf('%s <%s>', preg_match('/[\(\)\<\>\\\.\[\]@,;:"]/', $name) ? '"'.addcslashes($name, '"').'"' : $name, trim($email));
     }
   else
-    return $email;
+    return trim($email);
   }
 
 
diff --git a/program/include/rcube_vcard.php b/program/include/rcube_vcard.php
index 7dbbb3f..f574eed 100644
--- a/program/include/rcube_vcard.php
+++ b/program/include/rcube_vcard.php
@@ -269,6 +269,7 @@
 
         foreach($regs2[1] as $attrid => $attr) {
           if ((list($key, $value) = explode('=', $attr)) && $value) {
+	    $value = trim($value);
             if ($key == 'ENCODING') {
               // add next line(s) to value string if QP line end detected
               while ($value == 'QUOTED-PRINTABLE' && preg_match('/=$/', $lines[$i]))

--
Gitblit v1.9.1