zend-mail icon indicating copy to clipboard operation
zend-mail copied to clipboard

Problems with mailadress parsing

Open Baztey opened this issue 8 years ago • 2 comments

Example Email-header: "Foo <bar" [email protected]

Description: The example email-header should be valid according to https://tools.ietf.org/html/rfc2822#section-3.4 but the function AdressList.php/addFromString matches it incorrect. The result has the following form: "bar <[email protected]" This is clearly not a valid adress and therefore causes exceptions in the following code

Solution: Changing the regex in the addFromString function from lazzy to greedy by removing "?" from the named capture group "name"

  • old: ^((?P.*?)<(?P[^>]+)>|(?P.+))$
  • new: ^((?P.*)<(?P[^>]+)>|(?P.+))$

Baztey avatar Dec 21 '16 14:12 Baztey

@Baztey created PR based on your comments, including tests: https://github.com/zendframework/zend-mail/pull/143

however, it needs more fixes, because encoding back creates invalid result.

btw, your bugreport here has lost <>, use markdown code blocks to preserve them.

glensc avatar May 14 '17 13:05 glensc

This repository has been closed and moved to laminas/laminas-mail; a new issue has been opened at https://github.com/laminas/laminas-mail/issues/45.

michalbundyra avatar Jan 15 '20 19:01 michalbundyra