The email component function _webform_validate_email() calls the core function valid_email_address() to validate the email address. However, neither function trims the email before validation so if whitespaces occur at the beginning or end of the email address then validation will fail.

Replacing the line:

  if (!empty($form_element['#value']) && !valid_email_address($form_element['#value'])) { 

with:

  if (!empty($form_element['#value']) && !valid_email_address(trim($form_element['#value']))) { 

fixes the problem and is the approach taken by other modules (e.g., the CCK Email module) to resolve the problem.

Comments

quicksketch’s picture

Category: bug » feature

An e-mail address with spaces *isn't* a valid e-mail address though. Rather than than allowing it to pass through validation with spaces, a better approach would be to trim the actual value, not just allow it to pass through validation.

quicksketch’s picture

Status: Active » Closed (duplicate)