|  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
The substitution variable of mb_ereg_replace() is not working when a substitution variable is preceded by a backslash

If you look at the output is different for prior to PHP 7.3.0.

Test script:

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

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

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


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2019-01-08 09:09 UTC]
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]
Automatic comment on behalf of
Log: Fixed bug #77428
 [2019-01-08 09:22 UTC]
-Status: Open +Status: Closed
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat May 25 23:01:30 2024 UTC