Bug #60903 [Opn->Nab]: preg_match + operator fails with string exceeding length 18
| From: | felipe@php.net | Date: | Fri, 27 Jan 2012 20:54:10 +0000 |
| Subject: | Bug #60903 [Opn->Nab]: preg_match + operator fails with string exceeding length 18 | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-166871@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=60903&edit=1
ID: 60903
Updated by: felipe@php.net
Reported by: gohanman at gmail dot com
Summary: preg_match + operator fails with string exceeding
length 18
-Status: Open
+Status: Not a bug
Type: Bug
-Package: Regexps related
+Package: PCRE related
Operating System: Ubuntu
PHP Version: 5.3.9
Block user comment: N
Private report: N
New Comment:
Are you really using 5.3.9 with the built-in PCRE library?
Your test case works just fine here.
If it returns false, you can check preg_last_error() and adjust the INI configuration accordingly.
About crashing, it's known behavior from PCRE library, take a look at the PCRE documentation
for more information.
Previous Comments:
------------------------------------------------------------------------
[2012-01-27 15:50:53] gohanman at gmail dot com
Description:
------------
I'm trying to validate email addresses via regular expression. My regular expression fails if
the first domain portion is longer than 18 characters. Overall string length does not seem relevant.
Decreasing the length of the user portion or TLD does not make a 19+ character domain portion work.
Test script:
---------------
function is_email($str){
if(preg_match("/^[_a-z0-9-]+(.[_a-z0-9-]+)*@[a-z0-9-]+(.[a-z0-9-]+)*(.[a-z]{2,4})$/i",
$str))
return True;
return False;
}
var_dump(is_email("user@123456789012345678.com"));
var_dump(is_email("user@1234567890123456789.com"));
Expected result:
----------------
bool(true);
bool(true);
Actual result:
--------------
bool(true);
bool(false);
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=60903&edit=1