markov2 / perl5-Mail-Message

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

Regex too greedy on multiple encoded names in comma separated list #5

Closed Knyffen closed 2 years ago

Knyffen commented 2 years ago

Hello

When a comma separated list contains multiple names are encoded, the consumePhrase function in Mail::Message::Field::Full contains a greedy regex that spans across multiple email addresses. An example is "=?utf-8?q?foo?= bar@mail.com, =?utf-8?q?baz?= qux@mail.com" where consumePhrase greedily selects the entirety of "=?utf-8?q?foo?= bar@mail.com, =?utf-8?q?baz?=" as the phrase.

I believe that the issue can be fixed by replacing elsif($string =~ s/^\s*((?:\=\?.*\?\=|[${atext}${atext_ill}\ \t.])+)//o ) with elsif($string =~ s/^\s*((?:\=\?.*?\?\=|[${atext}${atext_ill}\ \t.])+)//o ) on https://github.com/markov2/perl5-Mail-Message/blob/a49dad0509c16db0539fdeb8d80be8c048b2a50b/lib/Mail/Message/Field/Full.pm#L643 to make it non-greedy.

Best regards Jonas

markov2 commented 2 years ago

I do agree that adding the '?' is needed. Thank you, Jonas!

The fix is on github. Usually, I create new releases when I have collected a few.

Knyffen commented 2 years ago

Great! Thank you for the quick response! Have a nice day :-)

Knyffen commented 2 years ago

Oh, and my name is Jonas Ryssel. Knyffen is my alias on the internet, but either is fine. Sorry for the confusion (I didn't expect to get my name in there). :-)