]> granicus.if.org Git - php/commitdiff
MFB: Fixed bug #46696 (cURL fails in upload files with specified
authorIlia Alshanetsky <iliaa@php.net>
Thu, 27 Nov 2008 17:01:29 +0000 (17:01 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Thu, 27 Nov 2008 17:01:29 +0000 (17:01 +0000)
content-type)

NEWS
ext/curl/interface.c

diff --git a/NEWS b/NEWS
index 8a80f6ecd620f55a0021b59a54514775fdcac448..0f286ef40e8b824477414f180f679d0d20b2c74f 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -4,6 +4,8 @@ PHP                                                                        NEWS
 - Upgraded PCRE to version 7.8 (Ilia)
 
 - Fixed memory leak inside readline_callback_handler_remove() function. (Felipe)
+- Fixed bug #46696 (cURL fails in upload files with specified content-type).
+  (Ilia)
 - Fixed bug #46673 (stream_lock call with wrong paramater). (Arnaud)
 - Fixed bug #46649 (Setting array element with that same array produces 
   inconsistent results). (Arnaud)
index d68f85bf43af3a86ab571d33f834e73be24c2396..54c7030abf9aad108b810c30f076bc0f9ad66e3b 100644 (file)
@@ -1481,17 +1481,37 @@ static int _php_curl_setopt(php_curl *ch, long option, zval **zvalue, zval *retu
                                         * must be explicitly cast to long in curl_formadd
                                         * use since curl needs a long not an int. */
                                        if (*postval == '@') {
+                                               char *type;
                                                ++postval;
+
+                                               if ((type = php_memnstr(postval, ";type=", sizeof(";type=") - 1, postval + strlen(postval)))) {
+                                                       *type = '\0';
+                                               }
                                                /* safe_mode / open_basedir check */
                                                if (php_check_open_basedir(postval TSRMLS_CC) || (PG(safe_mode) && !php_checkuid(postval, "rb+", CHECKUID_CHECK_MODE_PARAM))) {
+                                                       if (type) {
+                                                               *type = ';';
+                                                       }
                                                        RETVAL_FALSE;
                                                        return 1;
                                                }
-                                               error = curl_formadd(&first, &last, 
+                                               if (type) {
+                                                       type++;
+                                                       error = curl_formadd(&first, &last, 
+                                                                                        CURLFORM_COPYNAME, string_key,
+                                                                                        CURLFORM_NAMELENGTH, (long)string_key_len - 1,
+                                                                                        CURLFORM_FILE, postval,
+                                                                                        CURLFORM_CONTENTTYPE, type,
+                                                                                        CURLFORM_END);
+                                                       *(type - 1) = ';';
+                                               } else {
+                                                       error = curl_formadd(&first, &last, 
                                                                                         CURLFORM_COPYNAME, string_key,
                                                                                         CURLFORM_NAMELENGTH, (long)string_key_len - 1,
-                                                                                        CURLFORM_FILE, postval, 
+                                                                                        CURLFORM_FILE, postval,
                                                                                         CURLFORM_END);
+
+                                               }
                                        } else {
                                                error = curl_formadd(&first, &last, 
                                                                                         CURLFORM_COPYNAME, string_key,