[Rt-commit] rt branch, 4.0/outlook-quoted-email-addresses, created. rt-4.0.5-135-gc7f9a42
Thomas Sibley
trs at bestpractical.com
Mon Apr 30 18:40:26 EDT 2012
The branch, 4.0/outlook-quoted-email-addresses has been created
at c7f9a42b9d9531beafdf267206e07f686fa1c26e (commit)
- Log -----------------------------------------------------------------
commit c7f9a42b9d9531beafdf267206e07f686fa1c26e
Author: Thomas Sibley <trs at bestpractical.com>
Date: Mon Apr 30 18:08:45 2012 -0400
Liberally handle email addresses surrounded by single quotes in incoming headers
Outlook is known to produce mail headers like so:
Cc: "John Smith" <'jsmith at example.com'>
While Mr. Smith won't have received the original mail Cc'd to him and
RT, RT can at least notify him of future mail on the ticket if
$ParseNewMessageForTicketCcs is enabled.
This commit handles incoming mail. There are still many places that
directly parse mail headers from the database and don't strip
surrounding single quotes. For example, headers like the above will
still produce incorrect suggestions for the "One-time Cc/Bcc" fields on
ticket reply/comment pages. To fix this for good, we need to first
consolidate all email address/header parsing into RT::EmailParser and
then fix the problem in a single place.
diff --git a/lib/RT/EmailParser.pm b/lib/RT/EmailParser.pm
index 4cf4184..865e4da 100644
--- a/lib/RT/EmailParser.pm
+++ b/lib/RT/EmailParser.pm
@@ -548,10 +548,38 @@ sub ParseEmailAddress {
@addresses = Email::Address->parse($address_string);
}
+ $self->CleanupAddresses(@addresses);
+
return @addresses;
}
+=head2 CleanupAddresses ARRAY
+
+Massages an array of L<Email::Address> objects to make their email addresses
+more palatable.
+
+Currently this strips off surrounding single quotes around C<< ->address >> and
+B<< modifies the L<Email::Address> objects in-place >>.
+
+Returns the list of objects for convienence in C<map>/C<grep> chains.
+
+=cut
+
+sub CleanupAddresses {
+ my $self = shift;
+
+ for my $addr (@_) {
+ next unless defined $addr;
+ # Outlook sometimes sends addresses surrounded by single quotes;
+ # clean them all up
+ if ((my $email = $addr->address) =~ s/^'(.+)'$/$1/) {
+ $addr->address($email);
+ }
+ }
+ return @_;
+}
+
=head2 RescueOutlook
Outlook 2007/2010 have a bug when you write an email with the html format.
diff --git a/lib/RT/Interface/Email.pm b/lib/RT/Interface/Email.pm
index 909a9f4..f077749 100644
--- a/lib/RT/Interface/Email.pm
+++ b/lib/RT/Interface/Email.pm
@@ -1055,7 +1055,7 @@ sub ParseCcAddressesFromHead {
return
grep $_ ne $current_address && !RT::EmailParser->IsRTAddress( $_ ),
map lc $user->CanonicalizeEmailAddress( $_->address ),
- map Email::Address->parse( $args{'Head'}->get( $_ ) ),
+ map RT::EmailParser->CleanupAddresses( Email::Address->parse( $args{'Head'}->get( $_ ) ) ),
qw(To Cc);
}
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list