From 3b8fa83accdfc0d49da5dbf744761bdb72f029b2 Mon Sep 17 00:00:00 2001 From: Klaus Leithoff Date: Mon, 6 Dec 2010 15:07:48 +0000 Subject: [PATCH] * eMail: remove invalid -at- when occurring in full name, when adding address to email; skip addresses that produce a parse error while parsed with imap_rfc822_parse_adrlist --- addressbook/inc/class.addressbook_ui.inc.php | 2 +- felamimail/inc/class.ajax_contacts.inc.php | 2 +- felamimail/inc/class.bocompose.inc.php | 13 +++++++++---- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/addressbook/inc/class.addressbook_ui.inc.php b/addressbook/inc/class.addressbook_ui.inc.php index f27ce356d9..2256ee4033 100644 --- a/addressbook/inc/class.addressbook_ui.inc.php +++ b/addressbook/inc/class.addressbook_ui.inc.php @@ -729,7 +729,7 @@ class addressbook_ui extends addressbook_bo } if($email) { - $contact['n_fn'] = str_replace(',',' ',$contact['n_fn']); + $contact['n_fn'] = str_replace(array(',','@'),' ',$contact['n_fn']); egw_framework::set_onload("addEmail('".addslashes( $contact['n_fn'] ? $contact['n_fn'].' <'.trim($email).'>' : trim($email))."');"); //error_log(__METHOD__.__LINE__."addEmail('".addslashes( diff --git a/felamimail/inc/class.ajax_contacts.inc.php b/felamimail/inc/class.ajax_contacts.inc.php index f8b74b390a..118c2473ab 100644 --- a/felamimail/inc/class.ajax_contacts.inc.php +++ b/felamimail/inc/class.ajax_contacts.inc.php @@ -71,7 +71,7 @@ foreach(array($contact['email'],$contact['email_home']) as $email) { // avoid wrong addresses, if an rfc822 encoded address is in addressbook $email = preg_replace("/(^.*<)([a-zA-Z0-9_\-]+@[a-zA-Z0-9_\-\.]+)(.*)/",'$2',$email); - $contact['n_fn'] = str_replace(',',' ',$contact['n_fn']); + $contact['n_fn'] = str_replace(array(',','@'),' ',$contact['n_fn']); $completeMailString = addslashes(trim($contact['n_fn'] ? $contact['n_fn'] : $contact['fn']) .' <'. trim($email) .'>'); if(!empty($email) && in_array($completeMailString ,$jsArray) === false) { $i++; diff --git a/felamimail/inc/class.bocompose.inc.php b/felamimail/inc/class.bocompose.inc.php index 4687626306..0ba69c7051 100644 --- a/felamimail/inc/class.bocompose.inc.php +++ b/felamimail/inc/class.bocompose.inc.php @@ -712,40 +712,44 @@ foreach((array)$_formData['to'] as $address) { $address_array = imap_rfc822_parse_adrlist((get_magic_quotes_gpc()?stripslashes($address):$address), ''); foreach((array)$address_array as $addressObject) { + if ($addressObject->host == '.SYNTAX-ERROR.') continue; $emailAddress = $addressObject->mailbox. (!empty($addressObject->host) ? '@'.$addressObject->host : ''); #$emailName = $bofelamimail->encodeHeader($addressObject->personal, 'q'); #$_mailObject->AddAddress($emailAddress, $emailName); - $_mailObject->AddAddress($emailAddress, $addressObject->personal); + $_mailObject->AddAddress($emailAddress, str_replace(array('@'),' ',$addressObject->personal)); } } foreach((array)$_formData['cc'] as $address) { $address_array = imap_rfc822_parse_adrlist((get_magic_quotes_gpc()?stripslashes($address):$address),''); foreach((array)$address_array as $addressObject) { + if ($addressObject->host == '.SYNTAX-ERROR.') continue; $emailAddress = $addressObject->mailbox. (!empty($addressObject->host) ? '@'.$addressObject->host : ''); #$emailName = $bofelamimail->encodeHeader($addressObject->personal, 'q'); #$_mailObject->AddCC($emailAddress, $emailName); - $_mailObject->AddCC($emailAddress, $addressObject->personal); + $_mailObject->AddCC($emailAddress, str_replace(array('@'),' ',$addressObject->personal)); } } foreach((array)$_formData['bcc'] as $address) { $address_array = imap_rfc822_parse_adrlist((get_magic_quotes_gpc()?stripslashes($address):$address),''); foreach((array)$address_array as $addressObject) { + if ($addressObject->host == '.SYNTAX-ERROR.') continue; $emailAddress = $addressObject->mailbox. (!empty($addressObject->host) ? '@'.$addressObject->host : ''); #$emailName = $bofelamimail->encodeHeader($addressObject->personal, 'q'); #$_mailObject->AddBCC($emailAddress, $emailName); - $_mailObject->AddBCC($emailAddress, $addressObject->personal); + $_mailObject->AddBCC($emailAddress, str_replace(array('@'),' ',$addressObject->personal)); } } foreach((array)$_formData['replyto'] as $address) { $address_array = imap_rfc822_parse_adrlist((get_magic_quotes_gpc()?stripslashes($address):$address),''); foreach((array)$address_array as $addressObject) { + if ($addressObject->host == '.SYNTAX-ERROR.') continue; $emailAddress = $addressObject->mailbox. (!empty($addressObject->host) ? '@'.$addressObject->host : ''); #$emailName = $bofelamimail->encodeHeader($addressObject->personal, 'q'); #$_mailObject->AddBCC($emailAddress, $emailName); - $_mailObject->AddReplyto($emailAddress, $addressObject->personal); + $_mailObject->AddReplyto($emailAddress, str_replace(array('@'),' ',$addressObject->personal)); } } @@ -980,6 +984,7 @@ //$mail->SMTPDebug = 10; //error_log("Folder:".count(array($this->sessionData['folder']))."To:".count((array)$this->sessionData['to'])."CC:". count((array)$this->sessionData['cc']) ."bcc:".count((array)$this->sessionData['bcc'])); if(count((array)$this->sessionData['to']) > 0 || count((array)$this->sessionData['cc']) > 0 || count((array)$this->sessionData['bcc']) > 0) { +error_log(__METHOD__.__LINE__.array2string($mail)); try { $mail->Send(); }