Skip to content

Commit 16ebaff

Browse files
authored
ext/curl: handle CURLOPT_POSTREDIR as normal long (#23357)
Don't treat CURLOPT_POSTREDIR specially. Just pass its value to curl directly. There is no need to do `& CURL_REDIR_POST_ALL`. Curl already does this internally. The only functional change is that negative numbers will now raise an error, which seems reasonable.
1 parent 66c0f52 commit 16ebaff

2 files changed

Lines changed: 4 additions & 5 deletions

File tree

‎UPGRADING‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ PHP 8.7 UPGRADE NOTES
2828
converted to an int.
2929
. Nested arrays in CURLOPT_POSTFIELDS now throw a TypeError, instead of being
3030
silently converted to the string "Array".
31+
. Negative values for CURLOPT_POSTREDIR are now rejected, making
32+
curl_setopt() return false, instead of being silently interpreted as a
33+
combination of redirect types.
3134

3235
- PDO:
3336
. PDOStatement::bindColumn() now throws a ValueError when the column name is

‎ext/curl/interface.c‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1892,6 +1892,7 @@ static zend_result _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue
18921892
case CURLOPT_TCP_KEEPCNT:
18931893
#endif
18941894
case CURLOPT_FOLLOWLOCATION:
1895+
case CURLOPT_POSTREDIR:
18951896
lval = zval_get_long(zvalue);
18961897
if ((option == CURLOPT_PROTOCOLS || option == CURLOPT_REDIR_PROTOCOLS) &&
18971898
(PG(open_basedir) && *PG(open_basedir)) && (lval & CURLPROTO_FILE)) {
@@ -2259,11 +2260,6 @@ static zend_result _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue
22592260
error = curl_easy_setopt(ch->cp, option, (curl_off_t)lval);
22602261
break;
22612262

2262-
case CURLOPT_POSTREDIR:
2263-
lval = zval_get_long(zvalue);
2264-
error = curl_easy_setopt(ch->cp, CURLOPT_POSTREDIR, (long) (lval & CURL_REDIR_POST_ALL));
2265-
break;
2266-
22672263
/* the following options deal with files, therefore the open_basedir check
22682264
* is required.
22692265
*/

0 commit comments

Comments
 (0)