From 66a0c9f49176ec3309b94ea232fbbd92735454ae Mon Sep 17 00:00:00 2001 From: David Flatz Date: Fri, 5 Feb 2016 12:12:07 +0100 Subject: use php function to escape headers; don't swallow double quotes when escaping, this should fix bounces when realname contains umlauts and komma; be a little pedantic about whitespace in addrlist --- it_mail.class | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'it_mail.class') diff --git a/it_mail.class b/it_mail.class index 73b0bd7..aa242c5 100644 --- a/it_mail.class +++ b/it_mail.class @@ -305,7 +305,7 @@ function send($p = array()) function header_escape($string) { return preg_match('/[\x00-\x1f\x7f-\xff]/', $string) - ? ("=?{$this->charset}?Q?" . str_replace(" ", "_", preg_replace_callback('/[\x00-\x1f=\x7f-\xff]/', function($m) { return sprintf('=%02X', ord($m[0])); }, trim($string, ' "'))) . "?=") + ? ltrim(iconv_mime_encode('', $string, array('scheme' => 'Q', 'input-charset' => $this->charset, 'output-charset' => $this->charset)), ' :') : $string; } @@ -332,12 +332,12 @@ function addrlist_escape($string) foreach ((array)$mailboxes as $mailbox) { if (preg_match('/^(.*)(\s+?<[^>]+@[^>]+>\s*)$/', $mailbox, $matches)) - $result[] = $this->header_escape($matches[1]) . $matches[2]; + $result[] = $this->header_escape(trim($matches[1])) . $matches[2]; else - $result[] = $mailbox; + $result[] = trim($mailbox); } - return implode(',', $result); + return implode(', ', $result); } -- cgit v1.2.3