Commit eeed17c972 for wordpress.org
commit eeed17c9728c78265875d2474cb9f4b6c498a8e2
Author: desrosj <desrosj@git.wordpress.org>
Date: Tue Nov 10 15:14:05 2026 +0000
External Libraries: Update Requests library to version 2.0.21.
This update primarily includes a PHP 8.6 compatibility fix. The only other changes found in 2.0.18-2.0.21 are to the root certificate bundle included in the library, which are skipped as WordPress manages its own certificate bundle.
Props davidbaumwald.
Fixes #66647.
Built from https://develop.svn.wordpress.org/trunk@65383
git-svn-id: http://core.svn.wordpress.org/trunk@64522 1a063a9b-81f0-0310-95a4-ce76da25c4cd
diff --git a/wp-includes/Requests/src/Cookie.php b/wp-includes/Requests/src/Cookie.php
index 2cc821d647..da92832111 100644
--- a/wp-includes/Requests/src/Cookie.php
+++ b/wp-includes/Requests/src/Cookie.php
@@ -12,6 +12,7 @@ use WpOrg\Requests\Iri;
use WpOrg\Requests\Response\Headers;
use WpOrg\Requests\Utility\CaseInsensitiveDictionary;
use WpOrg\Requests\Utility\InputValidator;
+use WpOrg\Requests\Utility\Trim;
/**
* Cookie storage object
@@ -439,8 +440,8 @@ class Cookie {
list($name, $value) = explode('=', $kvparts, 2);
}
- $name = trim($name);
- $value = trim($value);
+ $name = trim($name, Trim::WHITESPACE_CHARS_NO_FF);
+ $value = trim($value, Trim::WHITESPACE_CHARS_NO_FF);
// Attribute keys are handled case-insensitively
$attributes = new CaseInsensitiveDictionary();
@@ -452,10 +453,10 @@ class Cookie {
$part_value = true;
} else {
list($part_key, $part_value) = explode('=', $part, 2);
- $part_value = trim($part_value);
+ $part_value = trim($part_value, Trim::WHITESPACE_CHARS_NO_FF);
}
- $part_key = trim($part_key);
+ $part_key = trim($part_key, Trim::WHITESPACE_CHARS_NO_FF);
$attributes[$part_key] = $part_value;
}
}
diff --git a/wp-includes/Requests/src/Exception/Transport/Curl.php b/wp-includes/Requests/src/Exception/Transport/Curl.php
index 4c0294d748..1c723c8247 100644
--- a/wp-includes/Requests/src/Exception/Transport/Curl.php
+++ b/wp-includes/Requests/src/Exception/Transport/Curl.php
@@ -76,5 +76,4 @@ final class Curl extends Transport {
public function getReason() {
return $this->reason;
}
-
}
diff --git a/wp-includes/Requests/src/IdnaEncoder.php b/wp-includes/Requests/src/IdnaEncoder.php
index 9f235527bf..15273a2b8a 100644
--- a/wp-includes/Requests/src/IdnaEncoder.php
+++ b/wp-includes/Requests/src/IdnaEncoder.php
@@ -212,7 +212,7 @@ class IdnaEncoder {
$character |= ($value & 0x3F) << ($remaining * 6);
}
- $position--;
+ --$position;
}
if (// Non-shortest form sequences are invalid
@@ -270,7 +270,7 @@ class IdnaEncoder {
// Character is valid ASCII
// TODO: this should also check if it's valid for a URL
$output .= chr($char);
- $h++;
+ ++$h;
// Check if the character is non-ASCII, but below initial n
// This never occurs for Punycode, so ignore in coverage
@@ -307,7 +307,7 @@ class IdnaEncoder {
$c = $codepoints[$num];
// if c < n then increment delta, fail on overflow
if ($c < $n) {
- $delta++;
+ ++$delta;
} elseif ($c === $n) { // if c == n then begin
// let q = delta
$q = $delta;
@@ -341,12 +341,12 @@ class IdnaEncoder {
// let delta = 0
$delta = 0;
// increment h
- $h++;
+ ++$h;
} // end
} // end
// increment delta and n
- $delta++;
- $n++;
+ ++$delta;
+ ++$n;
} // end
return $output;
diff --git a/wp-includes/Requests/src/Ipv6.php b/wp-includes/Requests/src/Ipv6.php
index bcdd63649f..d9b0a144f4 100644
--- a/wp-includes/Requests/src/Ipv6.php
+++ b/wp-includes/Requests/src/Ipv6.php
@@ -56,7 +56,7 @@ final class Ipv6 {
$c2 = ($ip2 === '') ? -1 : substr_count($ip2, ':');
if (strpos($ip2, '.') !== false) {
- $c2++;
+ ++$c2;
}
if ($c1 === -1 && $c2 === -1) {
diff --git a/wp-includes/Requests/src/Requests.php b/wp-includes/Requests/src/Requests.php
index 556b06e0a3..bd9f1e0ced 100644
--- a/wp-includes/Requests/src/Requests.php
+++ b/wp-includes/Requests/src/Requests.php
@@ -24,6 +24,7 @@ use WpOrg\Requests\Response;
use WpOrg\Requests\Transport\Curl;
use WpOrg\Requests\Transport\Fsockopen;
use WpOrg\Requests\Utility\InputValidator;
+use WpOrg\Requests\Utility\Trim;
/**
* Requests for PHP
@@ -35,6 +36,13 @@ use WpOrg\Requests\Utility\InputValidator;
* @package Requests
*/
class Requests {
+ /**
+ * Current version of Requests
+ *
+ * @var string
+ */
+ const VERSION = '2.0.21';
+
/**
* POST method
*
@@ -143,13 +151,6 @@ class Requests {
Fsockopen::class => Fsockopen::class,
];
- /**
- * Current version of Requests
- *
- * @var string
- */
- const VERSION = '2.0.17';
-
/**
* Selected transport name
*
@@ -763,7 +764,7 @@ class Requests {
foreach ($headers as $header) {
list($key, $value) = explode(':', $header, 2);
- $value = trim($value);
+ $value = trim($value, Trim::WHITESPACE_CHARS_NO_FF);
preg_replace('#(\s+)#i', ' ', $value);
$return->headers[$key] = $value;
}
@@ -790,7 +791,7 @@ class Requests {
$options['type'] = self::GET;
}
- $options['redirected']++;
+ ++$options['redirected'];
$location = $return->headers['location'];
if (strpos($location, 'http://') !== 0 && strpos($location, 'https://') !== 0) {
// relative redirect, for compatibility make it absolute
@@ -852,7 +853,7 @@ class Requests {
* @return string Decoded body
*/
protected static function decode_chunked($data) {
- if (!preg_match('/^([0-9a-f]+)(?:;(?:[\w-]*)(?:=(?:(?:[\w-]*)*|"(?:[^\r\n])*"))?)*\r\n/i', trim($data))) {
+ if (!preg_match('/^([0-9a-f]+)(?:;(?:[\w-]*)(?:=(?:(?:[\w-]*)*|"(?:[^\r\n])*"))?)*\r\n/i', trim($data, Trim::WHITESPACE_CHARS_NO_FF))) {
return $data;
}
@@ -866,7 +867,7 @@ class Requests {
return $data;
}
- $length = hexdec(trim($matches[1]));
+ $length = hexdec(trim($matches[1], Trim::WHITESPACE_CHARS_NO_FF));
if ($length === 0) {
// Ignore trailer headers
return $decoded;
@@ -876,7 +877,7 @@ class Requests {
$decoded .= substr($encoded, $chunk_length, $length);
$encoded = substr($encoded, $chunk_length + $length + 2);
- if (trim($encoded) === '0' || empty($encoded)) {
+ if (trim($encoded, Trim::WHITESPACE_CHARS_NO_FF) === '0' || empty($encoded)) {
return $decoded;
}
}
@@ -923,7 +924,7 @@ class Requests {
throw InvalidArgument::create(1, '$data', 'string', gettype($data));
}
- if (trim($data) === '') {
+ if (trim($data, Trim::WHITESPACE_CHARS_NO_FF) === '') {
// Empty body does not need further processing.
return $data;
}
@@ -990,7 +991,7 @@ class Requests {
throw InvalidArgument::create(1, '$gz_data', 'string', gettype($gz_data));
}
- if (trim($gz_data) === '') {
+ if (trim($gz_data, Trim::WHITESPACE_CHARS_NO_FF) === '') {
return false;
}
diff --git a/wp-includes/Requests/src/Response.php b/wp-includes/Requests/src/Response.php
index 86a0438bad..c1e7eff918 100644
--- a/wp-includes/Requests/src/Response.php
+++ b/wp-includes/Requests/src/Response.php
@@ -108,7 +108,7 @@ class Response {
*/
public function is_redirect() {
$code = $this->status_code;
- return in_array($code, [300, 301, 302, 303, 307], true) || $code > 307 && $code < 400;
+ return in_array($code, [300, 301, 302, 303, 307], true) || ($code > 307 && $code < 400);
}
/**
diff --git a/wp-includes/Requests/src/Session.php b/wp-includes/Requests/src/Session.php
index 0a63279022..0059131491 100644
--- a/wp-includes/Requests/src/Session.php
+++ b/wp-includes/Requests/src/Session.php
@@ -227,7 +227,13 @@ class Session {
* @throws \WpOrg\Requests\Exception On invalid URLs (`nonhttp`)
*/
public function request($url, $headers = [], $data = [], $type = Requests::GET, $options = []) {
- $request = $this->merge_request(compact('url', 'headers', 'data', 'options'));
+ $request = [
+ 'url' => $url,
+ 'headers' => $headers,
+ 'data' => $data,
+ 'options' => $options,
+ ];
+ $request = $this->merge_request($request);
return Requests::request($request['url'], $request['headers'], $request['data'], $type, $request['options']);
}
diff --git a/wp-includes/Requests/src/Ssl.php b/wp-includes/Requests/src/Ssl.php
index 99da11d8f7..bf0860b7e0 100644
--- a/wp-includes/Requests/src/Ssl.php
+++ b/wp-includes/Requests/src/Ssl.php
@@ -9,6 +9,7 @@ namespace WpOrg\Requests;
use WpOrg\Requests\Exception\InvalidArgument;
use WpOrg\Requests\Utility\InputValidator;
+use WpOrg\Requests\Utility\Trim;
/**
* SSL utilities for Requests
@@ -47,7 +48,7 @@ final class Ssl {
if (!empty($cert['extensions']['subjectAltName'])) {
$altnames = explode(',', $cert['extensions']['subjectAltName']);
foreach ($altnames as $altname) {
- $altname = trim($altname);
+ $altname = trim($altname, Trim::WHITESPACE_CHARS_NO_FF);
if (strpos($altname, 'DNS:') !== 0) {
continue;
}
@@ -55,7 +56,7 @@ final class Ssl {
$has_dns_alt = true;
// Strip the 'DNS:' prefix and trim whitespace
- $altname = trim(substr($altname, 4));
+ $altname = trim(substr($altname, 4), Trim::WHITESPACE_CHARS_NO_FF);
// Check for a match
if (self::match_domain($host, $altname) === true) {
diff --git a/wp-includes/Requests/src/Transport/Curl.php b/wp-includes/Requests/src/Transport/Curl.php
index 49522f5f9d..3a6c5af7d4 100644
--- a/wp-includes/Requests/src/Transport/Curl.php
+++ b/wp-includes/Requests/src/Transport/Curl.php
@@ -16,6 +16,7 @@ use WpOrg\Requests\Exception\Transport\Curl as CurlException;
use WpOrg\Requests\Requests;
use WpOrg\Requests\Transport;
use WpOrg\Requests\Utility\InputValidator;
+use WpOrg\Requests\Utility\Trim;
/**
* cURL HTTP transport
@@ -316,7 +317,7 @@ final class Curl implements Transport {
$options['hooks']->dispatch('multiple.request.complete', [&$responses[$key], $key]);
}
- $completed++;
+ ++$completed;
}
} while ($active || $completed < $subrequestcount);
@@ -480,7 +481,7 @@ final class Curl implements Transport {
if ($options['filename'] !== false && $this->stream_handle) {
fclose($this->stream_handle);
- $this->headers = trim($this->headers);
+ $this->headers = trim($this->headers, Trim::WHITESPACE_CHARS_NO_FF);
} else {
$this->headers .= $response;
}
diff --git a/wp-includes/Requests/src/Transport/Fsockopen.php b/wp-includes/Requests/src/Transport/Fsockopen.php
index c8e657a014..63310eb81b 100644
--- a/wp-includes/Requests/src/Transport/Fsockopen.php
+++ b/wp-includes/Requests/src/Transport/Fsockopen.php
@@ -16,6 +16,7 @@ use WpOrg\Requests\Ssl;
use WpOrg\Requests\Transport;
use WpOrg\Requests\Utility\CaseInsensitiveDictionary;
use WpOrg\Requests\Utility\InputValidator;
+use WpOrg\Requests\Utility\Trim;
/**
* fsockopen HTTP transport
@@ -183,7 +184,7 @@ final class Fsockopen implements Transport {
if (!$socket) {
if ($errno === 0) {
// Connection issue
- throw new Exception(rtrim($this->connect_error), 'fsockopen.connect_error');
+ throw new Exception(rtrim($this->connect_error, Trim::WHITESPACE_CHARS), 'fsockopen.connect_error');
}
throw new Exception($errstr, 'fsockopenerror', null, $errno);
@@ -486,7 +487,7 @@ final class Fsockopen implements Transport {
// If we don't have SSL options, then we couldn't make the connection at
// all
if (empty($meta) || empty($meta['ssl']) || empty($meta['ssl']['peer_certificate'])) {
- throw new Exception(rtrim($this->connect_error), 'ssl.connect_error');
+ throw new Exception(rtrim($this->connect_error, Trim::WHITESPACE_CHARS), 'ssl.connect_error');
}
$cert = openssl_x509_parse($meta['ssl']['peer_certificate']);
diff --git a/wp-includes/version.php b/wp-includes/version.php
index 2c0737c7bd..9ae8c2588d 100644
--- a/wp-includes/version.php
+++ b/wp-includes/version.php
@@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
-$wp_version = '7.2-beta4-65382';
+$wp_version = '7.2-beta4-65383';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.