Bug #74230 [Opn]: iconv fails to fail on surrogates
| From: | ab@php.net | Date: | Mon, 13 Mar 2017 12:41:28 +0000 |
| Subject: | Bug #74230 [Opn]: iconv fails to fail on surrogates | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-207812@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=74230&edit=1
ID: 74230
Updated by: ab@php.net
Reported by: paul dot crovella at gmail dot com
Summary: iconv fails to fail on surrogates
Status: Open
Type: Bug
Package: ICONV related
Operating System: Windows
PHP Version: 7.1.2
Block user comment: N
Private report: N
New Comment:
Thanks for the report. This seems to be the libiconv issue. The library used is quite old, but
surprisingly libiconv-1.15 was released a month ago after 6 years of silence :) I'm goint to
check with it. Otherwise, in 7.1 you might get an acceptable result with sapi_windows_cp_conv().
Thanks.
Previous Comments:
------------------------------------------------------------------------
[2017-03-09 10:48:45] paul dot crovella at gmail dot com
Description:
------------
Surrogate codepoints cannot be validly encoded in UTF-8. Iconv should return false when given a byte
sequence that would encode them and an in_charset of 'UTF-8'.
This works as expected on Linux https://3v4l.org/Ff6cr but
doesn't on Windows (tested with PHP 7.0.16 and 7.1.2.)
Test script:
---------------
$high = "\xED\xa1\x92"; // codepoint D852
$low = "\xED\xBD\xA2"; // codepoint DF62
$pair = $high.$low;
var_dump(
@\iconv('UTF-8', 'UTF-8', $high) === false,
@\iconv('UTF-8', 'UTF-8', $low) === false,
@\iconv('UTF-8', 'UTF-8', $pair) === false
);
Expected result:
----------------
bool(true)
bool(true)
bool(true)
Actual result:
--------------
bool(false)
bool(false)
bool(false)
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=74230&edit=1