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

by WorldofBB, Tuesday, February 04, 2020, 23:39 (1504 days ago) @ WorldofBB
edited by WorldofBB, Wednesday, February 05, 2020, 00:16

Quick follow-up:

Keeping in mind that my knowledge of php is VERY limited, I looked into this a little further and the problem appears to be the migration from PCRE to PCRE2 in php 7.3

According to the changelog for version 10.33 of PCRE2

https://www.pcre.org/changelog.txt

26. With PCRE2_EXTRA_BAD_ESCAPE_IS_LITERAL set, escape sequences such as \s
which are valid in character classes, but not as the end of ranges, were being
treated as literals. An example is [_-\s] (but not [\s-_] because that gave an
error at the *start* of a range). Now an "invalid range" error is given
independently of PCRE2_EXTRA_BAD_ESCAPE_IS_LITERAL.

27. Related to 26 above, PCRE2_BAD_ESCAPE_IS_LITERAL was affecting known escape
sequences such as \eX when they appeared invalidly in a character class. Now
the option applies only to unrecognized or malformed escape sequences.

With php 7.3 - PCRE2_EXTRA_BAD_ESCAPE_IS_LITERAL is set to false.

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.

https://wiki.php.net/rfc/pcre2-migration#backward_incompatible_changes

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)) {


Complete thread:

 RSS Feed of thread