Hi,
I'm currently using Mail::Sender to deliver mail to certain workpools of users in our system. I noticed something fishy when we started receiving bounces on a user's address that contained a single quote in the last name, e.g.
jane.o'doe@domain.com.
The actuall address that is used when sending (after passing through the Mail::Sender internals) comes out like so,
doe@domain.com
I found the code responsible:
sub _prepare_addresses {
my ($self, $type) = @_;
if (ref $self->{$type}) {
$self->{$type.'_list'} = $self->{$type};
$self->{$type} = join ', ', @{$self->{$type.'_list'}};
} else {
$self->{$type} =~ s/\s+/ /g;
$self->{$type} =~ s/, ?,/,/g;
$self->{$type.'_list'} = [map {s/\s+$//;$_} $self->{$type} =~ /((?
+:[^"',]+|"[^"]*"|'[^']*')+)(?:,\s*|\s*$)/g];
}
}
Regexs are not my strong point in perl, however I can see that the problem comes from the first class in the first regex group, i.e.
[^"',]. What I am wondering is there a better way to handle the parsing of $self->{'to'}? Doing a split on "," then cleaning up trailing white space and boundary single and double quote characters.
I did a fair bit of googling and was surprised this has not come up before.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.