Bug #77923 [Com]: preg_* function cannot get correct result
| From: | 2317216477 at qq dot com | Date: | Mon, 22 Apr 2019 01:56:51 +0000 |
| Subject: | Bug #77923 [Com]: preg_* function cannot get correct result | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-220557@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=77923&edit=1
ID: 77923
Comment by: 2317216477 at qq dot com
Reported by: 2317216477 at qq dot com
Summary: preg_* function cannot get correct result
Status: Not a bug
Type: Bug
Package: PCRE related
Operating System: any
PHP Version: 7.2.18RC1
Block user comment: N
Private report: N
New Comment:
I checked https://www.php.net/manual/zh/pcre.constants.php
and I found Robertï¼a user added a noteï¼said the same problem, I think it's still a
problem for php7.0 to 7.2, for example,
this is my regular func:
preg_f()
and this is my pseudo code:
preg_f()
error = preg_last_error()
if(error){
preg_f()
}
Only if I re-match can I get the correct result, I think it is not reasonable because the
logic:"I don't know I will be right or not until I checked preg_last_error()", that
is ... I don't know, maybe stupid.
Maybe php7.0 to 7.2 should handle it itself, or just throw a fatal error so a user know the
expression is correct or not in a certain way directly!
In a word, it returns a different result with php5 or php7.3+, it makes me puzzled
Previous Comments:
------------------------------------------------------------------------
[2019-04-20 05:52:07] requinix@php.net
Your regular expression is too inefficient to be used with JIT mode on such a large input. PCRE (not
PHP) is aborting executing because it ran out of stack space - preg_last_error() =
PREG_JIT_STACKLIMIT_ERROR (6).
Disabling JIT for that regex is a workaround. Fixing the regex is better.
But personally I would consider using SimpleXML to find the <w:p> elements, scan for your
${var} or ${/var} tokens, then... I don't know what you want to do from there.
------------------------------------------------------------------------
[2019-04-19 11:33:48] 2317216477 at qq dot com
You can use "ini_set" and set "pcre.jit" to 0 before preg_* functions to fix the
problem
I don't know why it happens and hope someone can fix it basically
------------------------------------------------------------------------
[2019-04-19 11:23:20] 2317216477 at qq dot com
Description:
------------
preg_* function cannot get correct result in php7.0~7.2 sometimes
the test string is too long so I put a test script on my github
page(https://github.com/icy2003/php/blob/master/samples/php7preg_bug.php)
you can test this script on this website:https://3v4l.org/,or you
can install php 7.0~7.2 in local environment
Test script:
---------------
https://github.com/icy2003/php/blob/master/samples/php7preg_bug.php
Expected result:
----------------
my pattern expected some results but in php7.0~7.2 it will be empty array!!
you can use "ini_set" and set "pcre.jit" to 0 before preg_* functions to fix the
problem
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=77923&edit=1