php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #52211 iconv() returns part of string on error
Submitted: 2010-06-30 15:27 UTC Modified: 2012-01-08 12:34 UTC
From: raphgivernaud at yahoo dot fr Assigned: felipe
Status: Closed Package: ICONV related
PHP Version: 5.3.2 OS: Windows Vista
Private report: No CVE-ID:
 [2010-06-30 15:27 UTC] raphgivernaud at yahoo dot fr
Description:
------------
When the function fails because of illegal characters, the function never returns false

Test script:
---------------
<?php

    $str = "PATHOLOGIES MÉDICO-CHIRUR. ADUL. PL";
    $str_iconv = iconv('CP850', 'ISO-8859-1', $str );
    var_dump($str_iconv);

?>

Expected result:
----------------
bool(false)

Actual result:
--------------
string(13) "PATHOLOGIES M"

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-07-01 03:08 UTC] felipe@php.net
-Summary: iconv return +Summary: iconv() returns part of string on error
 [2010-07-01 03:11 UTC] felipe@php.net
Automatic comment from SVN on behalf of felipe
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=300894
Log: - Fixed bug #52211 (iconv() returns part of string on error)
 [2010-07-01 03:15 UTC] felipe@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: felipe
 [2010-07-01 03:15 UTC] felipe@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.

This bug has been only fixed on trunk, because from what I can see, it might cause BC issue on 5.3 series.
 [2010-12-10 10:55 UTC] raphgivernaud at yahoo dot fr
Hello,

In version 5.3.3 and 5.3.4, the problem is still not
resolved
 [2010-12-10 12:20 UTC] felipe@php.net
Yes, as I mentioned, the fix was committed on trunk, not in 5.3 branch.
 [2010-12-10 12:39 UTC] raphgivernaud at yahoo dot fr
Ok, sorry
 [2011-12-18 18:36 UTC] ezyang@php.net
-Status: Closed +Status: Re-Opened
 [2011-12-18 18:36 UTC] ezyang@php.net
I don't think this bug was fixed correctly. In particular, iconv doesn't handle '//IGNORE' correctly now.

ezyang@javelin:~$ cat test.php
<?php var_dump(iconv("UTF-8", "ISO-8859-1//IGNORE", "\xE4\xB8\xAD"));
ezyang@javelin:~$ php --version
PHP 5.3.6-13ubuntu3.3 with Suhosin-Patch (cli) (built: Dec 13 2011 18:37:10) 
Copyright (c) 1997-2011 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2011 Zend Technologies
    with Xdebug v2.1.0, Copyright (c) 2002-2010, by Derick Rethans
ezyang@javelin:~$ php test.php
PHP Notice:  iconv(): Detected an illegal character in input string in /home/ezyang/test.php on line 1
PHP Stack trace:
PHP   1. {main}() /home/ezyang/test.php:0
PHP   2. iconv() /home/ezyang/test.php:1
string(0) ""
ezyang@javelin:~$ phpv 5.4.0RC3 --version
PHP 5.4.0RC3 (cli) (built: Dec 16 2011 15:14:12) 
Copyright (c) 1997-2011 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2011 Zend Technologies
ezyang@javelin:~$ phpv 5.4.0RC3 test.php
bool(false)
 [2012-01-08 12:34 UTC] pajoye@php.net
-Status: Re-Opened +Status: Closed
 [2012-01-08 12:34 UTC] pajoye@php.net
This is a totally unrelated issue to what you try to explain. And you already have 
a report for this, #48147
 
PHP Copyright © 2001-2014 The PHP Group
All rights reserved.
Last updated: Thu Apr 17 16:02:22 2014 UTC