Bug #77557 [Opn->Ver]: mb_regex_replace does not handle backreferences if regex-encoding is UTF-32

From: Date: Sat, 02 Feb 2019 19:05:23 +0000
Subject: Bug #77557 [Opn->Ver]: mb_regex_replace does not handle backreferences if regex-encoding is UTF-32
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-219336@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=77557&edit=1 ID: 77557 Updated by: cmb@php.net Reported by: codes at designsandcodes dot com Summary: mb_regex_replace does not handle backreferences if regex-encoding is UTF-32 -Status: Open +Status: Verified Type: Bug Package: mbstring related Operating System: Windows 10, Ubuntu 16.04 -PHP Version: 7.3.1 +PHP Version: 7.2 Block user comment: N Private report: N New Comment: This issue is not PHP 7.3 specific[1]. [1] <https://3v4l.org/KqU5d> Previous Comments: ------------------------------------------------------------------------ [2019-02-02 02:52:57] codes at designsandcodes dot com Description: ------------ Per summary, backreferences are not properly replaced if the regex encoding is any of the UTF-32 flavors (BE, LE, UCS-4). All 3 parameters (pattern, replace, subject) are being presented in the correct UTF-32 flavor; replace is being returned unmodified. Test script: --------------- $regexEncoding = 'UTF-32'; mb_regex_encoding( $regexEncoding ); var_export( mb_ereg_replace( mb_convert_encoding( '.+', $regexEncoding ), mb_convert_encoding( "the \\0", $regexEncoding ), mb_convert_encoding( 'dog', $regexEncoding ) ) ); Expected result: ---------------- '' . "\0" . '' . "\0" . '' . "\0" . 't' . "\0" . '' . "\0" . '' . "\0" . 'h' . "\0" . '' . "\0" . '' . "\0" . 'e' . "\0" . '' . "\0" . '' . "\0" . ' ' . "\0" . '' . "\0" . '' . "\0" . 'd' . "\0" . '' . "\0" . '' . "\0" . 'o' . "\0" . '' . "\0" . '' . "\0" . 'g' e.g., "the dog" in UTF-32 encoding Actual result: -------------- '' . "\0" . '' . "\0" . '' . "\0" . 't' . "\0" . '' . "\0" . '' . "\0" . 'h' . "\0" . '' . "\0" . '' . "\0" . 'e' . "\0" . '' . "\0" . '' . "\0" . ' ' . "\0" . '' . "\0" . '' . "\0" . '\\' . "\0" . '' . "\0" . '' . "\0" . '0' e.g., "\\0" in UTF-32 encoding ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=77557&edit=1

« previous php.bugs (#219336) next »