Bug #74183 [Opn->Ver]: preg_last_error not returning error code after error

From: Date: Fri, 10 Mar 2017 18:29:14 +0000
Subject: Bug #74183 [Opn->Ver]: preg_last_error not returning error code after error
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-207775@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=74183&edit=1 ID: 74183 Updated by: cmb@php.net Reported by: velazcomtz dot miguel at gmail dot com Summary: preg_last_error not returning error code after error -Status: Open +Status: Verified Type: Bug Package: *Regular Expressions Operating System: Ubuntu PHP Version: 5.6.30 Block user comment: N Private report: N New Comment: Confirmed: <https://3v4l.org/1eUf6>. Seems there is PCRE_G(error_code) = PHP_PCRE_INTERNAL_ERROR; missing around <https://github.com/php/php-src/blob/PHP-7.1.2/ext/pcre/php_pcre.c#L499>. Previous Comments: ------------------------------------------------------------------------ [2017-02-28 17:48:00] velazcomtz dot miguel at gmail dot com Description: ------------ --- From manual page: http://www.php.net/function.preg-last-error --- There are cases where preg_match returns false and preg_last_error returns 0 but, when you check the error.log file there is an error: PHP message: PHP Warning: preg_match(): Compilation failed: regular expression is too large at offset 128 Just as a reminder: this bug was detected and fixed previously here: https://bugs.php.net/bug.php?id=52732&edit=2 Test script: --------------- $sRegex = "/([A-Z]|[a-z]|[0-9]| |Ñ|ñ|!|&quot;|%|&amp;|'|´|-|:|;|>|=|&lt;|@|_|,|\{|\}|`|~|á|é|í|ó|ú|Á|É|Í|Ó|Ú|ü|Ü){1,300}/"; $sTest = "Hello world"; var_dump(preg_match($sRegex, $sTest)); // returns false var_dump(preg_last_error()); // returns 0 ------------------------------------------------------------------------ [2017-02-28 17:46:25] velazcomtz dot miguel at gmail dot com Description: ------------ --- From manual page: http://www.php.net/function.preg-last-error --- There are cases where preg_match returns false and preg_last_error returns 0 but, when you check the error.log file there is an error: PHP message: PHP Warning: preg_match(): Compilation failed: regular expression is too large at offset 128 Just as a reminder: this bug was detected and fixed previously here: https://bugs.php.net/bug.php?id=52732&edit=2 Test script: --------------- $sRegex = "/([A-Z]|[a-z]|[0-9]| |Ñ|ñ|!|&quot;|%|&amp;|'|´|-|:|;|>|=|&lt;|@|_|,|\{|\}|`|~|á|é|í|ó|ú|Á|É|Í|Ó|Ú|ü|Ü){1,300}/"; $sTest = "Hello world"; var_dump(preg_match($sRegex, $sTextoPrueba)); // returns false var_dump(preg_last_error()); // returns 0 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=74183&edit=1

« previous php.bugs (#207775) next »