Ticket #5169 (closed defect: fixed)

Opened 9 months ago

Last modified 9 months ago

Posting from email addresses with "hyphen" cannot be assigned to the user

Reported by: giannis1 Assigned to: anonymous
Priority: high Milestone: 2.3.1
Component: General Version: 2.3
Severity: normal Keywords: has-patch tested
Cc:

Description

I am trying to post a message via email and HTML form to my Wordpress... and it doesn't assign the post to the user when the email address includes "hyphen"...when user's email address is without "hyphen" is assign perfectly the post to the User.

For example:

When a user@testing.com submit a post via an external HTML form or by email, the post is assigned to the user. However, when user@test-ing.com submit, it assigns the post to the admin.

Please help!

Thanks

John

Attachments

wp-mail.php.diff (0.7 kB) - added by markjaquith on 10/09/07 05:10:38.
wp-mail.php.2.diff (0.7 kB) - added by markjaquith on 10/09/07 17:43:48.
Using sanitize_email() and is_email()
wp-mail.php.3.diff (0.8 kB) - added by Bobcat on 10/12/07 11:28:33.
Isolates email addr before sanitizing (fixed typo in comment)

Change History

10/09/07 05:10:38 changed by markjaquith

  • attachment wp-mail.php.diff added.

10/09/07 05:11:55 changed by markjaquith

  • version set to 2.3.
  • milestone set to 2.4.

giannis1, try the patch I uploaded.

10/09/07 07:33:02 changed by westi

-1 to current patch.

Should we not use is_email and sanitize_email here - that way we have one rule for sanitizing all email addresses.

10/09/07 17:43:48 changed by markjaquith

  • attachment wp-mail.php.2.diff added.

Using sanitize_email() and is_email()

10/09/07 17:44:25 changed by markjaquith

  • keywords set to has-patch 2nd-opinion.

Patch updated with Westi's suggestions.

10/09/07 18:45:12 changed by westi

  • keywords changed from has-patch 2nd-opinion to has-patch dev-reviewed.

+1

New patch looks good to me.

10/09/07 22:15:37 changed by markjaquith

  • status changed from new to closed.
  • resolution set to fixed.

(In [6212]) Properly sanitize e-mail addresses in wp-mail.php. Props giannis1. fixes #5169 for trunk

10/10/07 10:07:41 changed by Bobcat

  • status changed from closed to reopened.
  • resolution deleted.

This patch doesn't work. All emails get posted by 'admin'. The problem is that sanitize_email returns "FromUserNameaddr@domain.com" when the rest of the code expects simply "addr@domain.com" for looking-up the email address.

10/10/07 16:46:21 changed by markjaquith

  • status changed from reopened to closed.
  • resolution set to fixed.

(In [6217]) Strip From/Reply-To from e-mail before sanitizing in wp-mail.php. Props Bobcat. fixes #5169

10/10/07 18:09:53 changed by Bobcat

  • status changed from closed to reopened.
  • resolution deleted.

Nope, still doesn't work. It leaves the user name part of the From line; the part in quotes. e.g.: From line is:

From: "User Name" <addr@domain.com>

But your code sets $author to:

UserNameaddr@domain.com

When the rest of the code needs:

addr@domain.com

The easiest thing to do might be to use the regexp from your first patch to isolate the addr@domain.com part, then call sanitize_email and is_email.

10/12/07 02:19:55 changed by Bobcat

  • keywords changed from has-patch dev-reviewed to has-patch 2nd-opinion.

This patch (wp-mail.php.3.diff) isolates the email address before sending it to sanitize_email and is_email. I also improved the regexp to ignore strings that look like an email address if it's followed by a string in angle brackets (the string in angle brackets is the real email address); handles the case where a quoted string contains an "@" but isn't the real email address. I hope that makes sense.

10/12/07 11:28:33 changed by Bobcat

  • attachment wp-mail.php.3.diff added.

Isolates email addr before sanitizing (fixed typo in comment)

10/18/07 05:14:53 changed by ryan

See the regular expression for matching email addresses and weep.

http://trac.wordpress.org/attachment/ticket/4616/4616b.diff

10/18/07 05:35:01 changed by ryan

So let's see how the proposed patch for #4616 applies here, think about bumping the logic into a function like extract_email_address(), and maybe see if there's some squirrelmail code we can steal.

10/18/07 20:32:52 changed by ryan

Alright, Bobcat's patch looks like a good fix for now and we can explore the bigger issues later.

10/19/07 09:38:24 changed by Bobcat

  • keywords changed from has-patch 2nd-opinion to has-patch tested.
  • milestone changed from 2.4 to 2.3.1.

Thank you. Patch tested with WP 2.3 by sending emails from addresses with and without hyphens in the email address.

10/21/07 06:18:09 changed by ryan

  • status changed from reopened to closed.
  • resolution set to fixed.

(In [6280]) Allow hypens in email addresses. Props Bobcat. fixes #5169 for 2.3

10/21/07 06:18:59 changed by ryan

(In [6281]) Fix email address parsing in wp-mail.php. Props Bobcat. fixes #5169