php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #49536 mb_detect_encoding() returns incorrect results when strict_mode is turned on
Submitted: 2009-09-11 21:23 UTC Modified: 2009-09-23 14:27 UTC
From: moriyoshi@php.net Assigned: moriyoshi
Status: Closed Package: mbstring related
PHP Version: 5.3SVN-2009-09-11 (SVN) OS: *
Private report: No CVE-ID:
 [2009-09-11 21:23 UTC] moriyoshi@php.net
Description:
------------
mb_detect_encoding() produces wrong results from incomplete multibyte sequences when strict_mode is turned on. (originally reported by komura.db2r1e|at|gmail|dot|com)

Reproduce code:
---------------
// non-strict mode
var_dump(mb_detect_encoding("A\x81", "SJIS", false));
// strict mode
var_dump(mb_detect_encoding("A\x81", "SJIS", true));
// non-strict mode
var_dump(mb_detect_encoding("\xc0\x00", "UTF-8", false));
// strict mode
var_dump(mb_detect_encoding("\xc0\x00", "UTF-8", true));

Expected result:
----------------
string(4) "SJIS"
bool(false)
string(5) "UTF-8"
bool(false)


Actual result:
--------------
string(4) "SJIS"
string(4) "SJIS"
string(5) "UTF-8"
string(5) "UTF-8"


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-09-11 21:26 UTC] svn@php.net
Automatic comment from SVN on behalf of moriyoshi
Revision: http://svn.php.net/viewvc/?view=revision&revision=288273
Log: - Fix bug #49536 (mb_detect_encoding() returns incorrect results when strict_mode is turned on.)
  (patch by komura, thanks!)
 [2009-09-23 14:27 UTC] moriyoshi@php.net
This bug has been fixed in SVN.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2014 The PHP Group
All rights reserved.
Last updated: Mon Apr 21 04:01:57 2014 UTC