Bug #74230 [Opn->Csd]: iconv fails to fail on surrogates

From: Date: Mon, 27 Mar 2017 18:24:38 +0000
Subject: Bug #74230 [Opn->Csd]: iconv fails to fail on surrogates
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-208095@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 +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] ab@php.net 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

« previous php.bugs (#208095) next »