diff --git a/SimplePie.class.php b/SimplePie.class.php index 00105038..b982b7c7 100644 --- a/SimplePie.class.php +++ b/SimplePie.class.php @@ -52,13 +52,13 @@ /** * SimplePie Version */ -define('SIMPLEPIE_VERSION', '1.5.8'); +define('SIMPLEPIE_VERSION', '1.6.0'); /** * SimplePie Build * @todo Hardcode for release (there's no need to have to call SimplePie_Misc::get_build() only every load of simplepie.inc) */ -define('SIMPLEPIE_BUILD', '20220105000000'); +define('SIMPLEPIE_BUILD', '20220421110903'); /** * SimplePie Website URL @@ -650,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 @@ -1223,6 +1230,15 @@ public function encode_instead_of_strip($enable = true) $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 === '') @@ -2199,7 +2215,7 @@ public function get_image_tags($namespace, $tag) */ 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']; } @@ -3316,6 +3332,8 @@ private function store_links(&$file, $hub, $self) { } } +class_alias('SimplePie', 'SimplePie\SimplePie', false); + /** * Manages all author-related data * @@ -3423,6 +3441,8 @@ public function get_email() } } +class_alias('SimplePie_Author', 'SimplePie\Author', false); + /** * Used to create cache objects * @@ -3515,6 +3535,8 @@ public static function parse_URL($url) } } +class_alias('SimplePie_Cache', 'SimplePie\Cache', false); + /** * Base for cache objects * @@ -3586,6 +3608,8 @@ public function touch(); public function unlink(); } +class_alias('SimplePie_Cache_Base', 'SimplePie\Cache\Base', false); + /** * Base class for database-based caches * @@ -3680,6 +3704,8 @@ protected static function prepare_simplepie_object_for_cache($data) } } +class_alias('SimplePie_Cache_DB', 'SimplePie\Cache\DB', false); + /** * Caches data to the filesystem * @@ -3802,6 +3828,8 @@ public function unlink() } } +class_alias('SimplePie_Cache_File', 'SimplePie\Cache\File', false); + /** * Caches data to memcache * @@ -3940,6 +3968,8 @@ public function unlink() } } +class_alias('SimplePie_Cache_Memcache', 'SimplePie\Cache\Memcache', false); + /** * Caches data to memcached * @@ -4064,6 +4094,8 @@ private function setData($data) { } } +class_alias('SimplePie_Cache_Memcached', 'SimplePie\Cache\Memcached', false); + /** * Caches data to a MySQL database * @@ -4301,7 +4333,7 @@ public function save($data) $query->bindValue(':data', serialize($data)); $query->bindValue(':time', time()); $query->bindValue(':feed', $this->id); - if ($this->execute()) + if ($query->execute()) { return true; } @@ -4462,6 +4494,8 @@ public function unlink() } } +class_alias('SimplePie_Cache_MySQL', 'SimplePie\Cache\MySQL', false); + /** * Caches data to redis * @@ -4622,6 +4656,8 @@ public function unlink() { } +class_alias('SimplePie_Cache_Redis', 'SimplePie\Cache\Redis', false); + /** * Handles `` captions as defined in Media RSS. * @@ -4777,6 +4813,8 @@ public function get_type() } } +class_alias('SimplePie_Caption', 'SimplePie\Caption', false); + /** * Manages all category-related data * @@ -4815,7 +4853,7 @@ class SimplePie_Category /** * Category type - * + * * category for * subject for * @@ -4897,6 +4935,8 @@ public function get_type() } } +class_alias('SimplePie_Category', 'SimplePie\Category', false); + /** * Content-type sniffing * @@ -5172,6 +5212,8 @@ public function feed_or_html() } } +class_alias('SimplePie_Content_Type_Sniffer', 'SimplePie\Content\Type\Sniffer', false); + /** * Manages `` copyright tags as defined in Media RSS * @@ -5254,6 +5296,8 @@ public function get_attribution() } } +class_alias('SimplePie_Copyright', 'SimplePie\Copyright', false); + /** * SimplePie class. * @@ -5374,6 +5418,8 @@ public function get_name() } } +class_alias('SimplePie_Credit', 'SimplePie\Credit', false); + /** * Decode HTML Entities * @@ -7208,6 +7254,8 @@ public function get_real_type($find_handler = false) } } +class_alias('SimplePie_Enclosure', 'SimplePie\Enclosure', false); + /** * General SimplePie exception class * @@ -7217,6 +7265,8 @@ class SimplePie_Exception extends Exception { } +class_alias('SimplePie_Exception', 'SimplePie\Exception', false); + /** * Used for fetching remote files and reading local files * @@ -7476,6 +7526,8 @@ public function __construct($url, $timeout = 10, $redirects = 5, $headers = null } } +class_alias('SimplePie_File', 'SimplePie\File', false); + /** * HTTP Response Parser * @@ -7953,6 +8005,8 @@ static public function prepareHeaders($headers, $count = 1) } } +class_alias('SimplePie_HTTP_Parser', 'SimplePie\HTTP\Parser', false); + /** * IRI parser/serialiser/normaliser * @@ -9147,6 +9201,8 @@ protected function get_authority() } } +class_alias('SimplePie_IRI', 'SimplePie\IRI', false); + /** * Manages all item-related data * @@ -12071,6 +12127,8 @@ public function get_source() } } +class_alias('SimplePie_Item', 'SimplePie\Item', false); + /** * Used for feed auto-discovery * @@ -12461,6 +12519,8 @@ public function body(&$array) } } +class_alias('SimplePie_Locator', 'SimplePie\Locator', false); + /** * Miscellanous utilities * @@ -14692,6 +14752,8 @@ public static function url_remove_credentials($url) } } +class_alias('SimplePie_Misc', 'SimplePie\Misc', false); + /** * Class to validate and to work with IPv6 addresses. * @@ -14918,6 +14980,8 @@ public static function checkIPv6($ip) } } +class_alias('SimplePie_Net_IPv6', 'SimplePie\Net\IPv6', false); + /** * Date Parser * @@ -15900,6 +15964,8 @@ public function date_strtotime($date) } } +class_alias('SimplePie_Parse_Date', 'SimplePie\Parse\Date', false); + /** * Parses XML into something sane * @@ -16537,6 +16603,8 @@ private function declare_html_entities() { } } +class_alias('SimplePie_Parser', 'SimplePie\Parser', false); + /** * Handles `` or `` tags as defined in Media RSS and iTunes RSS respectively * @@ -16619,6 +16687,8 @@ public function get_value() } } +class_alias('SimplePie_Rating', 'SimplePie\Rating', false); + /** * Handles creating objects and calling methods * @@ -16802,6 +16872,8 @@ public function &call($type, $method, $parameters = array()) } } +class_alias('SimplePie_Registry', 'SimplePie\Registry', false); + /** * Handles `` as defined in Media RSS * @@ -16908,6 +16980,8 @@ public function get_value() } } +class_alias('SimplePie_Restriction', 'SimplePie\Restriction', false); + /** * Used for data cleanup and post-processing * @@ -16928,6 +17002,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'; @@ -17036,6 +17111,25 @@ public function encode_instead_of_strip($encode = false) $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) @@ -17088,9 +17182,9 @@ public function set_output_encoding($encoding = 'UTF-8') * 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 @@ -17102,6 +17196,7 @@ public function set_url_replacements($element_attribute = null) $element_attribute = array( 'a' => 'href', 'area' => 'href', + 'audio' => 'src', 'blockquote' => 'cite', 'del' => 'cite', 'form' => 'action', @@ -17111,7 +17206,12 @@ public function set_url_replacements($element_attribute = null) ), 'input' => 'src', 'ins' => 'cite', - 'q' => 'cite' + 'q' => 'cite', + 'source' => 'src', + 'video' => array( + 'poster', + 'src' + ) ); } $this->replace_url_attributes = (array) $element_attribute; @@ -17241,6 +17341,14 @@ public function sanitize($data, $type, $base = '') } } + 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) @@ -17314,6 +17422,8 @@ public function sanitize($data, $type, $base = '') { $data = preg_replace('/^/', '
', $data); } + + $data = str_replace('', '', $data); } if ($type & SIMPLEPIE_CONSTRUCT_IRI) @@ -17509,6 +17619,17 @@ protected function strip_attr($attrib, $xpath) } } + 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); @@ -17522,6 +17643,8 @@ protected function add_attr($tag, $valuePairs, $document) } } +class_alias('SimplePie_Sanitize', 'SimplePie\Sanitize', false); + /** * Handles `` * @@ -18057,6 +18180,8 @@ public function get_image_url() } } +class_alias('SimplePie_Source', 'SimplePie\Source', false); + /** * Parses the XML Declaration * @@ -18373,6 +18498,8 @@ public function standalone_value() } } +class_alias('SimplePie_XML_Declaration_Parser', 'SimplePie\XML\Declaration\Parser', false); + /** * Decode 'gzip' encoded HTTP data * @@ -18696,3 +18823,5 @@ public function parse() } } +class_alias('SimplePie_gzdecode', 'SimplePie\Gzdecode', false); +