Bug #74230 [NEW]: iconv fails to fail on surrogates

From: Date: Thu, 09 Mar 2017 10:48:47 +0000
Subject: Bug #74230 [NEW]: iconv fails to fail on surrogates
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-207756@lists.php.net to get a copy of this message
From: paul dot crovella at gmail dot com Operating system: Windows PHP version: 7.1.2 Package: ICONV related Bug Type: Bug Bug description:iconv fails to fail on surrogates 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 bug report at https://bugs.php.net/bug.php?id=74230&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=74230&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=74230&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=74230&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=74230&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=74230&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=74230&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=74230&r=needscript Try newer version: https://bugs.php.net/fix.php?id=74230&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=74230&r=support Expected behavior: https://bugs.php.net/fix.php?id=74230&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=74230&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=74230&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=74230&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=74230&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=74230&r=dst IIS Stability: https://bugs.php.net/fix.php?id=74230&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=74230&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=74230&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=74230&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=74230&r=mysqlcfg

« previous php.bugs (#207756) next »