This repository was archived by the owner on Sep 22, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +16
-7
lines changed Expand file tree Collapse file tree 2 files changed +16
-7
lines changed Original file line number Diff line number Diff line change @@ -105,15 +105,13 @@ public function buildPostData($data)
105
105
} else {
106
106
$ binary_data = false ;
107
107
foreach ($ data as $ key => $ value ) {
108
- // Fix "Notice: Array to string conversion" when $value in
109
- // curl_setopt($ch, CURLOPT_POSTFIELDS, $value) is an array
110
- // that contains an empty array.
108
+ // Fix "Notice: Array to string conversion" when $value in curl_setopt($ch, CURLOPT_POSTFIELDS,
109
+ // $value) is an array that contains an empty array.
111
110
if (is_array ($ value ) && empty ($ value )) {
112
111
$ data [$ key ] = '' ;
113
- // Fix "curl_setopt(): The usage of the @filename API for
114
- // file uploading is deprecated. Please use the CURLFile
115
- // class instead".
116
- } elseif (is_string ($ value ) && strpos ($ value , '@ ' ) === 0 ) {
112
+ // Fix "curl_setopt(): The usage of the @filename API for file uploading is deprecated. Please use
113
+ // the CURLFile class instead". Ignore non-file values prefixed with the @ character.
114
+ } elseif (is_string ($ value ) && strpos ($ value , '@ ' ) === 0 && is_file (substr ($ value , 1 ))) {
117
115
$ binary_data = true ;
118
116
if (class_exists ('CURLFile ' )) {
119
117
$ data [$ key ] = new \CURLFile (substr ($ value , 1 ));
Original file line number Diff line number Diff line change @@ -385,6 +385,17 @@ public function testPostCurlFileUpload()
385
385
}
386
386
}
387
387
388
+ public function testPostNonFilePathUpload ()
389
+ {
390
+ $ test = new Test ();
391
+ $ test ->server ('post ' , 'POST ' , array (
392
+ 'foo ' => 'bar ' ,
393
+ 'file ' => '@not-a-file ' ,
394
+ ));
395
+ $ this ->assertFalse ($ test ->curl ->error );
396
+ $ this ->assertEquals ('foo=bar&file=%40not-a-file ' , $ test ->curl ->response );
397
+ }
398
+
388
399
public function testPutRequestMethod ()
389
400
{
390
401
$ test = new Test ();
You can’t perform that action at this time.
0 commit comments