From 5eef6313ef7b70106c77d5cdc789396a082b5f8e Mon Sep 17 00:00:00 2001 From: westi Date: Mon, 19 Sep 2011 14:30:50 +0000 Subject: [PATCH] Improve the parsing of email addresses in wp_mail to re-support RFC2822 nameless "" style. Fixes #18463 props kitchin and SergeyBiryukov. git-svn-id: http://svn.automattic.com/wordpress/trunk@18717 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/pluggable.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/wp-includes/pluggable.php b/wp-includes/pluggable.php index 1b453a9fdf..3eb2abadf5 100644 --- a/wp-includes/pluggable.php +++ b/wp-includes/pluggable.php @@ -338,13 +338,13 @@ function wp_mail( $to, $subject, $message, $headers = '', $attachments = array() try { // Break $recipient into name and address parts if in the format "Foo " $recipient_name = ''; - if( preg_match( '/(.+)\s?<(.+)>/', $recipient, $matches ) ) { + if( preg_match( '/(.*)<(.+)>/', $recipient, $matches ) ) { if ( count( $matches ) == 3 ) { $recipient_name = $matches[1]; $recipient = $matches[2]; } } - $phpmailer->AddAddress( trim( $recipient ), $recipient_name); + $phpmailer->AddAddress( $recipient, $recipient_name); } catch ( phpmailerException $e ) { continue; } @@ -360,13 +360,13 @@ function wp_mail( $to, $subject, $message, $headers = '', $attachments = array() try { // Break $recipient into name and address parts if in the format "Foo " $recipient_name = ''; - if( preg_match( '/(.+)\s?<(.+)>/', $recipient, $matches ) ) { + if( preg_match( '/(.*)<(.+)>/', $recipient, $matches ) ) { if ( count( $matches ) == 3 ) { $recipient_name = $matches[1]; $recipient = $matches[2]; } } - $phpmailer->AddCc( trim($recipient), $recipient_name ); + $phpmailer->AddCc( $recipient, $recipient_name ); } catch ( phpmailerException $e ) { continue; } @@ -378,13 +378,13 @@ function wp_mail( $to, $subject, $message, $headers = '', $attachments = array() try { // Break $recipient into name and address parts if in the format "Foo " $recipient_name = ''; - if( preg_match( '/(.+)\s?<(.+)>/', $recipient, $matches ) ) { + if( preg_match( '/(.*)<(.+)>/', $recipient, $matches ) ) { if ( count( $matches ) == 3 ) { $recipient_name = $matches[1]; $recipient = $matches[2]; } } - $phpmailer->AddBcc( trim($recipient), $recipient_name ); + $phpmailer->AddBcc( $recipient, $recipient_name ); } catch ( phpmailerException $e ) { continue; }