Bug #77093 [ReO]: mb_ereg_replace() does not work with SJIS-win(cp932)

From: Date: Mon, 05 Nov 2018 01:37:40 +0000
Subject: Bug #77093 [ReO]: mb_ereg_replace() does not work with SJIS-win(cp932)
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-217825@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=77093&edit=1 ID: 77093 Updated by: yohgaki@php.net Reported by: ryosuke dot kobayashi at fujisystems dot co dot jp Summary: mb_ereg_replace() does not work with SJIS-win(cp932) Status: Re-Opened Type: Bug Package: mbstring related Operating System: Linux PHP Version: 7.2.11 Block user comment: N Private report: N New Comment: I suppose it would be fixed also, since mb_ereg_replace() (and it's valiants) is returning NULL for invalid encoding. Previous Comments: ------------------------------------------------------------------------ [2018-11-05 01:13:33] ryosuke dot kobayashi at fujisystems dot co dot jp thanks for the inquiry. I could understand the reason. So, are these results come from same reason? https://3v4l.org/BiA4b ------------------------------------------------------------------------ [2018-11-03 23:22:13] yohgaki@php.net I suppose returning exact encoding, i.e. SJIS-win, from _php_mb_regex_mbctype2name(MBREX(current_mbctype)) would fix this bug. ------------------------------------------------------------------------ [2018-11-03 23:16:00] yohgaki@php.net I briefly checked code. It seems the difference came from supported encoding between mbstring and Onigruma. Mbstring has 'SJIS-win' encoding while Oniguruma has only 'SJIS'. Any SJIS valiants are validated as 'SJIS'. As a result, Current (newer) code is trying to validate 'SJIS-win' as 'SJIS' which will fail in certain cases. Following code should be fixed to address this bug. i.e. php_mb_check_encoding() needs 'SJIS-win' from '_php_mb_regex_mbctype2name(MBREX(current_mbctype))' in this case, not 'SJIS'. php_mbregex.c if (!php_mb_check_encoding( string, string_len, _php_mb_regex_mbctype2name(MBREX(current_mbctype)) )) { Using 'SJIS' as mbregex encoding wouldn't fix issue. https://3v4l.org/P56Zg There should be other issue. ------------------------------------------------------------------------ [2018-11-03 03:34:33] yohgaki@php.net It seems encoding validation is failing somehow and returning FALSE for it. ------------------------------------------------------------------------ [2018-11-02 09:54:14] cmb@php.net <https://3v4l.org/m6JZe> looks like a bug. ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at https://bugs.php.net/bug.php?id=77093 -- Edit this bug report at https://bugs.php.net/bug.php?id=77093&edit=1

« previous php.bugs (#217825) next »