[php-src] master: ext/curl: handle CURLOPT_POSTREDIR as normal long (#23357)
| From: | Sjoerd Langkemper via GitHub | Date: | Thu, 12 Nov 2026 07:11:14 +0000 |
| Subject: | [php-src] master: ext/curl: handle CURLOPT_POSTREDIR as normal long (#23357) | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-143618@lists.php.net to get a copy of this message | ||
Author: Sjoerd Langkemper (Sjord)
Committer: GitHub (web-flow)
Pusher: kocsismate
Date: 2026-11-12T08:11:11+01:00
Commit: https://github.com/php/php-src/commit/16ebafff9afada536d09ea3a11d35b4b9ea86827
Raw diff: https://github.com/php/php-src/commit/16ebafff9afada536d09ea3a11d35b4b9ea86827.diff
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.
Changed paths:
M UPGRADING
M ext/curl/interface.c
Diff:
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.
*/