Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
Knyffen opened this issue Jun 8, 2022 · 3 comments
Closed
Labels
bug Something isn't working

Comments

@Knyffen
Copy link

Knyffen commented Jun 8, 2022

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

elsif($string =~ s/^\s*((?:\=\?.*\?\=|[${atext}${atext_ill}\ \t.])+)//o )
to make it non-greedy.

Best regards
Jonas

@markov2
Copy link
Owner

markov2 commented Jun 8, 2022

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.

@markov2 markov2 added the bug Something isn't working label Jun 8, 2022
@Knyffen
Copy link
Author

Knyffen commented Jun 8, 2022

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

@Knyffen Knyffen closed this as completed Jun 8, 2022
@Knyffen
Copy link
Author

Knyffen commented Jun 8, 2022

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). :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants