mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-12 04:40:26 +00:00
External Libraries: Update the SimplePie library to version 1.5.7.
This version shows significant improvements in the compatibility of SimplePie with PHP 8.0, 8.1, and even contains an initial PHP 8.2 fix. The release also contains a number of other bug fixes. Release notes: https://github.com/simplepie/simplepie/releases/tag/1.5.7 For a full list of changes in this update, see the SimplePie GitHub: https://github.com/simplepie/simplepie/compare/1.5.6...1.5.7 Follow-up to [47733], [49176]. Props jrf, SergeyBiryukov. Fixes #54659. git-svn-id: https://develop.svn.wordpress.org/trunk@52393 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -152,7 +152,7 @@ class SimplePie_Cache_Redis implements SimplePie_Cache_Base {
|
||||
if ($data !== false) {
|
||||
$return = $this->cache->set($this->name, $data);
|
||||
if ($this->options['expire']) {
|
||||
return $this->cache->expire($this->name, $this->ttl);
|
||||
return $this->cache->expire($this->name, $this->options['expire']);
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
@@ -1152,7 +1152,12 @@ class SimplePie_Enclosure
|
||||
// If we encounter an unsupported mime-type, check the file extension and guess intelligently.
|
||||
if (!in_array($type, array_merge($types_flash, $types_fmedia, $types_quicktime, $types_wmedia, $types_mp3)))
|
||||
{
|
||||
switch (strtolower($this->get_extension()))
|
||||
$extension = $this->get_extension();
|
||||
if ($extension === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
switch (strtolower($extension))
|
||||
{
|
||||
// Audio mime-types
|
||||
case 'aac':
|
||||
|
||||
@@ -106,7 +106,7 @@ class SimplePie_File
|
||||
curl_setopt($fp, CURLOPT_FAILONERROR, 1);
|
||||
curl_setopt($fp, CURLOPT_TIMEOUT, $timeout);
|
||||
curl_setopt($fp, CURLOPT_CONNECTTIMEOUT, $timeout);
|
||||
curl_setopt($fp, CURLOPT_REFERER, $url);
|
||||
curl_setopt($fp, CURLOPT_REFERER, SimplePie_Misc::url_remove_credentials($url));
|
||||
curl_setopt($fp, CURLOPT_USERAGENT, $useragent);
|
||||
curl_setopt($fp, CURLOPT_HTTPHEADER, $headers2);
|
||||
foreach ($curl_options as $curl_param => $curl_value) {
|
||||
@@ -119,6 +119,7 @@ class SimplePie_File
|
||||
curl_setopt($fp, CURLOPT_ENCODING, 'none');
|
||||
$this->headers = curl_exec($fp);
|
||||
}
|
||||
$this->status_code = curl_getinfo($fp, CURLINFO_HTTP_CODE);
|
||||
if (curl_errno($fp))
|
||||
{
|
||||
$this->error = 'cURL error ' . curl_errno($fp) . ': ' . curl_error($fp);
|
||||
|
||||
@@ -507,11 +507,13 @@ class SimplePie_HTTP_Parser
|
||||
{
|
||||
$data = explode("\r\n\r\n", $headers, $count);
|
||||
$data = array_pop($data);
|
||||
if (false !== stripos($data, "HTTP/1.0 200 Connection established\r\n\r\n")) {
|
||||
$data = str_ireplace("HTTP/1.0 200 Connection established\r\n\r\n", '', $data);
|
||||
if (false !== stripos($data, "HTTP/1.0 200 Connection established\r\n")) {
|
||||
$exploded = explode("\r\n\r\n", $data, 2);
|
||||
$data = end($exploded);
|
||||
}
|
||||
if (false !== stripos($data, "HTTP/1.1 200 Connection established\r\n\r\n")) {
|
||||
$data = str_ireplace("HTTP/1.1 200 Connection established\r\n\r\n", '', $data);
|
||||
if (false !== stripos($data, "HTTP/1.1 200 Connection established\r\n")) {
|
||||
$exploded = explode("\r\n\r\n", $data, 2);
|
||||
$data = end($exploded);
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
@@ -1803,7 +1803,7 @@ class SimplePie_Item
|
||||
}
|
||||
if (isset($content['attribs']['']['fileSize']))
|
||||
{
|
||||
$length = ceil($content['attribs']['']['fileSize']);
|
||||
$length = intval($content['attribs']['']['fileSize']);
|
||||
}
|
||||
if (isset($content['attribs']['']['medium']))
|
||||
{
|
||||
@@ -2425,7 +2425,7 @@ class SimplePie_Item
|
||||
}
|
||||
if (isset($content['attribs']['']['fileSize']))
|
||||
{
|
||||
$length = ceil($content['attribs']['']['fileSize']);
|
||||
$length = intval($content['attribs']['']['fileSize']);
|
||||
}
|
||||
if (isset($content['attribs']['']['medium']))
|
||||
{
|
||||
@@ -2790,7 +2790,7 @@ class SimplePie_Item
|
||||
}
|
||||
if (isset($link['attribs']['']['length']))
|
||||
{
|
||||
$length = ceil($link['attribs']['']['length']);
|
||||
$length = intval($link['attribs']['']['length']);
|
||||
}
|
||||
if (isset($link['attribs']['']['title']))
|
||||
{
|
||||
@@ -2833,7 +2833,7 @@ class SimplePie_Item
|
||||
}
|
||||
if (isset($link['attribs']['']['length']))
|
||||
{
|
||||
$length = ceil($link['attribs']['']['length']);
|
||||
$length = intval($link['attribs']['']['length']);
|
||||
}
|
||||
|
||||
// Since we don't have group or content for these, we'll just pass the '*_parent' variables directly to the constructor
|
||||
@@ -2862,13 +2862,14 @@ class SimplePie_Item
|
||||
$width = null;
|
||||
|
||||
$url = $this->sanitize($enclosure[0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($enclosure[0]));
|
||||
$url = $this->feed->sanitize->https_url($url);
|
||||
if (isset($enclosure[0]['attribs']['']['type']))
|
||||
{
|
||||
$type = $this->sanitize($enclosure[0]['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
|
||||
}
|
||||
if (isset($enclosure[0]['attribs']['']['length']))
|
||||
{
|
||||
$length = ceil($enclosure[0]['attribs']['']['length']);
|
||||
$length = intval($enclosure[0]['attribs']['']['length']);
|
||||
}
|
||||
|
||||
// Since we don't have group or content for these, we'll just pass the '*_parent' variables directly to the constructor
|
||||
|
||||
@@ -64,6 +64,7 @@ class SimplePie_Locator
|
||||
var $max_checked_feeds = 10;
|
||||
var $force_fsockopen = false;
|
||||
var $curl_options = array();
|
||||
var $dom;
|
||||
protected $registry;
|
||||
|
||||
public function __construct(SimplePie_File $file, $timeout = 10, $useragent = null, $max_checked_feeds = 10, $force_fsockopen = false, $curl_options = array())
|
||||
@@ -75,12 +76,19 @@ class SimplePie_Locator
|
||||
$this->force_fsockopen = $force_fsockopen;
|
||||
$this->curl_options = $curl_options;
|
||||
|
||||
if (class_exists('DOMDocument'))
|
||||
if (class_exists('DOMDocument') && $this->file->body != '')
|
||||
{
|
||||
$this->dom = new DOMDocument();
|
||||
|
||||
set_error_handler(array('SimplePie_Misc', 'silence_errors'));
|
||||
$this->dom->loadHTML($this->file->body);
|
||||
try
|
||||
{
|
||||
$this->dom->loadHTML($this->file->body);
|
||||
}
|
||||
catch (Throwable $ex)
|
||||
{
|
||||
$this->dom = null;
|
||||
}
|
||||
restore_error_handler();
|
||||
}
|
||||
else
|
||||
|
||||
@@ -2260,4 +2260,14 @@ function embed_wmedia(width, height, link) {
|
||||
{
|
||||
// No-op
|
||||
}
|
||||
|
||||
/**
|
||||
* Sanitize a URL by removing HTTP credentials.
|
||||
* @param string $url the URL to sanitize.
|
||||
* @return string the same URL without HTTP credentials.
|
||||
*/
|
||||
public static function url_remove_credentials($url)
|
||||
{
|
||||
return preg_replace('#^(https?://)[^/:@]+:[^/:@]+@#i', '$1', $url);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -164,12 +164,30 @@ class SimplePie_Parser
|
||||
xml_set_element_handler($xml, 'tag_open', 'tag_close');
|
||||
|
||||
// Parse!
|
||||
if (!xml_parse($xml, $data, true))
|
||||
$wrapper = @is_writable(sys_get_temp_dir()) ? 'php://temp' : 'php://memory';
|
||||
if (($stream = fopen($wrapper, 'r+')) &&
|
||||
fwrite($stream, $data) &&
|
||||
rewind($stream))
|
||||
{
|
||||
//Parse by chunks not to use too much memory
|
||||
do
|
||||
{
|
||||
$stream_data = fread($stream, 1048576);
|
||||
if (!xml_parse($xml, $stream_data === false ? '' : $stream_data, feof($stream)))
|
||||
{
|
||||
$this->error_code = xml_get_error_code($xml);
|
||||
$this->error_string = xml_error_string($this->error_code);
|
||||
$return = false;
|
||||
break;
|
||||
}
|
||||
} while (!feof($stream));
|
||||
fclose($stream);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error_code = xml_get_error_code($xml);
|
||||
$this->error_string = xml_error_string($this->error_code);
|
||||
$return = false;
|
||||
}
|
||||
|
||||
$this->current_line = xml_get_current_line_number($xml);
|
||||
$this->current_column = xml_get_current_column_number($xml);
|
||||
$this->current_byte = xml_get_current_byte_index($xml);
|
||||
|
||||
@@ -208,7 +208,8 @@ class SimplePie_Registry
|
||||
{
|
||||
case 'Cache':
|
||||
// For backwards compatibility with old non-static
|
||||
// Cache::create() methods
|
||||
// Cache::create() methods in PHP < 8.0.
|
||||
// No longer supported as of PHP 8.0.
|
||||
if ($method === 'get_handler')
|
||||
{
|
||||
$result = @call_user_func_array(array($class, 'create'), $parameters);
|
||||
|
||||
@@ -71,6 +71,15 @@ class SimplePie_Sanitize
|
||||
var $useragent = '';
|
||||
var $force_fsockopen = false;
|
||||
var $replace_url_attributes = null;
|
||||
var $registry;
|
||||
|
||||
/**
|
||||
* List of domains for which to force HTTPS.
|
||||
* @see SimplePie_Sanitize::set_https_domains()
|
||||
* Array is a tree split at DNS levels. Example:
|
||||
* array('biz' => true, 'com' => array('example' => true), 'net' => array('example' => array('www' => true)))
|
||||
*/
|
||||
var $https_domains = array();
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
@@ -241,6 +250,68 @@ class SimplePie_Sanitize
|
||||
$this->replace_url_attributes = (array) $element_attribute;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the list of domains for which to force HTTPS.
|
||||
* @see SimplePie_Misc::https_url()
|
||||
* Example array('biz', 'example.com', 'example.org', 'www.example.net');
|
||||
*/
|
||||
public function set_https_domains($domains)
|
||||
{
|
||||
$this->https_domains = array();
|
||||
foreach ($domains as $domain)
|
||||
{
|
||||
$domain = trim($domain, ". \t\n\r\0\x0B");
|
||||
$segments = array_reverse(explode('.', $domain));
|
||||
$node =& $this->https_domains;
|
||||
foreach ($segments as $segment)
|
||||
{//Build a tree
|
||||
if ($node === true)
|
||||
{
|
||||
break;
|
||||
}
|
||||
if (!isset($node[$segment]))
|
||||
{
|
||||
$node[$segment] = array();
|
||||
}
|
||||
$node =& $node[$segment];
|
||||
}
|
||||
$node = true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the domain is in the list of forced HTTPS.
|
||||
*/
|
||||
protected function is_https_domain($domain)
|
||||
{
|
||||
$domain = trim($domain, '. ');
|
||||
$segments = array_reverse(explode('.', $domain));
|
||||
$node =& $this->https_domains;
|
||||
foreach ($segments as $segment)
|
||||
{//Explore the tree
|
||||
if (isset($node[$segment]))
|
||||
{
|
||||
$node =& $node[$segment];
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
return $node === true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Force HTTPS for selected Web sites.
|
||||
*/
|
||||
public function https_url($url)
|
||||
{
|
||||
return (strtolower(substr($url, 0, 7)) === 'http://') &&
|
||||
$this->is_https_domain(parse_url($url, PHP_URL_HOST)) ?
|
||||
substr_replace($url, 's', 4, 0) : //Add the 's' to HTTPS
|
||||
$url;
|
||||
}
|
||||
|
||||
public function sanitize($data, $type, $base = '')
|
||||
{
|
||||
$data = trim($data);
|
||||
@@ -443,6 +514,7 @@ class SimplePie_Sanitize
|
||||
$value = $this->registry->call('Misc', 'absolutize_url', array($element->getAttribute($attribute), $this->base));
|
||||
if ($value !== false)
|
||||
{
|
||||
$value = $this->https_url($value);
|
||||
$element->setAttribute($attribute, $value);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user