Bug #79004 [NEW]: CURLFile's 3rd argument doesn't honor emptystring

From: Date: Fri, 20 Dec 2019 00:12:28 +0000
Subject: Bug #79004 [NEW]: CURLFile's 3rd argument doesn't honor emptystring
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-224430@lists.php.net to get a copy of this message
From: divinity76 at gmail dot com Operating system: Ubuntu 18.04 PHP version: 7.2.26 Package: Unknown/Other Function Bug Type: Bug Bug description:CURLFile's 3rd argument doesn't honor emptystring Description: ------------ if you give CURLFile's an empty string as the third argument, it will in fact swap out the empty string with the first argument! that makes porting this curl command rather difficult: curl -F "uploadManifest={json};type=application/json" http://127.0.0.1:9999/ i guess it's debatable weather emptystring should remove the filename header entirely (like CURLOPT_HTTPHEADER does, for example to remove libcurl-generated "Expect: 100-continue" headers, set CURLOPT_HTTPHEADER=>array("Except: "), and the Expect header won't be generated at all), or if it should literally send filename="" (but my personal opinion is that it should work the same as CURLOPT_HTTPHEADER, eg remove the filename header entirely), but whatever the right action is, it's certainly not the current action of replacing it with the on-disk file-location, and that's what it's currently doing. (maybe that would be ok if argument 3 is null, i don't know, but it's not appropriate if the 3rd argument is emptystring, the programmer specifically asked for an empty filename, and now doesn't get one.) Test script: --------------- <?php $stupid_workaround_fileh = tmpfile(); $stupid_workaround_filef = stream_get_meta_data($stupid_workaround_fileh)['uri']; fwrite($stupid_workaround_fileh,"{json}"); $ch=curl_init(); curl_setopt_array($ch, array( CURLOPT_URL => "http://127.0.0.1:9999/", CURLOPT_POST => 1, CURLOPT_POSTFIELDS => array( 'uploadManifest' => new CURLFile($stupid_workaround_filef, 'application/json', '') ) )); curl_exec($ch); Expected result: ---------------- POST / HTTP/1.1 Host: 127.0.0.1:9999 Accept: */* Content-Length: 186 Content-Type: multipart/form-data; boundary=------------------------2e0011350c342f21 --------------------------2e0011350c342f21 Content-Disposition: form-data; name="uploadManifest" Content-Type: application/json {json} --------------------------2e0011350c342f21-- Actual result: -------------- POST / HTTP/1.1 Host: 127.0.0.1:9999 Accept: */* Content-Length: 214 Content-Type: multipart/form-data; boundary=------------------------2e0011350c342f21 --------------------------2e0011350c342f21 Content-Disposition: form-data; name="uploadManifest"; filename="/tmp/phpSh32lX" Content-Type: application/json {json} --------------------------2e0011350c342f21-- -- Edit bug report at https://bugs.php.net/bug.php?id=79004&edit=1 -- Fix committed: https://bugs.php.net/fix.php?id=79004&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=79004&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=79004&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=79004&r=needscript Try newer version: https://bugs.php.net/fix.php?id=79004&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=79004&r=support Expected behavior: https://bugs.php.net/fix.php?id=79004&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=79004&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=79004&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=79004&r=globals PHP version support discontinued: https://bugs.php.net/fix.php?id=79004&r=phptooold Daylight Savings: https://bugs.php.net/fix.php?id=79004&r=dst IIS Stability: https://bugs.php.net/fix.php?id=79004&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=79004&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=79004&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=79004&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=79004&r=mysqlcfg

« previous php.bugs (#224430) next »