[freeside-commits] branch FREESIDE_3_BRANCH updated. e031448c5911bd58dcf5daacae6c6755648fec5a

Mark Wells mark at 420.am
Wed Dec 14 13:42:17 PST 2016


The branch, FREESIDE_3_BRANCH has been updated
       via  e031448c5911bd58dcf5daacae6c6755648fec5a (commit)
       via  75ab0df930bcbf5173cdda2ce7704fdcf09d9d39 (commit)
       via  bd730ebd92b6c8f9d07d943dcb276e0c9cde3e30 (commit)
      from  2c5bb9b8dfea90e8aac3937dfd28e3826e9c5f99 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit e031448c5911bd58dcf5daacae6c6755648fec5a
Author: Mark Wells <mark at freeside.biz>
Date:   Wed Dec 14 13:00:24 2016 -0800

    fix parsing of multiple To: addresses, #73241

diff --git a/FS/FS/Misc.pm b/FS/FS/Misc.pm
index eedc736..ff5723f 100644
--- a/FS/FS/Misc.pm
+++ b/FS/FS/Misc.pm
@@ -254,13 +254,11 @@ sub send_email {
   }
 
   push @to, $options{bcc} if defined($options{bcc});
-  # make sure 
-  my @env_to = split(/\s*,\s*/, join(', ', @to));
-  # strip display-name from envelope addresses
-  foreach (@env_to) {
-    s/^\s*//;
-    s/\s*$//;
-    s/^(.*)\s*<(.*@.*)>$/$2/;
+  # fully unpack all addresses found in @to (including Bcc) to make the
+  # envelope list
+  my @env_to;
+  foreach my $dest (@to) {
+    push @env_to, map { $_->address } Email::Address->parse($dest);
   }
 
   local $@; # just in case
@@ -281,7 +279,7 @@ sub send_email {
   if ( $conf->exists('log_sent_mail') ) {
     my $cust_msg = FS::cust_msg->new({
         'env_from'  => $options{'from'},
-        'env_to'    => join(', ', @to),
+        'env_to'    => join(', ', @env_to),
         'header'    => $message->header_as_string,
         'body'      => $message->body_as_string,
         '_date'     => $time,
diff --git a/httemplate/search/cust_msg.html b/httemplate/search/cust_msg.html
index 2e1f75c..fdb72a5 100644
--- a/httemplate/search/cust_msg.html
+++ b/httemplate/search/cust_msg.html
@@ -19,7 +19,10 @@
                               ucfirst($_[0]->msgtype) || $_[0]->msgname
                             },
                             sub {
-                              join('<BR>', split(/,\s*/, $_[0]->env_to) )
+                              join('<BR>',
+                                map { encode_entities($_->format) }
+                                Email::Address->parse($_[0]->env_to)
+                              )
                             },
                             'status',
                             sub { encode_entities($_[0]->error) },
diff --git a/httemplate/view/cust_msg.html b/httemplate/view/cust_msg.html
index 91a08eb..d2b043c 100755
--- a/httemplate/view/cust_msg.html
+++ b/httemplate/view/cust_msg.html
@@ -61,7 +61,9 @@ $custmsgnum =~ /^(\d+)$/ or die "illegal custmsgnum";
 my $cust_msg = qsearchs('cust_msg', { 'custmsgnum' => $custmsgnum });
 my $date = '';
 $date = time2str('%Y-%m-%d %T', $cust_msg->_date) if ( $cust_msg->_date );
-my $env_to = join('</TD></TR><TR><TD></TD><TD>', split(',', $cust_msg->env_to));
+my @to = map { encode_entities($_->format) }
+          Email::Address->parse($cust_msg->env_to);
+my $env_to = join('</TD></TR><TR><TD></TD><TD>', @to);
 
 my %label = (
   'sent'   => 'Sent:',

commit 75ab0df930bcbf5173cdda2ce7704fdcf09d9d39
Merge: bd730eb 2c5bb9b
Author: Mark Wells <mark at freeside.biz>
Date:   Wed Dec 14 12:55:27 2016 -0800

    Merge branch 'FREESIDE_3_BRANCH' of git.freeside.biz:/home/git/freeside into 3.x


commit bd730ebd92b6c8f9d07d943dcb276e0c9cde3e30
Author: Mark Wells <mark at freeside.biz>
Date:   Tue Dec 13 16:40:05 2016 -0800

    Un-revert "Format email addresses w/Email::Address ... RT#73241"
    
    This reverts commit 99e45c99df978410140c0e14f17820d57f9e6b54.

diff --git a/FS/FS/cust_main.pm b/FS/FS/cust_main.pm
index 7e1a25d..0165bc4 100644
--- a/FS/FS/cust_main.pm
+++ b/FS/FS/cust_main.pm
@@ -32,6 +32,7 @@ use Digest::MD5 qw(md5_base64);
 use Date::Format;
 #use Date::Manip;
 use File::Temp; #qw( tempfile );
+use Email::Address;
 use Business::CreditCard 0.28;
 use FS::UID qw( getotaker dbh driver_name );
 use FS::Record qw( qsearchs qsearch dbdef regexp_sql );
@@ -3571,15 +3572,17 @@ sub contact_list_email {
         # unlike on 4.x, we have a separate list of invoice email
         # destinations.
         # make sure they're not redundant with contact emails
-        my $dest = $contact->firstlast . ' <' . $contact_email->emailaddress . '>';
-        $emails{ $contact_email->emailaddress } = $dest;
+        $emails{ $contact_email->emailaddress } =
+          Email::Address->new( $contact->firstlast,
+                               $contact_email->emailaddress
+                             )->format;
       }
     }
   }
   if ( $and_invoice ) {
     foreach my $email ($self->invoicing_list_emailonly) {
-      my $dest = $self->name_short . ' <' . $email . '>';
-      $emails{ $email } ||= $dest;
+      $emails{ $email } ||=
+        Email::Address->new( $self->name_short, $email )->format;
     }
   }
   values %emails;

-----------------------------------------------------------------------

Summary of changes:
 FS/FS/Misc.pm                   |   14 ++++++--------
 FS/FS/cust_main.pm              |   11 +++++++----
 httemplate/search/cust_msg.html |    5 ++++-
 httemplate/view/cust_msg.html   |    4 +++-
 4 files changed, 20 insertions(+), 14 deletions(-)




More information about the freeside-commits mailing list