#39279 [NEW]: mb_ereg_replace() has an error
| From: | ivb at is dot ua | Date: | Fri, 27 Oct 2006 13:36:17 +0000 |
| Subject: | #39279 [NEW]: mb_ereg_replace() has an error | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-104071@lists.php.net to get a copy of this message | ||
From: ivb at is dot ua
Operating system: Windows 2000 SP4
PHP version: 5CVS-2006-10-27 (CVS)
PHP Bug Type: mbstring related
Bug description: mb_ereg_replace() has an error
Description:
------------
mb_ereg_replace() works incorrectly if 2nd parameter is multibyte and
contains substings \\n (n - digit). It returns substing \n itself instead
of corresponding parenthesized substring.
If 2nd parameter not multibyte - \\n correctly replaced with corresponding
parenthesized substrings.
If 2nd parameter multibyte, but not contains \\n substrings - replacement
works correctly.
Reproduce code:
---------------
<?php
function a2u ( $a ) {
return mb_convert_encoding ( $a, "UTF-16LE", "ASCII" );
}
function u2a ( $a ) {
return mb_convert_encoding ( $a, "ASCII", "UTF-16LE" );
}
mb_internal_encoding ( "UTF-16LE" );
mb_regex_encoding ( "UTF-16LE" );
$str = "abc..def";
$pat = "([^\.])\.\.([^\.])";
$rep = "\\1...\\2";
$res = mb_ereg_replace ( a2u ( $pat ), a2u ( $rep ), a2u ( $str ) );
echo "{" . $str . "}{" . u2a ( $res ) . "}\n";
?>
Expected result:
----------------
{abc..def}{abc...def}
Actual result:
--------------
{abc..def}{ab\1...\2ef}
--
Edit bug report at http://bugs.php.net/?id=39279&edit=1
--
Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=39279&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=39279&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=39279&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=39279&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=39279&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=39279&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=39279&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=39279&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=39279&r=support
Expected behavior: http://bugs.php.net/fix.php?id=39279&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=39279&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=39279&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=39279&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=39279&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=39279&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=39279&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=39279&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=39279&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=39279&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=39279&r=mysqlcfg