From: Ilia Alshanetsky Date: Thu, 27 Nov 2008 17:03:22 +0000 (+0000) Subject: MFB: Fixed bug #46696 (cURL fails in upload files with specified X-Git-Tag: BEFORE_HEAD_NS_CHANGES_MERGE~68 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=496ec83e38071bfd3b2a4dae0464231b89a0a657;p=php MFB: Fixed bug #46696 (cURL fails in upload files with specified content-type) --- diff --git a/ext/curl/interface.c b/ext/curl/interface.c index 66d58a795d..09026bf095 100644 --- a/ext/curl/interface.c +++ b/ext/curl/interface.c @@ -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,