[wp-trac] [WordPress Trac] #17305: wp_mail() does not accommodate address format "Name <address at tld.com>"
WordPress Trac
wp-trac at lists.automattic.com
Sat Jun 25 14:53:31 UTC 2011
#17305: wp_mail() does not accommodate address format "Name <address at tld.com>"
-----------------------------------+---------------------
Reporter: dllh | Owner: westi
Type: defect (bug) | Status: closed
Priority: normal | Milestone: 3.2
Component: Mail | Version: 3.2
Severity: normal | Resolution: fixed
Keywords: has-patch needs-codex |
-----------------------------------+---------------------
Changes (by kitchin):
* cc: kitchin (added)
* keywords: has-patch => has-patch needs-codex
Comment:
I am adding "needs-codex" so users can see the new feature.
This landed patch works, but could have been better. The regex has a part
which does not work. The problem is fixed later in AddAnAddress(), so
there is no real bug.
Details: The "\s?" in the regex does nothing, due to the greedy "+"
beforehand (minor exception below). In the typical case, "Foo
<bar at baz.com>", the $recipient_name is right-padded: 'Foo ' instead of
'Foo'.
The string is trimmed later, after $phpmailer->AddAddress(), or AddCc(),
or AddBcc(), call AddAnAddress(), which trims both the address and the
name.
Several fixes are possible for this bad looking code, with no change in
behavior. The best is to simplify the regexes to '/(.+)<(.+)>/' and call
trim() in both arguments (or neither):
$phpmailer->AddAddress( trim($recipient), $recipient_name );
...AddCc...
...AddBcc...
That has no change in behavior.
An ENHANCEMENT would be to allow "<bar at baz.com>" by making the regexes:
'/(.*)<(.+)>/'.
Minor exception above: the "\s?" in the regex will catch a single "\n".
But that is not a documented feature of wp_mail().
--
Ticket URL: <http://core.trac.wordpress.org/ticket/17305#comment:11>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list