Edit report at https://bugs.php.net/bug.php?id=74230&edit=1
ID: 74230
Updated by: [email protected]
Reported by: paul dot crovella at gmail dot com
Summary: iconv fails to fail on surrogates
-Status: Open
+Status: Closed
Type: Bug
Package: ICONV related
Operating System: Windows
PHP Version: 7.1.2
-Assigned To:
+Assigned To: ab
Block user comment: N
Private report: N
New Comment:
The deps was updated with libiconv-1.15 for all 7.x branches. Currently you can fetch any latest master snap for the tests and OFC teh upcoming RCs this week.
Thanks.
Previous Comments:
------------------------------------------------------------------------
[2017-03-13 20:29:57] paul dot crovella at gmail dot com
Wow, and their very first bullet point for that release is:
- The UTF-8 converter now rejects surrogates and out-of-range code points.
http://savannah.gnu.org/forum/forum.php?forum_id=8790
Talk about timing :D
------------------------------------------------------------------------
[2017-03-13 12:41:26] [email protected]
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.
------------------------------------------------------------------------
[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
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.