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

From: Date: Wed, 14 Feb 2018 16:24:02 +0000
Subject: Bug #74183 [Ver->Csd]: preg_last_error not returning error code after error
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-213955@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:             Verified
+Status:             Closed
 Type:               Bug
 Package:            *Regular Expressions
 Operating System:   Ubuntu
 PHP Version:        5.6.30
-Assigned To:        
+Assigned To:        cmb
 Block user comment: N
 Private report:     N

 New Comment:

This issue has already been fixed (see comment above).


Previous Comments:
------------------------------------------------------------------------
[2017-11-21 19:28:11] ab@php.net

Automatic comment on behalf of andrew.nester.dev@gmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=8fdef981ef940dfc2f1b21cfa3f227150472ad2d
Log: Fixed #75539 and #74183 - preg_last_error not returning error code after error

------------------------------------------------------------------------
[2017-11-21 11:44:31] andrew dot nester dot dev at gmail dot com

Thanks for reporting this issue! I've just added PR fixing this.

------------------------------------------------------------------------
[2017-03-10 18:29:10] cmb@php.net

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>.

------------------------------------------------------------------------
[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


Thread (5 messages)

« previous php.bugs (#213955) next »