Special Characters in Email Addresses?

robdog

Well-known member
Affected version
2.x
Not sure if this is a bug report, but I have users, for some reason, that want a single quote in their email address. Is this not allowed within XenForo? Should it be allowed? (possible bug?) Or is this an enhancement request?
 
This may be a bug in the email validation library that we use and I have opened an issue to address it.

Under RFC5322 and other validators I have tried, it should work fine:

 
@Chris D, this isn't a bug in that library--the demo email you provided works fine, and I can't repro it with their code.

The issue is in XF's \XF\Validator\Email.php:
PHP:
		if (preg_match('/["\'\s\\\\]/', $value))
		{
			// intentionally reject some odd (though technically valid) emails
			$errorKey = 'invalid';
			return false;
		}
 
I’ll have another go but I explicitly tried it in that library and it failed. Admittedly I didn’t read further but that’s the point the code was stopping for me.
 
Of course I've tried it again and now it works so that's cool 🙃

EDIT: Ah...

Well, we trigger the email validation twice. I think the first one is checking if the username is a valid email address as that's not something we allow. That was failing, but my test didn't go far enough to see where the real email check was failing.
 
Potentially though it was added due to security concerns.

It may depend whether the library we use for sending mail mitigates these concerns sufficiently.
 
Back
Top Bottom