mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
Fixed bug #46696 (cURL fails in upload files with specified content-type)
This commit is contained in:
parent
12e27a7014
commit
d741138a46
1 changed files with 22 additions and 2 deletions
|
@ -1582,17 +1582,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_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_END);
|
||||
|
||||
}
|
||||
} else {
|
||||
error = curl_formadd(&first, &last,
|
||||
CURLFORM_COPYNAME, string_key,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue