--- a/wp/wp-includes/class-simplepie.php Wed Sep 21 18:19:35 2022 +0200
+++ b/wp/wp-includes/class-simplepie.php Tue Sep 27 16:37:53 2022 +0200
@@ -68,7 +68,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*
* @package SimplePie
- * @version 1.5.6
+ * @version 1.5.8
* @copyright 2004-2017 Ryan Parman, Sam Sneddon, Ryan McCue
* @author Ryan Parman
* @author Sam Sneddon
@@ -85,7 +85,7 @@
/**
* SimplePie Version
*/
-define('SIMPLEPIE_VERSION', '1.5.6');
+define('SIMPLEPIE_VERSION', '1.5.8');
/**
* SimplePie Build
@@ -460,6 +460,13 @@
public $error;
/**
+ * @var int HTTP status code
+ * @see SimplePie::status_code()
+ * @access private
+ */
+ public $status_code;
+
+ /**
* @var object Instance of SimplePie_Sanitize (or other class)
* @see SimplePie::set_sanitize_class()
* @access private
@@ -944,6 +951,39 @@
}
/**
+ * Return the filename (i.e. hash, without path and without extension) of the file to cache a given URL.
+ * @param string $url The URL of the feed to be cached.
+ * @return string A filename (i.e. hash, without path and without extension).
+ */
+ public function get_cache_filename($url)
+ {
+ // Append custom parameters to the URL to avoid cache pollution in case of multiple calls with different parameters.
+ $url .= $this->force_feed ? '#force_feed' : '';
+ $options = array();
+ if ($this->timeout != 10)
+ {
+ $options[CURLOPT_TIMEOUT] = $this->timeout;
+ }
+ if ($this->useragent !== SIMPLEPIE_USERAGENT)
+ {
+ $options[CURLOPT_USERAGENT] = $this->useragent;
+ }
+ if (!empty($this->curl_options))
+ {
+ foreach ($this->curl_options as $k => $v)
+ {
+ $options[$k] = $v;
+ }
+ }
+ if (!empty($options))
+ {
+ ksort($options);
+ $url .= '#' . urlencode(var_export($options, true));
+ }
+ return call_user_func($this->cache_name_function, $url);
+ }
+
+ /**
* Set whether feed items should be sorted into reverse chronological order
*
* @param bool $enable Sort as reverse chronological order.
@@ -1181,6 +1221,7 @@
$this->strip_attributes(false);
$this->add_attributes(false);
$this->set_image_handler(false);
+ $this->set_https_domains(array());
}
}
@@ -1284,6 +1325,19 @@
}
/**
+ * Set the list of domains for which to force HTTPS.
+ * @see SimplePie_Sanitize::set_https_domains()
+ * @param array List of HTTPS domains. Example array('biz', 'example.com', 'example.org', 'www.example.net').
+ */
+ public function set_https_domains($domains = array())
+ {
+ if (is_array($domains))
+ {
+ $this->sanitize->set_https_domains($domains);
+ }
+ }
+
+ /**
* Set the handler to enable the display of cached images.
*
* @param string $page Web-accessible path to the handler_image.php file.
@@ -1408,8 +1462,8 @@
// Decide whether to enable caching
if ($this->cache && $parsed_feed_url['scheme'] !== '')
{
- $url = $this->feed_url . ($this->force_feed ? '#force_feed' : '');
- $cache = $this->registry->call('Cache', 'get_handler', array($this->cache_location, call_user_func($this->cache_name_function, $url), 'spc'));
+ $filename = $this->get_cache_filename($this->feed_url);
+ $cache = $this->registry->call('Cache', 'get_handler', array($this->cache_location, $filename, 'spc'));
}
// Fetch the data via SimplePie_File into $this->raw_data
@@ -1549,7 +1603,7 @@
* Fetch the data via SimplePie_File
*
* If the data is already cached, attempt to fetch it from there instead
- * @param SimplePie_Cache|false $cache Cache handler, or false to not load from the cache
+ * @param SimplePie_Cache_Base|false $cache Cache handler, or false to not load from the cache
* @return array|true Returns true if the data was loaded from the cache, or an array of HTTP headers and sniffed type
*/
protected function fetch_data(&$cache)
@@ -1612,6 +1666,7 @@
}
$file = $this->registry->create('File', array($this->feed_url, $this->timeout/10, 5, $headers, $this->useragent, $this->force_fsockopen, $this->curl_options));
+ $this->status_code = $file->status_code;
if ($file->success)
{
@@ -1666,6 +1721,8 @@
$file = $this->registry->create('File', array($this->feed_url, $this->timeout, 5, $headers, $this->useragent, $this->force_fsockopen, $this->curl_options));
}
}
+ $this->status_code = $file->status_code;
+
// If the file connection has an error, set SimplePie::error to that and quit
if (!$file->success && !($file->method & SIMPLEPIE_FILE_SOURCE_REMOTE === 0 || ($file->status_code === 200 || $file->status_code > 206 && $file->status_code < 300)))
{
@@ -1763,7 +1820,7 @@
}
/**
- * Get the error message for the occured error
+ * Get the error message for the occurred error
*
* @return string|array Error message, or array of messages for multifeeds
*/
@@ -1773,6 +1830,16 @@
}
/**
+ * Get the last HTTP status code
+ *
+ * @return int Status code
+ */
+ public function status_code()
+ {
+ return $this->status_code;
+ }
+
+ /**
* Get the raw XML
*
* This is the same as the old `$feed->enable_xml_dump(true)`, but returns
@@ -2615,13 +2682,19 @@
}
}
- if (isset($this->data['headers']['link']) &&
- preg_match('/<([^>]+)>; rel='.preg_quote($rel).'/',
- $this->data['headers']['link'], $match))
+ if (isset($this->data['headers']['link']))
{
- return array($match[1]);
+ $link_headers = $this->data['headers']['link'];
+ if (is_string($link_headers)) {
+ $link_headers = array($link_headers);
+ }
+ $matches = preg_filter('/<([^>]+)>; rel='.preg_quote($rel).'/', '$1', $link_headers);
+ if (!empty($matches)) {
+ return $matches;
+ }
}
- else if (isset($this->data['links'][$rel]))
+
+ if (isset($this->data['links'][$rel]))
{
return $this->data['links'][$rel];
}