php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #77428 mb_ereg_replace() doesn't replace a substitution variable
Submitted: 2019-01-08 01:47 UTC Modified: 2019-01-08 09:09 UTC
From: shin1x1 at gmail dot com Assigned:
Status: Closed Package: mbstring related
PHP Version: 7.3.0 OS:
Private report: No CVE-ID: None
 [2019-01-08 01:47 UTC] shin1x1 at gmail dot com
Description:
------------
The substitution variable of mb_ereg_replace() is not working when a substitution variable is preceded by a backslash

If you look at https://3v4l.org/OjhAe the output is different for prior to PHP 7.3.0.

Test script:
---------------
<?php

var_dump(mb_ereg_replace('(%)', '\\\1', 'a%c'));

Expected result:
----------------
string(4) "a\%c"

Actual result:
--------------
string(5) "a\\1c"

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2019-01-08 09:09 UTC] nikic@php.net
Hrm, both the old and the new behavior are incorrect. The result should be "a\1c" here. '\\\1' is \\1 after unescaping, which should be a literal \ followed by a literal 1.

Not sure what to do with this one... It looks like this function just did not support escaping backslashes previously, so we might just have to go back to that for BC reasons.
 [2019-01-08 09:22 UTC] nikic@php.net
Automatic comment on behalf of nikita.ppv@gmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=76c687feaf86d305f8ba510a7319ccc1b66a8901
Log: Fixed bug #77428
 [2019-01-08 09:22 UTC] nikic@php.net
-Status: Open +Status: Closed
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 16:01:28 2024 UTC