php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #43227 eregi() mbregex compile err: premature end of regular expression in
Submitted: 2007-11-09 16:03 UTC Modified: 2009-08-07 09:37 UTC
Votes:18
Avg. Score:4.6 ± 0.7
Reproduced:12 of 12 (100.0%)
Same Version:8 (66.7%)
Same OS:6 (50.0%)
From: baco at infomaniak dot ch Assigned: hirokawa (profile)
Status: Closed Package: mbstring related
PHP Version: 5.2.5 OS: Linux Debian
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: baco at infomaniak dot ch
New email:
PHP Version: OS:

 

 [2007-11-09 16:03 UTC] baco at infomaniak dot ch
Description:
------------
eregi() produce random errors like "function.mb-eregi: mbregex compile err: premature end of regular expression in" when used with special chars like accents.

N.B. On the web you can found a lot of reports of this issue. Some post suggests forcing mbstring.func_overload = 0 but it doesn't work for me.

If Apache1 is restarted the error doesn't come anymore before an amount of time and request.

$ GET http://localhost/test.php
ok

$ GET http://localhost/test.php
ok

$ GET http://localhost/test.php
<br />
<b>Warning</b>:  mb_eregi() [<a
href='function.mb-eregi'>function.mb-eregi</a>]: mbregex compile err:
premature end of regular expression in
<b>/home/www/ca8b72beb934995c1afb34e1a3ceb893/web/test.php</b> on line
<b>2</b><br />

$ GET http://localhost/test.php
<br />
<b>Warning</b>:  mb_eregi() [<a
href='function.mb-eregi'>function.mb-eregi</a>]: mbregex compile err:
premature end of regular expression in
<b>/home/www/ca8b72beb934995c1afb34e1a3ceb893/web/test.php</b> on line
<b>2</b><br />

$ GET http://localhost/test.php
<br />
<b>Warning</b>:  mb_eregi() [<a
href='function.mb-eregi'>function.mb-eregi</a>]: mbregex compile err:
premature end of regular expression in
<b>/home/www/ca8b72beb934995c1afb34e1a3ceb893/web/test.php</b> on line
<b>2</b><br />

$ GET http://localhost/test.php
ok

$ GET http://localhost/test.php
ok

...


Reproduce code:
---------------
<?php
    if (eregi("cit?", "electricit?")) {
        echo "ok\n";
    }
?>

Expected result:
----------------
OK

Actual result:
--------------
<br />
<b>Warning</b>:  mb_eregi() [<a
href='function.mb-eregi'>function.mb-eregi</a>]: mbregex compile err:
premature end of regular expression in
<b>/home/www/ca8b72beb934995c1afb34e1a3ceb893/web/test.php</b> on line
<b>2</b><br />

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-02-25 13:18 UTC] lip at lip dot net dot ua
I think these bugs are similar.
http://bugs.php.net/bug.php?id=44237
 [2008-02-25 13:31 UTC] baco at infomaniak dot ch
As workaround try to force mbstring.func_overload = 0 in your php.ini
and use this patch.

PHP5

unix_mbstring_func_overload.patch
--- ext/mbstring/mbstring.c     2007-09-24 13:51:36.000000000 +0200
+++ ext/mbstring/mbstring.c     2007-12-04 18:00:10.023564681 +0100
@@ -765,8 +765,8 @@
         PHP_INI_ENTRY("mbstring.script_encoding", NULL, PHP_INI_ALL, 
OnUpdate_mbstring_script_encoding)
 #endif /* ZEND_MULTIBYTE */
         PHP_INI_ENTRY("mbstring.substitute_character", NULL, 
PHP_INI_ALL, OnUpdate_mbstring_substitute_character)
-        STD_PHP_INI_ENTRY("mbstring.func_overload", "0", 
PHP_INI_SYSTEM |
-        PHP_INI_PERDIR, OnUpdateLong, func_overload, 
zend_mbstring_globals, mbstring_globals)
+        STD_PHP_INI_ENTRY("mbstring.func_overload", "0",
+        PHP_INI_SYSTEM, OnUpdateLong, func_overload, 
zend_mbstring_globals, mbstring_globals)

         STD_PHP_INI_BOOLEAN("mbstring.encoding_translation", "0",
         PHP_INI_SYSTEM | PHP_INI_PERDIR, 
OnUpdate_mbstring_encoding_translation,

PHP4

--- ext/mbstring/mbstring.c     2007-04-04 17:28:18.000000000 +0200
+++ ext/mbstring/mbstring.c     2007-12-04 18:05:29.363559316 +0100
@@ -815,8 +815,8 @@
         PHP_INI_ENTRY("mbstring.script_encoding", NULL, PHP_INI_ALL, 
OnUpdate_mbstring_script_encoding)
 #endif /* ZEND_MULTIBYTE */
         PHP_INI_ENTRY("mbstring.substitute_character", NULL, 
PHP_INI_ALL, OnUpdate_mbstring_substitute_character)
-        STD_PHP_INI_ENTRY("mbstring.func_overload", "0", 
PHP_INI_SYSTEM |
-        PHP_INI_PERDIR, OnUpdateInt, func_overload, 
zend_mbstring_globals, mbstring_globals)
+        STD_PHP_INI_ENTRY("mbstring.func_overload", "0",
+        PHP_INI_SYSTEM, OnUpdateInt, func_overload, 
zend_mbstring_globals, mbstring_globals)

         STD_PHP_INI_BOOLEAN("mbstring.encoding_translation", "0",
         PHP_INI_SYSTEM | PHP_INI_PERDIR, 
OnUpdate_mbstring_encoding_translation,
 [2008-07-11 21:32 UTC] jani@php.net
Assigned to mbstring maintainer.
 [2009-08-07 09:37 UTC] jani@php.net
This was fixed.
 [2009-09-11 06:08 UTC] svn@php.net
Automatic comment from SVN on behalf of torben
Revision: http://svn.php.net/viewvc/?view=revision&revision=288256
Log: Note that mbstring.func_overload is once again PHP_INI_SYSTEM only.
Addresses bugs #49238, #43227, and #49189.

This really should have been mentioned in the release notes for 5.2.7
and 5.3.0.
 [2011-01-16 14:27 UTC] ciprianmp at yahoo dot com
How was this solved?
I have clients encountering this similar issue on 5.2.12 either. So what the 
actual fix should be?
Hosting teams won't look up this error in order to apply the fixes. They ask for 
the exact "what to do" from the customer report. So what can we request to be 
done, especially on shared servers?
Thank you.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Nov 24 02:01:28 2024 UTC