|  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: Assigned: moriyoshi (profile)
Status: Closed Package: mbstring related
PHP Version: 5.3SVN-2009-09-11 (SVN) OS: *
Private report: No CVE-ID: None
 [2009-09-11 21:23 UTC]
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"
string(5) "UTF-8"

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


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2009-09-11 21:26 UTC]
Automatic comment from SVN on behalf of moriyoshi
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]
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
Thank you for the report, and for helping us make PHP better.

PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Apr 14 15:01:29 2024 UTC