From a1733f06ae1031f0c5ae5ea2e92380ac5ce56494 Mon Sep 17 00:00:00 2001 From: alecpl Date: Mon, 29 Dec 2008 14:43:45 +0000 Subject: - fix identity name quoting when sending mail as per discussion in #1485654 --- program/steps/mail/sendmail.inc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'program/steps') diff --git a/program/steps/mail/sendmail.inc b/program/steps/mail/sendmail.inc index 21e1a7ff1..8e8d13919 100644 --- a/program/steps/mail/sendmail.inc +++ b/program/steps/mail/sendmail.inc @@ -64,7 +64,13 @@ function rcmail_get_identity($id) { $out = $sql_arr; $out['mailto'] = $sql_arr['email']; - $name = strpos($sql_arr['name'], ",") ? '"'.$sql_arr['name'].'"' : $sql_arr['name']; + + // Special chars as defined by RFC 822 need to in quoted string (or escaped). + if (preg_match('/[\(\)\<\>\\\.\[\]@,;:"]/', $sql_arr['name'])) + $name = '"' . addcslashes($sql_arr['name'], '"') . '"'; + else + $name = $sql_arr['name']; + $out['string'] = rcube_charset_convert($name, RCMAIL_CHARSET, $OUTPUT->get_charset()); if ($sql_arr['email']) $out['string'] .= ' <' . $sql_arr['email'] . '>'; -- cgit v1.2.3