Avatar

Cannot register, always get: The e-mail address is invalid (General)

by Auge ⌂ @, Wednesday, February 05, 2020, 10:16 (14 days ago) @ WorldofBB

Hello

So as of php 7.3, PCRE2 is more strict in pattern validations. So hyphens now need to be escaped or put at the beginning or the end of a character class.

After running a quick test, it would seem that escaping the hyphen does seem to resolve the problem in php 7.3. Replacing line 393 in functions.inc.php with the following code appears to resolve the issue as well:

if (!preg_match("/^([\w\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,}|[0-9]{1,3})(\]?)$/", $email)) {

I've two questions about it (I myself have problems with understandig of regular expressions).

1. The syntax checks are more strict with PRCE2 which was introduced with PHP 7.3. Is it possible that the more strict syntax rules break the code in older PHP versions (up to 7.2.x) that use PRCE1?

"/^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,}|[0-9]{1,3})(\]?)$/"
"/^([\w\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,}|[0-9]{1,3})(\]?)$/"

2. In the first block (([\w-\.]+) versus ([\w\-\.]+)) you masked the hyphen (-) with a backslash. In the block for the domain name the hyphen got not masked only because it is at the end of the rule ((([\w-]+\.)+)); for this see your sentence: "So hyphens now need to be escaped or put at the beginning or the end of a character class.")?

Thank you again for your investigations.

Tschö, Auge

--
Trenne niemals Müll, denn er hat nur eine Silbe!


Complete thread:

 RSS Feed of thread

powered by my little forum