markov2 / perl5-Mail-Message

Processing MIME messages
http://perl.overmeer.net/CPAN
1 stars 1 forks source link

Parsing a Mail::Address includes quotes in phrase #4

Closed abeverley closed 2 years ago

abeverley commented 2 years ago

When using Mail::Message::Field::Address to parse email addresses, if the email address is a string then the parsed value does not include quotes, but when parsing the same string as a Mail::Address object it includes the quotes.

my $e = '"John Smith" <john@example.com>';

my $msg = Mail::Message->build(
    To      => 'me@example.com',
    From    => $e,
    Subject => "My subject",
    data    => "My body",
);

my ($from_orig) = $msg->from;

# Parse Mail::Address
my $from = Mail::Message::Field::Address->parse($from_orig);
print $from->phrase; # Includes quotes

# Parse string
$from = Mail::Message::Field::Address->parse($e);
print $from->phrase; # Does not include quotes
markov2 commented 2 years ago

The coercion from Mail::Address into a Mail::Message::Full::Address in Mail::Internet::coerce(), part of module User-Identity, trusted Mail::Address for its parsing... which is certainly underserved. Patch https://github.com/markov2/perl5-User-Identity/commit/0a67a7b881dc426b6f7abe8735e540dc206c44b2

abeverley commented 2 years ago

Thanks for the really quick responses Mark, I think that's it for now :)

Any chance of a CPAN release please?

markov2 commented 2 years ago

This problem was a bit harder to find than the other reports. Yes, when you improve the code so much, with your good reports, you deserve a rapid release ;-)

abeverley commented 2 years ago

Great, thanks!

markov2 commented 2 years ago

Released User-Identity 1.01 and Mail-Message 3.012