From 68d08ca5469f1672d07eaab1cac5a02b30f8f067 Mon Sep 17 00:00:00 2001 From: Sjoerd Langkemper Date: Tue, 18 Aug 2026 19:07:26 +0000 Subject: [PATCH] ext/curl: handle CURLOPT_POSTREDIR as normal long 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. --- UPGRADING | 3 +++ ext/curl/interface.c | 6 +----- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/UPGRADING b/UPGRADING index a4df23352639..875e05554566 100644 --- a/UPGRADING +++ b/UPGRADING @@ -28,6 +28,9 @@ PHP 8.7 UPGRADE NOTES converted to an int. . Nested arrays in CURLOPT_POSTFIELDS now throw a TypeError, instead of being silently converted to the string "Array". + . Negative values for CURLOPT_POSTREDIR are now rejected, making + curl_setopt() return false, instead of being silently interpreted as a + combination of redirect types. - PDO: . PDOStatement::bindColumn() now throws a ValueError when the column name is diff --git a/ext/curl/interface.c b/ext/curl/interface.c index 44724428beb1..94618e4bf74d 100644 --- a/ext/curl/interface.c +++ b/ext/curl/interface.c @@ -1892,6 +1892,7 @@ static zend_result _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue case CURLOPT_TCP_KEEPCNT: #endif case CURLOPT_FOLLOWLOCATION: + case CURLOPT_POSTREDIR: lval = zval_get_long(zvalue); if ((option == CURLOPT_PROTOCOLS || option == CURLOPT_REDIR_PROTOCOLS) && (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 error = curl_easy_setopt(ch->cp, option, (curl_off_t)lval); break; - case CURLOPT_POSTREDIR: - lval = zval_get_long(zvalue); - error = curl_easy_setopt(ch->cp, CURLOPT_POSTREDIR, (long) (lval & CURL_REDIR_POST_ALL)); - break; - /* the following options deal with files, therefore the open_basedir check * is required. */