Bug #77711 [NEW]: CURLFile unable to handle UNICODE filenames

From: Date: Fri, 08 Mar 2019 16:00:31 +0000
Subject: Bug #77711 [NEW]: CURLFile unable to handle UNICODE filenames
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-219890@lists.php.net to get a copy of this message
From: anrdaemon at freemail dot ru Operating system: Windows PHP version: 7.3.3 Package: cURL related Bug Type: Bug Bug description:CURLFile unable to handle UNICODE filenames Description: ------------ CURLFile starting from PHP 7.1 is unable to handle local paths containing UNICODE sequences. The workaround is to iconv() the path to single-byte character set used by WinAPI non-widestring family of functions on a given OS installation. But that's limiting the usability of the language to laughable levels. $ php -i | grep -E "chars|encod" default_charset => CP866 => CP866 input_encoding => CP866 => CP866 internal_encoding => UTF-8 => UTF-8 output_encoding => CP866 => CP866 zend.script_encoding => no value => no value exif.encode_jis => no value => no value exif.encode_unicode => ISO-8859-15 => ISO-8859-15 iconv.input_encoding => no value => no value iconv.internal_encoding => no value => no value iconv.output_encoding => no value => no value mailparse.def_charset => UTF-8 => UTF-8 HTTP input encoding translation => disabled mbstring.encoding_translation => Off => Off mbstring.internal_encoding => no value => no value Test script: --------------- <?php // Cyrillic capital letter A // tempnam() returns path encoded in internal_encoding $name = tempnam(__DIR__, "\u{0410}"); //print bin2hex(basename($name)); file_put_contents($name, "Test."); $file = new \CURLFile($name, null, "file"); // $file = new \CURLFile(iconv("UTF-8", "CP1251", $name), null, "file"); // Rather arbitrary workaround $curl = curl_init($argv[1] ?: "http://example.org/post.php"); curl_setopt_array($curl, [ CURLOPT_POST => true, CURLOPT_POSTFIELDS => [ "file" => $file, ], CURLOPT_VERBOSE => true, ]); $rc = curl_exec($curl); if($rc === false) { $err = curl_errno($curl); error_log(curl_strerror($err) . " ($err): " . curl_error($curl)); die; } print "$rc"; Expected result: ---------------- Successful upload. Actual result: -------------- Failed to open/read local data from file/application (26): -- Edit bug report at https://bugs.php.net/bug.php?id=77711&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=77711&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=77711&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=77711&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=77711&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=77711&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=77711&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=77711&r=needscript Try newer version: https://bugs.php.net/fix.php?id=77711&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=77711&r=support Expected behavior: https://bugs.php.net/fix.php?id=77711&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=77711&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=77711&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=77711&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=77711&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=77711&r=dst IIS Stability: https://bugs.php.net/fix.php?id=77711&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=77711&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=77711&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=77711&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=77711&r=mysqlcfg

« previous php.bugs (#219890) next »