diff --git a/NEWS b/NEWS index 6ca2a85f72c03..c9c48d74f5500 100644 --- a/NEWS +++ b/NEWS @@ -19,6 +19,10 @@ PHP NEWS . Remove WeakMap entries whose key is only reachable through the entry value. (Arnaud) +- Curl: + . Added Curl options and constants up to (including) version 7.87. + (nielsdos, adoy) + - DOM: . Added DOMNode::contains() and DOMNameSpaceNode::contains(). (nielsdos) . Added DOMElement::getAttributeNames(). (nielsdos) diff --git a/UPGRADING b/UPGRADING index 18700b6872c2c..6c17192179607 100644 --- a/UPGRADING +++ b/UPGRADING @@ -187,6 +187,11 @@ PHP 8.3 UPGRADE NOTES . IntlChar::enumCharNames is now returning a boolean. Previously it returned null on success and false on failure. +- Curl: + . curl_getinfo() now supports two new constants: CURLINFO_CAPATH and CURLINFO_CAINFO. + If option is null, the following two additional keys are present: + "capath" and "cainfo". + - MBString: . mb_strtolower, mb_strtotitle, and mb_convert_case implement conditional casing rules for the Greek letter sigma. For mb_convert_case, conditional @@ -339,6 +344,23 @@ PHP 8.3 UPGRADE NOTES 10. New Global Constants ======================================== +- Curl: + . CURLINFO_CAPATH + . CURLINFO_CAINFO + . CURLOPT_MIME_OPTIONS + . CURLMIMEOPT_FORMESCAPE + . CURLOPT_WS_OPTIONS + . CURLWS_RAW_MODE + . CURLOPT_SSH_HOSTKEYFUNCTION + . CURLOPT_PROTOCOLS_STR + . CURLOPT_REDIR_PROTOCOLS_STR + . CURLOPT_CA_CACHE_TIMEOUT + . CURLOPT_QUICK_EXIT + . CURLKHMATCH_OK + . CURLKHMATCH_MISMATCH + . CURLKHMATCH_MISSING + . CURLKHMATCH_LAST + - Intl: . MIXED_NUMBERS (Spoofchecker). . HIDDEN_OVERLAY (Spoofchecker). diff --git a/ext/curl/curl.stub.php b/ext/curl/curl.stub.php index 282fc1eaaa126..05ce48640380f 100644 --- a/ext/curl/curl.stub.php +++ b/ext/curl/curl.stub.php @@ -941,6 +941,18 @@ */ const CURLINFO_EFFECTIVE_METHOD = UNKNOWN; #endif +#if LIBCURL_VERSION_NUM >= 0x075400 /* Available since 7.84.0 */ +/** + * @var int + * @cvalue CURLINFO_CAPATH + */ +const CURLINFO_CAPATH = UNKNOWN; +/** + * @var int + * @cvalue CURLINFO_CAINFO + */ +const CURLINFO_CAINFO = UNKNOWN; +#endif /* Other */ /** @@ -1979,6 +1991,26 @@ * @cvalue CURLOPT_SSH_KNOWNHOSTS */ const CURLOPT_SSH_KNOWNHOSTS = UNKNOWN; +/** + * @var int + * @cvalue CURLKHMATCH_OK + */ +const CURLKHMATCH_OK = UNKNOWN; +/** + * @var int + * @cvalue CURLKHMATCH_MISMATCH + */ +const CURLKHMATCH_MISMATCH = UNKNOWN; +/** + * @var int + * @cvalue CURLKHMATCH_MISSING + */ +const CURLKHMATCH_MISSING = UNKNOWN; +/** + * @var int + * @cvalue CURLKHMATCH_LAST + */ +const CURLKHMATCH_LAST = UNKNOWN; /* Available since 7.20.0 */ /** @@ -3522,6 +3554,66 @@ const CURLOPT_SSH_HOST_PUBLIC_KEY_SHA256 = UNKNOWN; #endif +#if LIBCURL_VERSION_NUM >= 0x075100 /* Available since 7.81.0 */ +/** + * @var int + * @cvalue CURLOPT_MIME_OPTIONS + */ +const CURLOPT_MIME_OPTIONS = UNKNOWN; +/** + * @var int + * @cvalue CURLMIMEOPT_FORMESCAPE + */ +const CURLMIMEOPT_FORMESCAPE = UNKNOWN; +#endif + +#if LIBCURL_VERSION_NUM >= 0x075400 /* Available since 7.84.0 */ +/** + * @var int + * @cvalue CURLOPT_SSH_HOSTKEYFUNCTION + */ +const CURLOPT_SSH_HOSTKEYFUNCTION = UNKNOWN; +#endif + +#if LIBCURL_VERSION_NUM >= 0x075500 /* Available since 7.85.0 */ +/** + * @var int + * @cvalue CURLOPT_PROTOCOLS_STR + */ +const CURLOPT_PROTOCOLS_STR = UNKNOWN; +/** + * @var int + * @cvalue CURLOPT_REDIR_PROTOCOLS_STR + */ +const CURLOPT_REDIR_PROTOCOLS_STR = UNKNOWN; +#endif + +#if LIBCURL_VERSION_NUM >= 0x075600 /* Available since 7.86.0 */ +/** + * @var int + * @cvalue CURLOPT_WS_OPTIONS + */ +const CURLOPT_WS_OPTIONS = UNKNOWN; +/** + * @var int + * @cvalue CURLWS_RAW_MODE + */ +const CURLWS_RAW_MODE = UNKNOWN; +#endif + +#if LIBCURL_VERSION_NUM >= 0x075700 /* Available since 7.87.0 */ +/** + * @var int + * @cvalue CURLOPT_CA_CACHE_TIMEOUT + */ +const CURLOPT_CA_CACHE_TIMEOUT = UNKNOWN; +/** + * @var int + * @cvalue CURLOPT_QUICK_EXIT + */ +const CURLOPT_QUICK_EXIT = UNKNOWN; +#endif + /** * @var int * @cvalue CURLOPT_SAFE_UPLOAD diff --git a/ext/curl/curl_arginfo.h b/ext/curl/curl_arginfo.h index c746edbb4a41c..d702de608a908 100644 --- a/ext/curl/curl_arginfo.h +++ b/ext/curl/curl_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: 778f1aa4a9333ef419c89276911333bc8a04a065 */ + * Stub hash: d524d2fd58e484682c860d8a72eafc9a7d544911 */ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_curl_close, 0, 1, IS_VOID, 0) ZEND_ARG_OBJ_INFO(0, handle, CurlHandle, 0) @@ -422,6 +422,12 @@ static void register_curl_symbols(int module_number) REGISTER_LONG_CONSTANT("CURLINFO_TOTAL_TIME", CURLINFO_TOTAL_TIME, CONST_PERSISTENT); #if LIBCURL_VERSION_NUM >= 0x074800 /* Available since 7.72.0 */ REGISTER_LONG_CONSTANT("CURLINFO_EFFECTIVE_METHOD", CURLINFO_EFFECTIVE_METHOD, CONST_PERSISTENT); +#endif +#if LIBCURL_VERSION_NUM >= 0x075400 /* Available since 7.84.0 */ + REGISTER_LONG_CONSTANT("CURLINFO_CAPATH", CURLINFO_CAPATH, CONST_PERSISTENT); +#endif +#if LIBCURL_VERSION_NUM >= 0x075400 /* Available since 7.84.0 */ + REGISTER_LONG_CONSTANT("CURLINFO_CAINFO", CURLINFO_CAINFO, CONST_PERSISTENT); #endif REGISTER_LONG_CONSTANT("CURLMSG_DONE", CURLMSG_DONE, CONST_PERSISTENT); REGISTER_LONG_CONSTANT("CURLVERSION_NOW", CURLVERSION_NOW, CONST_PERSISTENT); @@ -614,6 +620,10 @@ static void register_curl_symbols(int module_number) REGISTER_LONG_CONSTANT("CURLFTP_CREATE_DIR_RETRY", CURLFTP_CREATE_DIR_RETRY, CONST_PERSISTENT); REGISTER_LONG_CONSTANT("CURL_VERSION_CURLDEBUG", CURL_VERSION_CURLDEBUG, CONST_PERSISTENT); REGISTER_LONG_CONSTANT("CURLOPT_SSH_KNOWNHOSTS", CURLOPT_SSH_KNOWNHOSTS, CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("CURLKHMATCH_OK", CURLKHMATCH_OK, CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("CURLKHMATCH_MISMATCH", CURLKHMATCH_MISMATCH, CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("CURLKHMATCH_MISSING", CURLKHMATCH_MISSING, CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("CURLKHMATCH_LAST", CURLKHMATCH_LAST, CONST_PERSISTENT); REGISTER_LONG_CONSTANT("CURLINFO_RTSP_CLIENT_CSEQ", CURLINFO_RTSP_CLIENT_CSEQ, CONST_PERSISTENT); REGISTER_LONG_CONSTANT("CURLINFO_RTSP_CSEQ_RECV", CURLINFO_RTSP_CSEQ_RECV, CONST_PERSISTENT); REGISTER_LONG_CONSTANT("CURLINFO_RTSP_SERVER_CSEQ", CURLINFO_RTSP_SERVER_CSEQ, CONST_PERSISTENT); @@ -1295,6 +1305,33 @@ static void register_curl_symbols(int module_number) #endif #if LIBCURL_VERSION_NUM >= 0x075000 /* Available since 7.80.0 */ REGISTER_LONG_CONSTANT("CURLOPT_SSH_HOST_PUBLIC_KEY_SHA256", CURLOPT_SSH_HOST_PUBLIC_KEY_SHA256, CONST_PERSISTENT); +#endif +#if LIBCURL_VERSION_NUM >= 0x075100 /* Available since 7.81.0 */ + REGISTER_LONG_CONSTANT("CURLOPT_MIME_OPTIONS", CURLOPT_MIME_OPTIONS, CONST_PERSISTENT); +#endif +#if LIBCURL_VERSION_NUM >= 0x075100 /* Available since 7.81.0 */ + REGISTER_LONG_CONSTANT("CURLMIMEOPT_FORMESCAPE", CURLMIMEOPT_FORMESCAPE, CONST_PERSISTENT); +#endif +#if LIBCURL_VERSION_NUM >= 0x075400 /* Available since 7.84.0 */ + REGISTER_LONG_CONSTANT("CURLOPT_SSH_HOSTKEYFUNCTION", CURLOPT_SSH_HOSTKEYFUNCTION, CONST_PERSISTENT); +#endif +#if LIBCURL_VERSION_NUM >= 0x075500 /* Available since 7.85.0 */ + REGISTER_LONG_CONSTANT("CURLOPT_PROTOCOLS_STR", CURLOPT_PROTOCOLS_STR, CONST_PERSISTENT); +#endif +#if LIBCURL_VERSION_NUM >= 0x075500 /* Available since 7.85.0 */ + REGISTER_LONG_CONSTANT("CURLOPT_REDIR_PROTOCOLS_STR", CURLOPT_REDIR_PROTOCOLS_STR, CONST_PERSISTENT); +#endif +#if LIBCURL_VERSION_NUM >= 0x075600 /* Available since 7.86.0 */ + REGISTER_LONG_CONSTANT("CURLOPT_WS_OPTIONS", CURLOPT_WS_OPTIONS, CONST_PERSISTENT); +#endif +#if LIBCURL_VERSION_NUM >= 0x075600 /* Available since 7.86.0 */ + REGISTER_LONG_CONSTANT("CURLWS_RAW_MODE", CURLWS_RAW_MODE, CONST_PERSISTENT); +#endif +#if LIBCURL_VERSION_NUM >= 0x075700 /* Available since 7.87.0 */ + REGISTER_LONG_CONSTANT("CURLOPT_CA_CACHE_TIMEOUT", CURLOPT_CA_CACHE_TIMEOUT, CONST_PERSISTENT); +#endif +#if LIBCURL_VERSION_NUM >= 0x075700 /* Available since 7.87.0 */ + REGISTER_LONG_CONSTANT("CURLOPT_QUICK_EXIT", CURLOPT_QUICK_EXIT, CONST_PERSISTENT); #endif REGISTER_LONG_CONSTANT("CURLOPT_SAFE_UPLOAD", CURLOPT_SAFE_UPLOAD, CONST_PERSISTENT); } diff --git a/ext/curl/curl_private.h b/ext/curl/curl_private.h index ca3024bcd4926..3800d6533e555 100644 --- a/ext/curl/curl_private.h +++ b/ext/curl/curl_private.h @@ -77,6 +77,9 @@ typedef struct { php_curl_callback *xferinfo; #endif php_curl_callback *fnmatch; +#if LIBCURL_VERSION_NUM >= 0x075400 + php_curl_callback *sshhostkey; +#endif } php_curl_handlers; struct _php_curl_error { diff --git a/ext/curl/interface.c b/ext/curl/interface.c index 710321ba1df93..44284b7a29670 100644 --- a/ext/curl/interface.c +++ b/ext/curl/interface.c @@ -515,6 +515,12 @@ static HashTable *curl_get_gc(zend_object *object, zval **table, int *n) zend_get_gc_buffer_add_zval(gc_buffer, &curl->handlers.fnmatch->func_name); } +#if LIBCURL_VERSION_NUM >= 0x075400 + if (curl->handlers.sshhostkey) { + zend_get_gc_buffer_add_zval(gc_buffer, &curl->handlers.sshhostkey->func_name); + } +#endif + zend_get_gc_buffer_add_zval(gc_buffer, &curl->handlers.std_err); zend_get_gc_buffer_add_zval(gc_buffer, &curl->private_data); @@ -768,6 +774,61 @@ static size_t curl_xferinfo(void *clientp, curl_off_t dltotal, curl_off_t dlnow, /* }}} */ #endif +#if LIBCURL_VERSION_NUM >= 0x075400 +static int curl_ssh_hostkeyfunction(void *clientp, int keytype, const char *key, size_t keylen) +{ + php_curl *ch = (php_curl *)clientp; + php_curl_callback *t = ch->handlers.sshhostkey; + int rval = CURLKHMATCH_MISMATCH; /* cancel connection in case of an exception */ + +#if PHP_CURL_DEBUG + fprintf(stderr, "curl_ssh_hostkeyfunction() called\n"); + fprintf(stderr, "clientp = %x, keytype = %d, key = %s, keylen = %zu\n", clientp, keytype, key, keylen); +#endif + + zval argv[4]; + zval retval; + zend_result error; + zend_fcall_info fci; + + GC_ADDREF(&ch->std); + ZVAL_OBJ(&argv[0], &ch->std); + ZVAL_LONG(&argv[1], keytype); + ZVAL_STRINGL(&argv[2], key, keylen); + ZVAL_LONG(&argv[3], keylen); + + fci.size = sizeof(fci); + ZVAL_COPY_VALUE(&fci.function_name, &t->func_name); + fci.object = NULL; + fci.retval = &retval; + fci.param_count = 4; + fci.params = argv; + fci.named_params = NULL; + + ch->in_callback = 1; + error = zend_call_function(&fci, &t->fci_cache); + ch->in_callback = 0; + if (error == FAILURE) { + php_error_docref(NULL, E_WARNING, "Cannot call the CURLOPT_SSH_HOSTKEYFUNCTION"); + } else if (!Z_ISUNDEF(retval)) { + _php_curl_verify_handlers(ch, /* reporterror */ true); + if (Z_TYPE(retval) == IS_LONG) { + zend_long retval_long = Z_LVAL(retval); + if (retval_long == CURLKHMATCH_OK || retval_long == CURLKHMATCH_MISMATCH) { + rval = retval_long; + } else { + zend_throw_error(NULL, "The CURLOPT_SSH_HOSTKEYFUNCTION callback must return either CURLKHMATCH_OK or CURLKHMATCH_MISMATCH"); + } + } else { + zend_throw_error(NULL, "The CURLOPT_SSH_HOSTKEYFUNCTION callback must return either CURLKHMATCH_OK or CURLKHMATCH_MISMATCH"); + } + } + zval_ptr_dtor(&argv[0]); + zval_ptr_dtor(&argv[2]); + return rval; +} +#endif + /* {{{ curl_read */ static size_t curl_read(char *data, size_t size, size_t nmemb, void *ctx) { @@ -1031,6 +1092,9 @@ void init_curl_handle(php_curl *ch) ch->handlers.xferinfo = NULL; #endif ch->handlers.fnmatch = NULL; +#if LIBCURL_VERSION_NUM >= 0x075400 + ch->handlers.sshhostkey = NULL; +#endif ch->clone = emalloc(sizeof(uint32_t)); *ch->clone = 1; @@ -1155,6 +1219,17 @@ PHP_FUNCTION(curl_init) } /* }}} */ +static void _php_copy_callback(php_curl *ch, php_curl_callback **new_callback, php_curl_callback *source_callback, CURLoption option) +{ + if (source_callback) { + *new_callback = ecalloc(1, sizeof(php_curl_callback)); + if (!Z_ISUNDEF(source_callback->func_name)) { + ZVAL_COPY(&(*new_callback)->func_name, &source_callback->func_name); + } + curl_easy_setopt(ch->cp, option, (void *) ch); + } +} + void _php_setup_easy_copy_handlers(php_curl *ch, php_curl *source) { if (!Z_ISUNDEF(source->handlers.write->stream)) { @@ -1194,31 +1269,14 @@ void _php_setup_easy_copy_handlers(php_curl *ch, php_curl *source) curl_easy_setopt(ch->cp, CURLOPT_WRITEHEADER, (void *) ch); curl_easy_setopt(ch->cp, CURLOPT_DEBUGDATA, (void *) ch); - if (source->handlers.progress) { - ch->handlers.progress = ecalloc(1, sizeof(php_curl_callback)); - if (!Z_ISUNDEF(source->handlers.progress->func_name)) { - ZVAL_COPY(&ch->handlers.progress->func_name, &source->handlers.progress->func_name); - } - curl_easy_setopt(ch->cp, CURLOPT_PROGRESSDATA, (void *) ch); - } - + _php_copy_callback(ch, &ch->handlers.progress, source->handlers.progress, CURLOPT_PROGRESSDATA); #if LIBCURL_VERSION_NUM >= 0x072000 - if (source->handlers.xferinfo) { - ch->handlers.xferinfo = ecalloc(1, sizeof(php_curl_callback)); - if (!Z_ISUNDEF(source->handlers.xferinfo->func_name)) { - ZVAL_COPY(&ch->handlers.xferinfo->func_name, &source->handlers.xferinfo->func_name); - } - curl_easy_setopt(ch->cp, CURLOPT_XFERINFODATA, (void *) ch); - } + _php_copy_callback(ch, &ch->handlers.xferinfo, source->handlers.xferinfo, CURLOPT_XFERINFODATA); +#endif + _php_copy_callback(ch, &ch->handlers.fnmatch, source->handlers.fnmatch, CURLOPT_FNMATCH_DATA); +#if LIBCURL_VERSION_NUM >= 0x075400 + _php_copy_callback(ch, &ch->handlers.sshhostkey, source->handlers.sshhostkey, CURLOPT_SSH_HOSTKEYDATA); #endif - - if (source->handlers.fnmatch) { - ch->handlers.fnmatch = ecalloc(1, sizeof(php_curl_callback)); - if (!Z_ISUNDEF(source->handlers.fnmatch->func_name)) { - ZVAL_COPY(&ch->handlers.fnmatch->func_name, &source->handlers.fnmatch->func_name); - } - curl_easy_setopt(ch->cp, CURLOPT_FNMATCH_DATA, (void *) ch); - } ZVAL_COPY(&ch->private_data, &source->private_data); @@ -1784,6 +1842,16 @@ static zend_result _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue #endif #if LIBCURL_VERSION_NUM >= 0x075000 /* Available since 7.80.0 */ case CURLOPT_MAXLIFETIME_CONN: +#endif +#if LIBCURL_VERSION_NUM >= 0x075100 /* Available since 7.81.0 */ + case CURLOPT_MIME_OPTIONS: +#endif +#if LIBCURL_VERSION_NUM >= 0x075600 /* Available since 7.86.0 */ + case CURLOPT_WS_OPTIONS: +#endif +#if LIBCURL_VERSION_NUM >= 0x075700 /* Available since 7.87.0 */ + case CURLOPT_CA_CACHE_TIMEOUT: + case CURLOPT_QUICK_EXIT: #endif lval = zval_get_long(zvalue); if ((option == CURLOPT_PROTOCOLS || option == CURLOPT_REDIR_PROTOCOLS) && @@ -1898,10 +1966,21 @@ static zend_result _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue #endif #if LIBCURL_VERSION_NUM >= 0x075000 /* Available since 7.80.0 */ case CURLOPT_SSH_HOST_PUBLIC_KEY_SHA256: +#endif +#if LIBCURL_VERSION_NUM >= 0x075500 /* Available since 7.85.0 */ + case CURLOPT_PROTOCOLS_STR: + case CURLOPT_REDIR_PROTOCOLS_STR: #endif { zend_string *tmp_str; zend_string *str = zval_get_tmp_string(zvalue, &tmp_str); +#if LIBCURL_VERSION_NUM >= 0x075500 /* Available since 7.85.0 */ + if ((option == CURLOPT_PROTOCOLS_STR || option == CURLOPT_REDIR_PROTOCOLS_STR) && + (PG(open_basedir) && *PG(open_basedir)) && php_memnistr(ZSTR_VAL(str), "file", sizeof("file") - 1, ZSTR_VAL(str) + ZSTR_LEN(str)) != NULL) { + php_error_docref(NULL, E_WARNING, "The FILE protocol cannot be activated when an open_basedir is set"); + return FAILURE; + } +#endif zend_result ret = php_curl_option_str(ch, option, ZSTR_VAL(str), ZSTR_LEN(str)); zend_tmp_string_release(tmp_str); return ret; @@ -2197,6 +2276,20 @@ static zend_result _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue ZVAL_COPY(&ch->handlers.progress->func_name, zvalue); break; +#if LIBCURL_VERSION_NUM >= 0x075400 /* Available since 7.84.0 */ + case CURLOPT_SSH_HOSTKEYFUNCTION: + curl_easy_setopt(ch->cp, CURLOPT_SSH_HOSTKEYFUNCTION, curl_ssh_hostkeyfunction); + curl_easy_setopt(ch->cp, CURLOPT_SSH_HOSTKEYDATA, ch); + if (ch->handlers.sshhostkey == NULL) { + ch->handlers.sshhostkey = ecalloc(1, sizeof(php_curl_callback)); + } else if (!Z_ISUNDEF(ch->handlers.sshhostkey->func_name)) { + zval_ptr_dtor(&ch->handlers.sshhostkey->func_name); + ch->handlers.sshhostkey->fci_cache = empty_fcall_info_cache; + } + ZVAL_COPY(&ch->handlers.sshhostkey->func_name, zvalue); + break; +#endif + case CURLOPT_READFUNCTION: if (!Z_ISUNDEF(ch->handlers.read->func_name)) { zval_ptr_dtor(&ch->handlers.read->func_name); @@ -2653,6 +2746,14 @@ PHP_FUNCTION(curl_getinfo) if (curl_easy_getinfo(ch->cp, CURLINFO_EFFECTIVE_METHOD, &s_code) == CURLE_OK) { CAAS("effective_method", s_code); } +#endif +#if LIBCURL_VERSION_NUM >= 0x075400 /* Available since 7.84.0 */ + if (curl_easy_getinfo(ch->cp, CURLINFO_CAPATH, &s_code) == CURLE_OK) { + CAAS("capath", s_code); + } + if (curl_easy_getinfo(ch->cp, CURLINFO_CAINFO, &s_code) == CURLE_OK) { + CAAS("cainfo", s_code); + } #endif } else { switch (option) { @@ -2810,6 +2911,14 @@ PHP_FUNCTION(curl_close) } /* }}} */ +static void _php_curl_free_callback(php_curl_callback* callback) +{ + if (callback) { + zval_ptr_dtor(&callback->func_name); + efree(callback); + } +} + static void curl_free_obj(zend_object *object) { php_curl *ch = curl_from_obj(object); @@ -2874,22 +2983,14 @@ static void curl_free_obj(zend_object *object) efree(ch->handlers.write_header); efree(ch->handlers.read); - if (ch->handlers.progress) { - zval_ptr_dtor(&ch->handlers.progress->func_name); - efree(ch->handlers.progress); - } - + _php_curl_free_callback(ch->handlers.progress); #if LIBCURL_VERSION_NUM >= 0x072000 - if (ch->handlers.xferinfo) { - zval_ptr_dtor(&ch->handlers.xferinfo->func_name); - efree(ch->handlers.xferinfo); - } + _php_curl_free_callback(ch->handlers.xferinfo); +#endif + _php_curl_free_callback(ch->handlers.fnmatch); +#if LIBCURL_VERSION_NUM >= 0x075400 + _php_curl_free_callback(ch->handlers.sshhostkey); #endif - - if (ch->handlers.fnmatch) { - zval_ptr_dtor(&ch->handlers.fnmatch->func_name); - efree(ch->handlers.fnmatch); - } zval_ptr_dtor(&ch->postfields); zval_ptr_dtor(&ch->private_data); @@ -2971,6 +3072,14 @@ static void _php_curl_reset_handlers(php_curl *ch) efree(ch->handlers.fnmatch); ch->handlers.fnmatch = NULL; } + +#if LIBCURL_VERSION_NUM >= 0x075400 + if (ch->handlers.sshhostkey) { + zval_ptr_dtor(&ch->handlers.sshhostkey->func_name); + efree(ch->handlers.sshhostkey); + ch->handlers.sshhostkey = NULL; + } +#endif } /* }}} */ diff --git a/ext/curl/tests/curl_basic_026.phpt b/ext/curl/tests/curl_basic_026.phpt new file mode 100644 index 0000000000000..befe9c7e69c18 --- /dev/null +++ b/ext/curl/tests/curl_basic_026.phpt @@ -0,0 +1,27 @@ +--TEST-- +Test curl_getinfo() function with CURLOPT_* from curl >= 7.81.0 +--EXTENSIONS-- +curl +--SKIPIF-- += 7.81.0"); +} +?> +--FILE-- + +--EXPECT-- +bool(true) diff --git a/ext/curl/tests/curl_basic_027.phpt b/ext/curl/tests/curl_basic_027.phpt new file mode 100644 index 0000000000000..d4b408859c679 --- /dev/null +++ b/ext/curl/tests/curl_basic_027.phpt @@ -0,0 +1,37 @@ +--TEST-- +Test curl_getinfo() function with CURLINFO_* and CURLOPT_* from curl >= 7.84.0 +--EXTENSIONS-- +curl +--SKIPIF-- += 7.84.0"); +} +?> +--FILE-- + +--EXPECT-- +bool(true) +bool(true) +bool(true) diff --git a/ext/curl/tests/curl_basic_028.phpt b/ext/curl/tests/curl_basic_028.phpt new file mode 100644 index 0000000000000..f8e79f63ead5e --- /dev/null +++ b/ext/curl/tests/curl_basic_028.phpt @@ -0,0 +1,34 @@ +--TEST-- +Test curl_getinfo() function with CURLOPT_* from curl >= 7.85.0 +--INI-- +open_basedir=. +--EXTENSIONS-- +curl +--SKIPIF-- += 7.85.0"); +} +?> +--FILE-- + +--EXPECTF-- +Warning: curl_setopt(): The FILE protocol cannot be activated when an open_basedir is set in %s on line %d +bool(false) +bool(true) +bool(true) diff --git a/ext/curl/tests/curl_basic_029.phpt b/ext/curl/tests/curl_basic_029.phpt new file mode 100644 index 0000000000000..b43e5e3897dd6 --- /dev/null +++ b/ext/curl/tests/curl_basic_029.phpt @@ -0,0 +1,30 @@ +--TEST-- +Test curl_getinfo() function with CURLOPT_* from curl >= 7.86.0 +--EXTENSIONS-- +curl +--SKIPIF-- += 7.86.0"); +} +?> +--FILE-- + +--EXPECTF-- +bool(%s) +bool(%s) diff --git a/ext/curl/tests/curl_basic_030.phpt b/ext/curl/tests/curl_basic_030.phpt new file mode 100644 index 0000000000000..0beace9a7eac3 --- /dev/null +++ b/ext/curl/tests/curl_basic_030.phpt @@ -0,0 +1,29 @@ +--TEST-- +Test curl_getinfo() function with CURLOPT_* from curl >= 7.87.0 +--EXTENSIONS-- +curl +--SKIPIF-- += 7.87.0"); +} +?> +--FILE-- + +--EXPECT-- +bool(true) +bool(true)