Bug #69151 [Opn]: mb_ereg should reject ill-formed byte sequence
| From: | yohgaki@php.net | Date: | Sat, 28 Mar 2015 21:01:44 +0000 |
| Subject: | Bug #69151 [Opn]: mb_ereg should reject ill-formed byte sequence | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-191667@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=69151&edit=1
ID: 69151
Updated by: yohgaki@php.net
Reported by: masakielastic at gmail dot com
Summary: mb_ereg should reject ill-formed byte sequence
Status: Open
Type: Bug
Package: mbstring related
Operating System: Mac OS X
PHP Version: 5.6.6
Block user comment: N
Private report: N
New Comment:
While we may check encoding validity in functions, it requires CPU resource.
The best approach is to check encoding validity when program accepts inputs. i.e . Users must make
sure encoding validity. Otherwise, PHP must check encoding again and again. Therefore, I think it is
better to document this behavior in the manual.
We may have unicode support in near future and we should take this approach, so that we don't
repeat PHP 6 failure.
I wrote type affinity RFC for PHP
https://wiki.php.net/rfc/introduce-type-affinity
Encoding validation for $_GET/$_POST/etc may be handled by this RFC.
Previous Comments:
------------------------------------------------------------------------
[2015-03-01 13:03:37] masakielastic at gmail dot com
Description:
------------
mb_reg should return false like preg_match if the argument is not well-formed byte sequence since
Oniguruma doesn't check the validity of encoding. The same rule applies to mb_ereg_replace,
mb_ereg_search_init.
Test script:
---------------
$str = "\x80";
var_dump(
false === mb_eregi('.', $str, $matches),
[] === $matches
);
Expected result:
----------------
bool(true)
bool(true)
Actual result:
--------------
bool(false)
bool(false)
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=69151&edit=1