php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #39279 mb_ereg_replace() has an error
Submitted: 2006-10-27 13:36 UTC Modified: 2009-05-20 01:00 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: ivb at is dot ua Assigned: masugata (profile)
Status: No Feedback Package: mbstring related
PHP Version: 5CVS-2008-10-31 (CVS) OS: *
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2006-10-27 13:36 UTC] ivb at is dot ua
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}


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-12-27 04:59 UTC] masugata@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5.2-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5.2-win32-latest.zip

I have tried Reproduce code in snapshot.
But, did not become the result of your report.

Could you confirm it again?

Thank you.

 [2006-12-27 06:13 UTC] ivb at is dot ua
Yes, I confirm that bug exists and I can reproduce it. I download latest snapshot and take my example from this report. The result still "{abc..def}{ab\1...\2ef}" instead of "{abc..def}{abc...def}".

If you need any my assistance (my php.ini f.e.) please feel free to contact with me by my e-mail.
 [2007-01-22 10:20 UTC] masugata@php.net
Oh! This is a big help.
Give me, your php.ini and program.
Please send to 'masugata@php.net'.

Thank You.

 [2007-01-22 11:42 UTC] ivb at is dot ua
feedback sent via e-mail
 [2008-10-31 14:45 UTC] jani@php.net
3rd anniversary gift to mr. Masugata: You got feedback. What's the status with this now?
 [2009-05-12 02:16 UTC] jani@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5.2-latest.tar.gz
 
For Windows:

  http://windows.php.net/snapshots/


 [2009-05-20 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Mar 19 08:01:29 2024 UTC