#41147 [Asn->Bgs]: mb_check_encoding fails to check invalid string

From: Date: Sat, 18 Aug 2007 14:45:13 +0000
Subject: #41147 [Asn->Bgs]: mb_check_encoding fails to check invalid string
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-116303@lists.php.net to get a copy of this message
 ID:               41147
 Updated by:       hirokawa@php.net
 Reported By:      teracci2002 at yahoo dot co dot jp
-Status:           Assigned
+Status:           Bogus
 Bug Type:         mbstring related
 Operating System: Linux
 PHP Version:      5.2.1
 Assigned To:      hirokawa
 New Comment:

It is expected behavior because 
0x00,0xa1 is null byte + valid ShiftJIS character.
mb_check_encoding should be used to detect invalid 
or corrupted multibyte characters.



Previous Comments:
------------------------------------------------------------------------

[2007-04-20 10:11:03] teracci2002 at yahoo dot co dot jp

If the data is NOT valid, FALSE should be returned, I guess.
But actually it returns TRUE.
Am I wrong or missing your point?

------------------------------------------------------------------------

[2007-04-20 09:27:44] tony2001@php.net

Please explain why do you think it should succeed if the data is
invalid.

------------------------------------------------------------------------

[2007-04-20 09:21:42] teracci2002 at yahoo dot co dot jp

Description:
------------
mb_check_encoding returns true when specific invalid EUC-JP / Shift_JIS
/ UTF-8 char sequence supplied.


Reproduce code:
---------------
//(1)
var_dump(mb_check_encoding("\x00\xA1", "EUC-JP"));
//(2)
var_dump(mb_check_encoding("\x00\x81", "Shift_JIS"));
//(3)
var_dump(mb_check_encoding("\x00\xE3", "UTF-8"));

Expected result:
----------------
//(1)
bool(false)
//(2)
bool(false)
//(3)
bool(false)

Actual result:
--------------
//(1)
bool(true)
//(2)
bool(true)
//(3)
bool(true)



------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=41147&edit=1


Thread (14 messages)

« previous php.bugs (#116303) next »