MDL-75467 libraries: upgrade to version 1.6.0 of SimplePie.
This commit is contained in:
@@ -38,8 +38,9 @@ What comes in the package?
|
||||
Since SimplePie 1.3, we've split the classes into separate files to make it easier
|
||||
to maintain and use.
|
||||
|
||||
If you'd like a single monolithic file, you can run `php build/compile.php` to
|
||||
generate `SimplePie.compiled.php`.
|
||||
If you'd like a single monolithic file, see the assets in the
|
||||
[releases](https://github.com/simplepie/simplepie/releases), or you can
|
||||
run `php build/compile.php` to generate `SimplePie.compiled.php` yourself.
|
||||
|
||||
To start the demo
|
||||
-----------------
|
||||
|
||||
@@ -58,6 +58,8 @@ if (!class_exists('SimplePie'))
|
||||
*/
|
||||
class SimplePie_Autoloader
|
||||
{
|
||||
protected $path;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
|
||||
Regular → Executable
+103
-12
@@ -33,7 +33,7 @@
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* @package SimplePie
|
||||
* @version 1.5.6
|
||||
* @version 1.6.0
|
||||
* @copyright 2004-2017 Ryan Parman, Sam Sneddon, Ryan McCue
|
||||
* @author Ryan Parman
|
||||
* @author Sam Sneddon
|
||||
@@ -50,7 +50,7 @@ define('SIMPLEPIE_NAME', 'SimplePie');
|
||||
/**
|
||||
* SimplePie Version
|
||||
*/
|
||||
define('SIMPLEPIE_VERSION', '1.5.6');
|
||||
define('SIMPLEPIE_VERSION', '1.6.0');
|
||||
|
||||
/**
|
||||
* SimplePie Build
|
||||
@@ -424,6 +424,13 @@ class SimplePie
|
||||
*/
|
||||
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()
|
||||
@@ -643,6 +650,13 @@ class SimplePie
|
||||
*/
|
||||
public $strip_htmltags = array('base', 'blink', 'body', 'doctype', 'embed', 'font', 'form', 'frame', 'frameset', 'html', 'iframe', 'input', 'marquee', 'meta', 'noscript', 'object', 'param', 'script', 'style');
|
||||
|
||||
/**
|
||||
* @var array Stores the default attributes to be renamed by rename_attributes().
|
||||
* @see SimplePie::rename_attributes()
|
||||
* @access private
|
||||
*/
|
||||
public $rename_attributes = array();
|
||||
|
||||
/**
|
||||
* @var bool Should we throw exceptions, or use the old-style error property?
|
||||
* @access private
|
||||
@@ -908,6 +922,39 @@ class SimplePie
|
||||
$this->cache_location = (string) $location;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
*
|
||||
@@ -1146,6 +1193,7 @@ class SimplePie
|
||||
$this->strip_attributes(false);
|
||||
$this->add_attributes(false);
|
||||
$this->set_image_handler(false);
|
||||
$this->set_https_domains(array());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1182,6 +1230,15 @@ class SimplePie
|
||||
$this->sanitize->encode_instead_of_strip($enable);
|
||||
}
|
||||
|
||||
public function rename_attributes($attribs = '')
|
||||
{
|
||||
if ($attribs === '')
|
||||
{
|
||||
$attribs = $this->rename_attributes;
|
||||
}
|
||||
$this->sanitize->rename_attributes($attribs);
|
||||
}
|
||||
|
||||
public function strip_attributes($attribs = '')
|
||||
{
|
||||
if ($attribs === '')
|
||||
@@ -1248,6 +1305,19 @@ class SimplePie
|
||||
$this->sanitize->set_url_replacements($element_attribute);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
@@ -1373,8 +1443,8 @@ class SimplePie
|
||||
// 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
|
||||
@@ -1514,7 +1584,7 @@ class SimplePie
|
||||
* 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)
|
||||
@@ -1577,6 +1647,7 @@ class SimplePie
|
||||
}
|
||||
|
||||
$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)
|
||||
{
|
||||
@@ -1631,6 +1702,8 @@ class SimplePie
|
||||
$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)))
|
||||
{
|
||||
@@ -1728,7 +1801,7 @@ class SimplePie
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
@@ -1737,6 +1810,16 @@ class SimplePie
|
||||
return $this->error;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the last HTTP status code
|
||||
*
|
||||
* @return int Status code
|
||||
*/
|
||||
public function status_code()
|
||||
{
|
||||
return $this->status_code;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the raw XML
|
||||
*
|
||||
@@ -2132,7 +2215,7 @@ class SimplePie
|
||||
*/
|
||||
public function get_base($element = array())
|
||||
{
|
||||
if (!($this->get_type() & SIMPLEPIE_TYPE_RSS_SYNDICATION) && !empty($element['xml_base_explicit']) && isset($element['xml_base']))
|
||||
if (!empty($element['xml_base_explicit']) && isset($element['xml_base']))
|
||||
{
|
||||
return $element['xml_base'];
|
||||
}
|
||||
@@ -2580,13 +2663,19 @@ class SimplePie
|
||||
}
|
||||
}
|
||||
|
||||
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];
|
||||
}
|
||||
@@ -3243,3 +3332,5 @@ class SimplePie
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class_alias('SimplePie', 'SimplePie\SimplePie', false);
|
||||
|
||||
@@ -147,3 +147,5 @@ class SimplePie_Author
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
class_alias('SimplePie_Author', 'SimplePie\Author', false);
|
||||
|
||||
@@ -132,3 +132,5 @@ class SimplePie_Cache
|
||||
return $params;
|
||||
}
|
||||
}
|
||||
|
||||
class_alias('SimplePie_Cache', 'SimplePie\Cache', false);
|
||||
|
||||
@@ -111,3 +111,5 @@ interface SimplePie_Cache_Base
|
||||
*/
|
||||
public function unlink();
|
||||
}
|
||||
|
||||
class_alias('SimplePie_Cache_Base', 'SimplePie\Cache\Base', false);
|
||||
|
||||
@@ -134,3 +134,5 @@ abstract class SimplePie_Cache_DB implements SimplePie_Cache_Base
|
||||
return array(serialize($data->data), $items_by_id);
|
||||
}
|
||||
}
|
||||
|
||||
class_alias('SimplePie_Cache_DB', 'SimplePie\Cache\DB', false);
|
||||
|
||||
@@ -162,3 +162,5 @@ class SimplePie_Cache_File implements SimplePie_Cache_Base
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
class_alias('SimplePie_Cache_File', 'SimplePie\Cache\File', false);
|
||||
|
||||
@@ -178,3 +178,5 @@ class SimplePie_Cache_Memcache implements SimplePie_Cache_Base
|
||||
return $this->cache->delete($this->name, 0);
|
||||
}
|
||||
}
|
||||
|
||||
class_alias('SimplePie_Cache_Memcache', 'SimplePie\Cache\Memcache', false);
|
||||
|
||||
Regular → Executable
+2
@@ -164,3 +164,5 @@ class SimplePie_Cache_Memcached implements SimplePie_Cache_Base
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
class_alias('SimplePie_Cache_Memcached', 'SimplePie\Cache\Memcached', false);
|
||||
|
||||
@@ -278,7 +278,7 @@ class SimplePie_Cache_MySQL extends SimplePie_Cache_DB
|
||||
$query->bindValue(':data', serialize($data));
|
||||
$query->bindValue(':time', time());
|
||||
$query->bindValue(':feed', $this->id);
|
||||
if ($this->execute())
|
||||
if ($query->execute())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -438,3 +438,5 @@ class SimplePie_Cache_MySQL extends SimplePie_Cache_DB
|
||||
return $query->execute() && $query2->execute();
|
||||
}
|
||||
}
|
||||
|
||||
class_alias('SimplePie_Cache_MySQL', 'SimplePie\Cache\MySQL', false);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
@@ -170,3 +170,5 @@ class SimplePie_Cache_Redis implements SimplePie_Cache_Base {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class_alias('SimplePie_Cache_Redis', 'SimplePie\Cache\Redis', false);
|
||||
|
||||
@@ -196,3 +196,5 @@ class SimplePie_Caption
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
class_alias('SimplePie_Caption', 'SimplePie\Caption', false);
|
||||
|
||||
@@ -79,7 +79,7 @@ class SimplePie_Category
|
||||
|
||||
/**
|
||||
* Category type
|
||||
*
|
||||
*
|
||||
* category for <category>
|
||||
* subject for <dc:subject>
|
||||
*
|
||||
@@ -161,3 +161,4 @@ class SimplePie_Category
|
||||
}
|
||||
}
|
||||
|
||||
class_alias('SimplePie_Category', 'SimplePie\Category', false);
|
||||
|
||||
@@ -316,3 +316,5 @@ class SimplePie_Content_Type_Sniffer
|
||||
return 'text/html';
|
||||
}
|
||||
}
|
||||
|
||||
class_alias('SimplePie_Content_Type_Sniffer', 'SimplePie\Content\Type\Sniffer', false);
|
||||
|
||||
@@ -122,3 +122,5 @@ class SimplePie_Copyright
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
class_alias('SimplePie_Copyright', 'SimplePie\Copyright', false);
|
||||
|
||||
@@ -146,3 +146,5 @@ class SimplePie_Credit
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
class_alias('SimplePie_Credit', 'SimplePie\Credit', false);
|
||||
|
||||
@@ -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':
|
||||
@@ -1302,3 +1307,5 @@ class SimplePie_Enclosure
|
||||
return $type;
|
||||
}
|
||||
}
|
||||
|
||||
class_alias('SimplePie_Enclosure', 'SimplePie\Enclosure', false);
|
||||
|
||||
@@ -48,4 +48,6 @@
|
||||
*/
|
||||
class SimplePie_Exception extends Exception
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
class_alias('SimplePie_Exception', 'SimplePie\Exception', false);
|
||||
|
||||
@@ -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);
|
||||
@@ -298,3 +299,5 @@ class SimplePie_File
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class_alias('SimplePie_File', 'SimplePie\File', false);
|
||||
|
||||
@@ -507,12 +507,16 @@ 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;
|
||||
}
|
||||
}
|
||||
|
||||
class_alias('SimplePie_HTTP_Parser', 'SimplePie\HTTP\Parser', false);
|
||||
|
||||
@@ -1234,3 +1234,5 @@ class SimplePie_IRI
|
||||
return $iauthority;
|
||||
}
|
||||
}
|
||||
|
||||
class_alias('SimplePie_IRI', 'SimplePie\IRI', false);
|
||||
|
||||
@@ -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
|
||||
@@ -2964,3 +2965,5 @@ class SimplePie_Item
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
class_alias('SimplePie_Item', 'SimplePie\Item', false);
|
||||
|
||||
@@ -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
|
||||
@@ -422,3 +430,5 @@ class SimplePie_Locator
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
class_alias('SimplePie_Locator', 'SimplePie\Locator', false);
|
||||
|
||||
@@ -2260,4 +2260,16 @@ 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);
|
||||
}
|
||||
}
|
||||
|
||||
class_alias('SimplePie_Misc', 'SimplePie\Misc', false);
|
||||
|
||||
@@ -267,3 +267,5 @@ class SimplePie_Net_IPv6
|
||||
return self::check_ipv6($ip);
|
||||
}
|
||||
}
|
||||
|
||||
class_alias('SimplePie_Net_IPv6', 'SimplePie\Net\IPv6', false);
|
||||
|
||||
@@ -1023,3 +1023,5 @@ class SimplePie_Parse_Date
|
||||
return $strtotime;
|
||||
}
|
||||
}
|
||||
|
||||
class_alias('SimplePie_Parse_Date', 'SimplePie\Parse\Date', false);
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -122,3 +122,5 @@ class SimplePie_Rating
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
class_alias('SimplePie_Rating', 'SimplePie\Rating', false);
|
||||
|
||||
Regular → Executable
+4
-1
@@ -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);
|
||||
@@ -222,3 +223,5 @@ class SimplePie_Registry
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
class_alias('SimplePie_Registry', 'SimplePie\Registry', false);
|
||||
|
||||
@@ -146,3 +146,5 @@ class SimplePie_Restriction
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
class_alias('SimplePie_Restriction', 'SimplePie\Restriction', false);
|
||||
|
||||
@@ -61,6 +61,7 @@ class SimplePie_Sanitize
|
||||
var $strip_htmltags = array('base', 'blink', 'body', 'doctype', 'embed', 'font', 'form', 'frame', 'frameset', 'html', 'iframe', 'input', 'marquee', 'meta', 'noscript', 'object', 'param', 'script', 'style');
|
||||
var $encode_instead_of_strip = false;
|
||||
var $strip_attributes = array('bgsound', 'expr', 'id', 'style', 'onclick', 'onerror', 'onfinish', 'onmouseover', 'onmouseout', 'onfocus', 'onblur', 'lowsrc', 'dynsrc');
|
||||
var $rename_attributes = array();
|
||||
var $add_attributes = array('audio' => array('preload' => 'none'), 'iframe' => array('sandbox' => 'allow-scripts allow-same-origin'), 'video' => array('preload' => 'none'));
|
||||
var $strip_comments = false;
|
||||
var $output_encoding = 'UTF-8';
|
||||
@@ -71,6 +72,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()
|
||||
{
|
||||
@@ -160,6 +170,25 @@ class SimplePie_Sanitize
|
||||
$this->encode_instead_of_strip = (bool) $encode;
|
||||
}
|
||||
|
||||
public function rename_attributes($attribs = array())
|
||||
{
|
||||
if ($attribs)
|
||||
{
|
||||
if (is_array($attribs))
|
||||
{
|
||||
$this->rename_attributes = $attribs;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->rename_attributes = explode(',', $attribs);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->rename_attributes = false;
|
||||
}
|
||||
}
|
||||
|
||||
public function strip_attributes($attribs = array('bgsound', 'expr', 'id', 'style', 'onclick', 'onerror', 'onfinish', 'onmouseover', 'onmouseout', 'onfocus', 'onblur', 'lowsrc', 'dynsrc'))
|
||||
{
|
||||
if ($attribs)
|
||||
@@ -212,9 +241,9 @@ class SimplePie_Sanitize
|
||||
* Set element/attribute key/value pairs of HTML attributes
|
||||
* containing URLs that need to be resolved relative to the feed
|
||||
*
|
||||
* Defaults to |a|@href, |area|@href, |blockquote|@cite, |del|@cite,
|
||||
* |form|@action, |img|@longdesc, |img|@src, |input|@src, |ins|@cite,
|
||||
* |q|@cite
|
||||
* Defaults to |a|@href, |area|@href, |audio|@src, |blockquote|@cite,
|
||||
* |del|@cite, |form|@action, |img|@longdesc, |img|@src, |input|@src,
|
||||
* |ins|@cite, |q|@cite, |source|@src, |video|@src
|
||||
*
|
||||
* @since 1.0
|
||||
* @param array|null $element_attribute Element/attribute key/value pairs, null for default
|
||||
@@ -226,6 +255,7 @@ class SimplePie_Sanitize
|
||||
$element_attribute = array(
|
||||
'a' => 'href',
|
||||
'area' => 'href',
|
||||
'audio' => 'src',
|
||||
'blockquote' => 'cite',
|
||||
'del' => 'cite',
|
||||
'form' => 'action',
|
||||
@@ -235,12 +265,79 @@ class SimplePie_Sanitize
|
||||
),
|
||||
'input' => 'src',
|
||||
'ins' => 'cite',
|
||||
'q' => 'cite'
|
||||
'q' => 'cite',
|
||||
'source' => 'src',
|
||||
'video' => array(
|
||||
'poster',
|
||||
'src'
|
||||
)
|
||||
);
|
||||
}
|
||||
$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);
|
||||
@@ -303,6 +400,14 @@ class SimplePie_Sanitize
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->rename_attributes)
|
||||
{
|
||||
foreach ($this->rename_attributes as $attrib)
|
||||
{
|
||||
$this->rename_attr($attrib, $xpath);
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->strip_attributes)
|
||||
{
|
||||
foreach ($this->strip_attributes as $attrib)
|
||||
@@ -376,6 +481,8 @@ class SimplePie_Sanitize
|
||||
{
|
||||
$data = preg_replace('/^<div' . SIMPLEPIE_PCRE_XML_ATTRIBUTE . '>/', '<div>', $data);
|
||||
}
|
||||
|
||||
$data = str_replace('</source>', '', $data);
|
||||
}
|
||||
|
||||
if ($type & SIMPLEPIE_CONSTRUCT_IRI)
|
||||
@@ -443,6 +550,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);
|
||||
}
|
||||
}
|
||||
@@ -570,6 +678,17 @@ class SimplePie_Sanitize
|
||||
}
|
||||
}
|
||||
|
||||
protected function rename_attr($attrib, $xpath)
|
||||
{
|
||||
$elements = $xpath->query('//*[@' . $attrib . ']');
|
||||
|
||||
foreach ($elements as $element)
|
||||
{
|
||||
$element->setAttribute('data-sanitized-' . $attrib, $element->getAttribute($attrib));
|
||||
$element->removeAttribute($attrib);
|
||||
}
|
||||
}
|
||||
|
||||
protected function add_attr($tag, $valuePairs, $document)
|
||||
{
|
||||
$elements = $document->getElementsByTagName($tag);
|
||||
@@ -582,3 +701,5 @@ class SimplePie_Sanitize
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class_alias('SimplePie_Sanitize', 'SimplePie\Sanitize', false);
|
||||
|
||||
@@ -575,3 +575,5 @@ class SimplePie_Source
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
class_alias('SimplePie_Source', 'SimplePie\Source', false);
|
||||
|
||||
@@ -357,3 +357,5 @@ class SimplePie_XML_Declaration_Parser
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class_alias('SimplePie_XML_Declaration_Parser', 'SimplePie\XML\Declaration\Parser', false);
|
||||
|
||||
@@ -364,3 +364,5 @@ class SimplePie_gzdecode
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
class_alias('SimplePie_gzdecode', 'SimplePie\Gzdecode', false);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
Description of SimplePie v1.5.6 library import into Moodle
|
||||
Description of SimplePie library import into Moodle
|
||||
|
||||
Obtained from https://github.com/simplepie/simplepie/releases/
|
||||
|
||||
@@ -13,6 +13,7 @@ To upgrade this library:
|
||||
- README.markdown
|
||||
5. That should leave you with just the following. Do not move them. If there is any difference, check if they also need to be moved and update this doc:
|
||||
- idn (This is a third-party library that SimplePie can optionally use. We don't use this in Moodle)
|
||||
- src
|
||||
- CHANGELOG.md
|
||||
- composer.json
|
||||
- db.sql
|
||||
|
||||
@@ -167,7 +167,7 @@
|
||||
<location>simplepie</location>
|
||||
<name>SimplePie</name>
|
||||
<description>Simple Pie helps with blogs.</description>
|
||||
<version>1.5.6</version>
|
||||
<version>1.6.0</version>
|
||||
<license>BSD</license>
|
||||
<repository>https://github.com/simplepie/simplepie</repository>
|
||||
</library>
|
||||
|
||||
Reference in New Issue
Block a user