Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
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
Comment #1
quicksketchAn 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.
Comment #2
quicksketchThis was fixed in #650434: Remove white space from email fields