]> 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:03:22 +0000 (17:03 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Thu, 27 Nov 2008 17:03:22 +0000 (17:03 +0000)
content-type)

ext/curl/interface.c

index 66d58a795d1aca391fcf876f6e509f8658ea1688..09026bf095d0f535592ae5968360077bb4bec809 100644 (file)
@@ -1639,17 +1639,37 @@ type_conflict:
                                         * 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';
+                                               }
                                                /* open_basedir check */
                                                if (php_check_open_basedir(postval TSRMLS_CC)) {
+                                                       if (type) {
+                                                               *type = ';';
+                                                       }
                                                        RETVAL_FALSE;
                                                        return 1;
                                                }
-                                               error = curl_formadd(&first, &last, 
+                                               if (type) {
+                                                       type++;
+                                                       error = curl_formadd(&first, &last, 
                                                                                         CURLFORM_COPYNAME, key,
                                                                                         CURLFORM_NAMELENGTH, l,
-                                                                                        CURLFORM_FILE, postval, 
+                                                                                        CURLFORM_FILE, postval,
+                                                                                        CURLFORM_CONTENTTYPE, type,
                                                                                         CURLFORM_END);
+                                                       *(type - 1) = ';';
+                                               } else {
+                                                       error = curl_formadd(&first, &last, 
+                                                                                        CURLFORM_COPYNAME, key,
+                                                                                        CURLFORM_NAMELENGTH, l,
+                                                                                        CURLFORM_FILE, postval,
+                                                                                        CURLFORM_END);
+
+                                               }
                                        } else {
                                                error = curl_formadd(&first, &last, 
                                                                                         CURLFORM_COPYNAME, key,