mirror of
https://github.com/php/php-src.git
synced 2026-03-24 00:02:20 +01:00
Add new curl constants from curl until (including) 7.87 (#10459)
Fixes GH-10454
This commit is contained in:
4
NEWS
4
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)
|
||||
|
||||
22
UPGRADING
22
UPGRADING
@@ -195,6 +195,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
|
||||
@@ -361,6 +366,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).
|
||||
|
||||
@@ -941,6 +941,18 @@ const CURLINFO_TOTAL_TIME = UNKNOWN;
|
||||
*/
|
||||
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 @@ const CURL_VERSION_CURLDEBUG = UNKNOWN;
|
||||
* @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_MAXLIFETIME_CONN = UNKNOWN;
|
||||
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
|
||||
|
||||
39
ext/curl/curl_arginfo.h
generated
39
ext/curl/curl_arginfo.h
generated
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
|
||||
27
ext/curl/tests/curl_basic_026.phpt
Normal file
27
ext/curl/tests/curl_basic_026.phpt
Normal file
@@ -0,0 +1,27 @@
|
||||
--TEST--
|
||||
Test curl_getinfo() function with CURLOPT_* from curl >= 7.81.0
|
||||
--EXTENSIONS--
|
||||
curl
|
||||
--SKIPIF--
|
||||
<?php $curl_version = curl_version();
|
||||
if ($curl_version['version_number'] < 0x075100) {
|
||||
exit("skip: test works only with curl >= 7.81.0");
|
||||
}
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
include 'server.inc';
|
||||
|
||||
$ch = curl_init();
|
||||
|
||||
$host = curl_cli_server_start();
|
||||
|
||||
$url = "{$host}/get.inc?test=";
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||
var_dump(curl_setopt($ch, CURLOPT_MIME_OPTIONS, CURLMIMEOPT_FORMESCAPE));
|
||||
curl_exec($ch);
|
||||
curl_close($ch);
|
||||
?>
|
||||
--EXPECT--
|
||||
bool(true)
|
||||
37
ext/curl/tests/curl_basic_027.phpt
Normal file
37
ext/curl/tests/curl_basic_027.phpt
Normal file
@@ -0,0 +1,37 @@
|
||||
--TEST--
|
||||
Test curl_getinfo() function with CURLINFO_* and CURLOPT_* from curl >= 7.84.0
|
||||
--EXTENSIONS--
|
||||
curl
|
||||
--SKIPIF--
|
||||
<?php $curl_version = curl_version();
|
||||
if ($curl_version['version_number'] < 0x075400) {
|
||||
exit("skip: test works only with curl >= 7.84.0");
|
||||
}
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
include 'server.inc';
|
||||
|
||||
$ch = curl_init();
|
||||
var_dump(array_key_exists('capath', curl_getinfo($ch)));
|
||||
var_dump(array_key_exists('cainfo', curl_getinfo($ch)));
|
||||
|
||||
$host = curl_cli_server_start();
|
||||
|
||||
$url = "{$host}/get.inc?test=";
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||
var_dump(curl_setopt($ch, CURLOPT_SSH_HOSTKEYFUNCTION, function ($ch, $keytype, $key, $keylen) {
|
||||
// Can't really trigger this in a test
|
||||
var_dump($keytype);
|
||||
var_dump($key);
|
||||
var_dump($keylen);
|
||||
return CURLKHMATCH_OK;
|
||||
}));
|
||||
curl_exec($ch);
|
||||
curl_close($ch);
|
||||
?>
|
||||
--EXPECT--
|
||||
bool(true)
|
||||
bool(true)
|
||||
bool(true)
|
||||
34
ext/curl/tests/curl_basic_028.phpt
Normal file
34
ext/curl/tests/curl_basic_028.phpt
Normal file
@@ -0,0 +1,34 @@
|
||||
--TEST--
|
||||
Test curl_getinfo() function with CURLOPT_* from curl >= 7.85.0
|
||||
--INI--
|
||||
open_basedir=.
|
||||
--EXTENSIONS--
|
||||
curl
|
||||
--SKIPIF--
|
||||
<?php $curl_version = curl_version();
|
||||
if ($curl_version['version_number'] < 0x075500) {
|
||||
exit("skip: test works only with curl >= 7.85.0");
|
||||
}
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
include 'server.inc';
|
||||
|
||||
$ch = curl_init();
|
||||
|
||||
$host = curl_cli_server_start();
|
||||
|
||||
$url = "{$host}/get.inc?test=";
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||
var_dump(curl_setopt($ch, CURLOPT_PROTOCOLS_STR, "FilE,DICT"));
|
||||
var_dump(curl_setopt($ch, CURLOPT_PROTOCOLS_STR, "DICT"));
|
||||
var_dump(curl_setopt($ch, CURLOPT_REDIR_PROTOCOLS_STR, "HTTP"));
|
||||
curl_exec($ch);
|
||||
curl_close($ch);
|
||||
?>
|
||||
--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)
|
||||
30
ext/curl/tests/curl_basic_029.phpt
Normal file
30
ext/curl/tests/curl_basic_029.phpt
Normal file
@@ -0,0 +1,30 @@
|
||||
--TEST--
|
||||
Test curl_getinfo() function with CURLOPT_* from curl >= 7.86.0
|
||||
--EXTENSIONS--
|
||||
curl
|
||||
--SKIPIF--
|
||||
<?php $curl_version = curl_version();
|
||||
if ($curl_version['version_number'] < 0x075600) {
|
||||
exit("skip: test works only with curl >= 7.86.0");
|
||||
}
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
include 'server.inc';
|
||||
|
||||
$ch = curl_init();
|
||||
|
||||
$host = curl_cli_server_start();
|
||||
|
||||
$url = "{$host}/get.inc?test=";
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||
// Return value depends on if support is enabled or not
|
||||
var_dump(curl_setopt($ch, CURLOPT_WS_OPTIONS, 0));
|
||||
var_dump(curl_setopt($ch, CURLOPT_WS_OPTIONS, CURLWS_RAW_MODE));
|
||||
curl_exec($ch);
|
||||
curl_close($ch);
|
||||
?>
|
||||
--EXPECTF--
|
||||
bool(%s)
|
||||
bool(%s)
|
||||
29
ext/curl/tests/curl_basic_030.phpt
Normal file
29
ext/curl/tests/curl_basic_030.phpt
Normal file
@@ -0,0 +1,29 @@
|
||||
--TEST--
|
||||
Test curl_getinfo() function with CURLOPT_* from curl >= 7.87.0
|
||||
--EXTENSIONS--
|
||||
curl
|
||||
--SKIPIF--
|
||||
<?php $curl_version = curl_version();
|
||||
if ($curl_version['version_number'] < 0x075700) {
|
||||
exit("skip: test works only with curl >= 7.87.0");
|
||||
}
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
include 'server.inc';
|
||||
|
||||
$ch = curl_init();
|
||||
|
||||
$host = curl_cli_server_start();
|
||||
|
||||
$url = "{$host}/get.inc?test=";
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||
var_dump(curl_setopt($ch, CURLOPT_CA_CACHE_TIMEOUT, 1));
|
||||
var_dump(curl_setopt($ch, CURLOPT_QUICK_EXIT, 1000));
|
||||
curl_exec($ch);
|
||||
curl_close($ch);
|
||||
?>
|
||||
--EXPECT--
|
||||
bool(true)
|
||||
bool(true)
|
||||
Reference in New Issue
Block a user