Bug #74183 [Com]: preg_last_error not returning error code after error

From: Date: Tue, 21 Nov 2017 11:44:33 +0000
Subject: Bug #74183 [Com]: preg_last_error not returning error code after error
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-212657@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
 Comment by:         andrew dot nester dot dev at gmail dot com
 Reported by:        velazcomtz dot miguel at gmail dot com
 Summary:            preg_last_error not returning error code after error
 Status:             Verified
 Type:               Bug
 Package:            *Regular Expressions
 Operating System:   Ubuntu
 PHP Version:        5.6.30
 Block user comment: N
 Private report:     N

 New Comment:

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


Previous Comments:
------------------------------------------------------------------------
[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 (#212657) next »