Skip to content

Commit 0aaea39

Browse files
committed
Merge branch 'PHP-7.1'
* PHP-7.1: Interpretation of curl_setopt values for boolean parameters
2 parents 16758a3 + a49675f commit 0aaea39

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed

ext/curl/interface.c

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2315,8 +2315,7 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue) /* {{{
23152315
error = curl_easy_setopt(ch->cp, option, lval);
23162316
break;
23172317
case CURLOPT_SAFE_UPLOAD:
2318-
lval = zval_get_long(zvalue);
2319-
if (lval == 0) {
2318+
if (!zend_is_true(zvalue)) {
23202319
php_error_docref(NULL, E_WARNING, "Disabling safe uploads is no longer supported");
23212320
return FAILURE;
23222321
}
@@ -2652,13 +2651,11 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue) /* {{{
26522651
break;
26532652

26542653
case CURLOPT_FOLLOWLOCATION:
2655-
lval = zval_get_long(zvalue);
2654+
lval = zend_is_true(zvalue);
26562655
#if LIBCURL_VERSION_NUM < 0x071304
2657-
if (PG(open_basedir) && *PG(open_basedir)) {
2658-
if (lval != 0) {
2659-
php_error_docref(NULL, E_WARNING, "CURLOPT_FOLLOWLOCATION cannot be activated when an open_basedir is set");
2660-
return FAILURE;
2661-
}
2656+
if (lval && PG(open_basedir) && *PG(open_basedir)) {
2657+
php_error_docref(NULL, E_WARNING, "CURLOPT_FOLLOWLOCATION cannot be activated when an open_basedir is set");
2658+
return FAILURE;
26622659
}
26632660
#endif
26642661
error = curl_easy_setopt(ch->cp, option, lval);
@@ -2814,8 +2811,7 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue) /* {{{
28142811
break;
28152812

28162813
case CURLOPT_RETURNTRANSFER:
2817-
lval = zval_get_long(zvalue);
2818-
if (lval) {
2814+
if (zend_is_true(zvalue)) {
28192815
ch->handlers->write->method = PHP_CURL_RETURN;
28202816
} else {
28212817
ch->handlers->write->method = PHP_CURL_STDOUT;
@@ -2891,8 +2887,7 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue) /* {{{
28912887
}
28922888

28932889
case CURLINFO_HEADER_OUT:
2894-
lval = zval_get_long(zvalue);
2895-
if (lval == 1) {
2890+
if (zend_is_true(zvalue)) {
28962891
curl_easy_setopt(ch->cp, CURLOPT_DEBUGFUNCTION, curl_debug);
28972892
curl_easy_setopt(ch->cp, CURLOPT_DEBUGDATA, (void *)ch);
28982893
curl_easy_setopt(ch->cp, CURLOPT_VERBOSE, 1);

0 commit comments

Comments
 (0)