From d708bddfcb7811030bbcd951d803ca5e0809230f Mon Sep 17 00:00:00 2001 From: Daniel Ziegenberg Date: Mon, 27 Jan 2025 19:28:44 +0100 Subject: [PATCH] MDL-84156 Libraries: Upgrade SimpePie to 1.8.1 - removed sources in the `library/` directory of the SimplePie lib as those were for PSR-0 namespaces and we use PSR-4 - removed the PSR-4 autoloader provided by SimmpePie as we use our own class loading mechanism - updated the instructions in readme_moodle.txt - fixed constants now being namespaced under \SimplePie\SimplePie Signed-off-by: Daniel Ziegenberg --- blocks/rss_client/editfeed.php | 4 +- lib/simplepie/CHANGELOG.md | 304 +++++++++ lib/simplepie/README.markdown | 16 + lib/simplepie/autoloader.php | 128 ---- lib/simplepie/composer.json | 1 + lib/simplepie/library/SimplePie.php | 488 -------------- lib/simplepie/library/SimplePie/Author.php | 57 -- lib/simplepie/library/SimplePie/Cache.php | 57 -- .../library/SimplePie/Cache/Base.php | 57 -- lib/simplepie/library/SimplePie/Cache/DB.php | 57 -- .../library/SimplePie/Cache/File.php | 57 -- .../library/SimplePie/Cache/Memcache.php | 57 -- .../library/SimplePie/Cache/Memcached.php | 57 -- .../library/SimplePie/Cache/MySQL.php | 57 -- .../library/SimplePie/Cache/Redis.php | 26 - lib/simplepie/library/SimplePie/Caption.php | 57 -- lib/simplepie/library/SimplePie/Category.php | 57 -- .../SimplePie/Content/Type/Sniffer.php | 57 -- lib/simplepie/library/SimplePie/Copyright.php | 57 -- lib/simplepie/library/SimplePie/Core.php | 57 -- lib/simplepie/library/SimplePie/Credit.php | 57 -- .../SimplePie/Decode/HTML/Entities.php | 596 ------------------ lib/simplepie/library/SimplePie/Enclosure.php | 57 -- lib/simplepie/library/SimplePie/Exception.php | 57 -- lib/simplepie/library/SimplePie/File.php | 57 -- .../library/SimplePie/HTTP/Parser.php | 57 -- lib/simplepie/library/SimplePie/IRI.php | 57 -- lib/simplepie/library/SimplePie/Item.php | 57 -- lib/simplepie/library/SimplePie/Locator.php | 57 -- lib/simplepie/library/SimplePie/Misc.php | 57 -- lib/simplepie/library/SimplePie/Net/IPv6.php | 57 -- .../library/SimplePie/Parse/Date.php | 57 -- lib/simplepie/library/SimplePie/Parser.php | 57 -- lib/simplepie/library/SimplePie/Rating.php | 57 -- lib/simplepie/library/SimplePie/Registry.php | 57 -- .../library/SimplePie/Restriction.php | 57 -- lib/simplepie/library/SimplePie/Sanitize.php | 57 -- lib/simplepie/library/SimplePie/Source.php | 57 -- .../SimplePie/XML/Declaration/Parser.php | 57 -- lib/simplepie/library/SimplePie/gzdecode.php | 57 -- lib/simplepie/moodle_simplepie.php | 45 +- lib/simplepie/readme_moodle.txt | 15 +- lib/simplepie/src/Author.php | 1 - lib/simplepie/src/Cache.php | 1 - lib/simplepie/src/Cache/Base.php | 1 - lib/simplepie/src/Cache/BaseDataCache.php | 5 +- lib/simplepie/src/Cache/DB.php | 9 +- lib/simplepie/src/Cache/DataCache.php | 1 - lib/simplepie/src/Cache/File.php | 1 - lib/simplepie/src/Cache/Memcache.php | 1 - lib/simplepie/src/Cache/Memcached.php | 1 - lib/simplepie/src/Cache/MySQL.php | 9 +- lib/simplepie/src/Cache/Psr16.php | 3 +- lib/simplepie/src/Cache/Redis.php | 1 - lib/simplepie/src/Caption.php | 1 - lib/simplepie/src/Category.php | 1 - lib/simplepie/src/Content/Type/Sniffer.php | 1 - lib/simplepie/src/Copyright.php | 1 - lib/simplepie/src/Credit.php | 1 - lib/simplepie/src/Enclosure.php | 17 +- lib/simplepie/src/Exception.php | 1 - lib/simplepie/src/File.php | 1 - lib/simplepie/src/Gzdecode.php | 3 +- lib/simplepie/src/HTTP/Parser.php | 1 - lib/simplepie/src/IRI.php | 1 - lib/simplepie/src/Item.php | 7 +- lib/simplepie/src/Locator.php | 1 - lib/simplepie/src/Misc.php | 1 - lib/simplepie/src/Net/IPv6.php | 1 - lib/simplepie/src/Parse/Date.php | 1 - lib/simplepie/src/Parser.php | 12 +- lib/simplepie/src/Rating.php | 1 - lib/simplepie/src/Registry.php | 5 +- lib/simplepie/src/RegistryAware.php | 1 - lib/simplepie/src/Restriction.php | 1 - lib/simplepie/src/Sanitize.php | 13 +- lib/simplepie/src/SimplePie.php | 28 +- lib/simplepie/src/Source.php | 7 +- lib/simplepie/src/XML/Declaration/Parser.php | 1 - lib/thirdpartylibs.xml | 2 +- 80 files changed, 407 insertions(+), 3185 deletions(-) create mode 100644 lib/simplepie/CHANGELOG.md delete mode 100644 lib/simplepie/autoloader.php delete mode 100644 lib/simplepie/library/SimplePie.php delete mode 100644 lib/simplepie/library/SimplePie/Author.php delete mode 100644 lib/simplepie/library/SimplePie/Cache.php delete mode 100644 lib/simplepie/library/SimplePie/Cache/Base.php delete mode 100644 lib/simplepie/library/SimplePie/Cache/DB.php delete mode 100644 lib/simplepie/library/SimplePie/Cache/File.php delete mode 100644 lib/simplepie/library/SimplePie/Cache/Memcache.php delete mode 100644 lib/simplepie/library/SimplePie/Cache/Memcached.php delete mode 100644 lib/simplepie/library/SimplePie/Cache/MySQL.php delete mode 100644 lib/simplepie/library/SimplePie/Cache/Redis.php delete mode 100644 lib/simplepie/library/SimplePie/Caption.php delete mode 100644 lib/simplepie/library/SimplePie/Category.php delete mode 100644 lib/simplepie/library/SimplePie/Content/Type/Sniffer.php delete mode 100644 lib/simplepie/library/SimplePie/Copyright.php delete mode 100644 lib/simplepie/library/SimplePie/Core.php delete mode 100644 lib/simplepie/library/SimplePie/Credit.php delete mode 100644 lib/simplepie/library/SimplePie/Decode/HTML/Entities.php delete mode 100644 lib/simplepie/library/SimplePie/Enclosure.php delete mode 100644 lib/simplepie/library/SimplePie/Exception.php delete mode 100644 lib/simplepie/library/SimplePie/File.php delete mode 100644 lib/simplepie/library/SimplePie/HTTP/Parser.php delete mode 100644 lib/simplepie/library/SimplePie/IRI.php delete mode 100644 lib/simplepie/library/SimplePie/Item.php delete mode 100644 lib/simplepie/library/SimplePie/Locator.php delete mode 100644 lib/simplepie/library/SimplePie/Misc.php delete mode 100644 lib/simplepie/library/SimplePie/Net/IPv6.php delete mode 100644 lib/simplepie/library/SimplePie/Parse/Date.php delete mode 100644 lib/simplepie/library/SimplePie/Parser.php delete mode 100644 lib/simplepie/library/SimplePie/Rating.php delete mode 100644 lib/simplepie/library/SimplePie/Registry.php delete mode 100644 lib/simplepie/library/SimplePie/Restriction.php delete mode 100644 lib/simplepie/library/SimplePie/Sanitize.php delete mode 100644 lib/simplepie/library/SimplePie/Source.php delete mode 100644 lib/simplepie/library/SimplePie/XML/Declaration/Parser.php delete mode 100644 lib/simplepie/library/SimplePie/gzdecode.php diff --git a/blocks/rss_client/editfeed.php b/blocks/rss_client/editfeed.php index 545d422f127..d4692b629d7 100644 --- a/blocks/rss_client/editfeed.php +++ b/blocks/rss_client/editfeed.php @@ -85,7 +85,7 @@ class feed_edit_form extends moodleform { $rss->set_timeout(10); $rss->set_feed_url($data['url']); $rss->set_autodiscovery_cache_duration(0); - $rss->set_autodiscovery_level(SIMPLEPIE_LOCATOR_NONE); + $rss->set_autodiscovery_level(\SimplePie\SimplePie::LOCATOR_NONE); $rss->init(); if ($rss->error()) { @@ -129,7 +129,7 @@ class feed_edit_form extends moodleform { public static function autodiscover_feed_url($url){ $rss = new moodle_simplepie(); $rss->set_feed_url($url); - $rss->set_autodiscovery_level(SIMPLEPIE_LOCATOR_ALL); + $rss->set_autodiscovery_level(\SimplePie\SimplePie::LOCATOR_ALL); // When autodiscovering an RSS feed, simplepie will try lots of // rss links on a page, so set the timeout high $rss->set_timeout(20); diff --git a/lib/simplepie/CHANGELOG.md b/lib/simplepie/CHANGELOG.md new file mode 100644 index 00000000000..afc58588bbc --- /dev/null +++ b/lib/simplepie/CHANGELOG.md @@ -0,0 +1,304 @@ +# Changelog + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [Unreleased](https://github.com/simplepie/simplepie/compare/1.8.1...one-dot-eight) + +Nothing yet. + +## [1.8.1](https://github.com/simplepie/simplepie/compare/1.8.0...1.8.1) - 2024-10-01 + +### Changed + +- Disable Composer lockfile by @jrfnl in [#887](https://github.com/simplepie/simplepie/pull/887), backported in [#895](https://github.com/simplepie/simplepie/pull/895) + +### Fixed + +- Fixes for PHP 8.4 deprecations by @Girgias, @jrfnl and @jtojnar, backported in [#875](https://github.com/simplepie/simplepie/pull/875) +- Fix locator with website missing `Content-Type` header by @jtojnar in [#891](https://github.com/simplepie/simplepie/pull/891) +- Fix `encode` argument of `SimplePie::strip_htmltags()` @jtojnar in [#894](https://github.com/simplepie/simplepie/pull/894), backported in [#898](https://github.com/simplepie/simplepie/pull/898) +- Reverted `strict_types` by @jtojnar in [#842](https://github.com/simplepie/simplepie/pull/842) + +## [1.8.0](https://github.com/simplepie/simplepie/compare/1.7.0...1.8.0) - 2023-01-20 + +### Added + +- New method `SimplePie\SimplePie::set_cache()` for providing a PSR-16 cache implementation by @Art4 in [#742](https://github.com/simplepie/simplepie/pull/742) +- New method `SimplePie\SimplePie::set_cache_namefilter()` for customize the cache key in [#762](https://github.com/simplepie/simplepie/pull/762) +- New class `SimplePie\Cache\CallableNameFilter` to provide a `callable` to customize the cache key in [#762](https://github.com/simplepie/simplepie/pull/762) +- New interface `SimplePie\RegistryAware` to inject the `Registry` instance into classes created by `Registry` by @Art4 in [#760](https://github.com/simplepie/simplepie/pull/760) +- update PHP versions in GH Actions workflows by @jrfnl in [#767](https://github.com/simplepie/simplepie/pull/767) +- Registry: Allow using class-strings instead of magic strings by @jtojnar and @Art4 in [#766](https://github.com/simplepie/simplepie/pull/766) + +### Changed + +- Clarify branching strategy by @Art4 in [#751](https://github.com/simplepie/simplepie/pull/751) +- Use native array_replace_recursive() by @Alkarex in [#749](https://github.com/simplepie/simplepie/pull/749) +- PHP 7.2 or newer is now required by @Art4 in [#743](https://github.com/simplepie/simplepie/pull/743) +- Parse\Date: Clean up regex structure by @jtojnar in [#765](https://github.com/simplepie/simplepie/pull/765) +- Declare strict_types=1 in every file by @Art4 in [#763](https://github.com/simplepie/simplepie/pull/763) + +### Fixed + +- Item::get_date(): fix return type on unparsable date by @jtojnar in [#753](https://github.com/simplepie/simplepie/pull/753) +- Fix error handling for PHP 8.1 by @cedric-anne in [#747](https://github.com/simplepie/simplepie/pull/747) +- The method `SimplePie\SimplePie::get_image_height()` returns the pixel number as `int` instead of `float` by @Art4 in [#763](https://github.com/simplepie/simplepie/pull/763) +- The method `SimplePie\SimplePie::get_image_width()` returns the pixel number as `int` instead of `float` by @Art4 in [#763](https://github.com/simplepie/simplepie/pull/763) +- No URL Decode for enclosure links by @Alkarex in [#768](https://github.com/simplepie/simplepie/pull/768) +- Sanitize thumbnail URL by @Alkarex in [#770](https://github.com/simplepie/simplepie/pull/770) +- Fix case of multiple RSS2.0 enclosures by @Alkarex in [#769](https://github.com/simplepie/simplepie/pull/769) +- Fix broken phpdoc references by @jtojnar in [#771](https://github.com/simplepie/simplepie/pull/771) + +### Deprecated + +- The method `SimplePie\Misc::array_merge_recursive()` is deprecated, use native `array_replace_recursive()` instead +- The method `SimplePie\SimplePie::set_cache_name_function()` is deprecated, use `SimplePie\SimplePie::set_cache_namefilter()` instead +- The method `SimplePie\SimplePie::set_cache_location()` is deprecated, use `SimplePie\SimplePie::set_cache()` instead +- The method `SimplePie\SimplePie::force_cache_fallback()` is deprecated, expired cache will not be used anymore +- The class `SimplePie\Cache` is deprecated, use implementation of `SimplePie\SimplePie::set_cache()` instead +- The class `SimplePie\Cache\DB` is deprecated, use implementation of `Psr\SimpleCache\CacheInterface` instead +- The class `SimplePie\Cache\File` is deprecated, use implementation of `Psr\SimpleCache\CacheInterface` instead +- The class `SimplePie\Cache\Memcache` is deprecated, use implementation of `Psr\SimpleCache\CacheInterface` instead +- The class `SimplePie\Cache\Memcached` is deprecated, use implementation of `Psr\SimpleCache\CacheInterface` instead +- The class `SimplePie\Cache\MySQL` is deprecated, use implementation of `Psr\SimpleCache\CacheInterface` instead +- The class `SimplePie\Cache\Redis` is deprecated, use implementation of `Psr\SimpleCache\CacheInterface` instead +- The interface `SimplePie\Cache\Base` is deprecated, use interface `Psr\SimpleCache\CacheInterface` instead + +### Removed + +- ROADMAP.md removed by @Art4 in [#748](https://github.com/simplepie/simplepie/pull/748) +- remove check for E_USER_DEPRECATED definition by @Art4 in [#750](https://github.com/simplepie/simplepie/pull/750) +- remove broken BC code in Registry by @Art4 in [#764](https://github.com/simplepie/simplepie/pull/764) + +## [1.7.0](https://github.com/simplepie/simplepie/compare/1.6.0...1.7.0) - 2022-09-30 + +### Added + +- New class `SimplePie\SimplePie` as a replacement for class `SimplePie` +- New method `SimplePie\Misc::get_default_useragent()` as a replacement for constant `SIMPLEPIE_USERAGENT` + +### Changed + +- Do not use magic values for state machine state by @jtojnar in [#735](https://github.com/simplepie/simplepie/pull/735) +- Use PSR-4 classes in Registry by @Art4 in [#736](https://github.com/simplepie/simplepie/pull/736) +- GH Actions: run tests against PHP 8.2 by @jrfnl in [#739](https://github.com/simplepie/simplepie/pull/739) +- Change code style to PSR-12 by @Art4 in [#738](https://github.com/simplepie/simplepie/pull/738) + +### Fixed + +- Fix status_code type by @Alkarex in [#728](https://github.com/simplepie/simplepie/pull/728) +- Fix parsing of HTTP Links by @Alkarex in [#729](https://github.com/simplepie/simplepie/pull/729) +- Fix using the best base link for an item content by @Alkarex in [#744](https://github.com/simplepie/simplepie/pull/744) +- Fix .editorconfig regression by @Alkarex in [#745](https://github.com/simplepie/simplepie/pull/745) + +### Deprecated + +- The class `SimplePie` is deprecated, use class `SimplePie\SimplePie` instead +- The use of PSR-0 classes (all classes without namespaces in the `library` directory) is deprecated, use PSR-4 classes (see `src` directory) instead +- The constant `SIMPLEPIE_BUILD` is deprecated, use `SimplePie\Misc::get_build()` instead +- The constant `SIMPLEPIE_USERAGENT` is deprecated, use `SimplePie\Misc::get_default_useragent()` instead +- All global constants are deprecated, use the constants from the class `SimplePie\SimplePie` instead (e.g. replace `SIMPLEPIE_VERSION` with `SimplePie\SimplePie::VERSION`) + +## [1.6.0](https://github.com/simplepie/simplepie/compare/1.5.8...1.6.0) - 2022-04-21 + +### Added + +- New methods `SimplePie::rename_attributes()` and `SimplePie_Sanitize::rename_attributes()` allow renaming attributes by @math-GH in [#717](https://github.com/simplepie/simplepie/pull/717) +- Add audio, video @src elements/attribute for URL resolution by @rdalverny in [#716](https://github.com/simplepie/simplepie/pull/716) +- Added new namespaced aliases and PSR-4 support for every class by @Art4 in [#711](https://github.com/simplepie/simplepie/pull/711) +- Add .editorconfig by @Alkarex in [#724](https://github.com/simplepie/simplepie/pull/724) +- Upload compiled file as release asset by @Art4 in [#725](https://github.com/simplepie/simplepie/pull/725) + +### Changed + +- GH Actions: version update for ramsey/composer-install by @jrfnl in [#713](https://github.com/simplepie/simplepie/pull/713) + +### Fixed + +- Bugfix in MySQL cache by @Art4 in [#720](https://github.com/simplepie/simplepie/pull/720) +- Re-enable xml:base for all supported RSS formats by @Alkarex in [#723](https://github.com/simplepie/simplepie/pull/723) + +## [1.5.8](https://github.com/simplepie/simplepie/compare/1.5.7...1.5.8) - 2021-12-24 + +### Changed + +- Update CHANGELOG.md, follow keepachangelog format by @Art4 in [#709](https://github.com/simplepie/simplepie/pull/709) + +### Fixed + +- Fix a small typo in the error() function Docblock by @audrasjb in [#712](https://github.com/simplepie/simplepie/pull/712) +- Fix/708 version bump for constant `SIMPLEPIE_VERSION` for 1.5.8 release by @faisal-alvi in [#710](https://github.com/simplepie/simplepie/pull/710) + +## [1.5.7](https://github.com/simplepie/simplepie/compare/1.5.6...1.5.7) - 2021-12-19 + +* Fix PHP8 crash due to insufficient isset test by @Alkarex in [#670](https://github.com/simplepie/simplepie/pull/670) +* gitignore tests by @Alkarex in [#671](https://github.com/simplepie/simplepie/pull/671) +* Reduce memory when parsing large feeds by @Alkarex in [#672](https://github.com/simplepie/simplepie/pull/672) +* PHP8 catch ValueError for loadHTML() by @Alkarex in [#673](https://github.com/simplepie/simplepie/pull/673) +* Provide access to HTTP status code by @Alkarex in [#674](https://github.com/simplepie/simplepie/pull/674) +* Fix wrong type hint by @Alkarex in [#678](https://github.com/simplepie/simplepie/pull/678) +* Force HTTPS for selected domains by @Alkarex in [#676](https://github.com/simplepie/simplepie/pull/676) +* Prevent cache polution by @Alkarex in [#675](https://github.com/simplepie/simplepie/pull/675) +* Fix typo in comment by @Alkarex in [#680](https://github.com/simplepie/simplepie/pull/680) +* Remove HTTP credentials in HTTP Referer by @Alkarex in [#681](https://github.com/simplepie/simplepie/pull/681) +* CI: switch to GH Actions by @jrfnl in [#688](https://github.com/simplepie/simplepie/pull/688) +* PHP 8.1: fix "passing null to non-nullable" deprecation notice by @jrfnl in [#689](https://github.com/simplepie/simplepie/pull/689) +* Tests: PHPUnit cross-version compatibility by @jrfnl in [#690](https://github.com/simplepie/simplepie/pull/690) +* Tests: use strict assertions by @jrfnl in [#692](https://github.com/simplepie/simplepie/pull/692) +* CacheTest: handle different exceptions PHP cross-version by @jrfnl in [#691](https://github.com/simplepie/simplepie/pull/691) +* GH Actions: don't allow builds to fail on PHP 8.0 or 8.1 by @jrfnl in [#693](https://github.com/simplepie/simplepie/pull/693) +* Tests: use the correct parameter order by @jrfnl in [#694](https://github.com/simplepie/simplepie/pull/694) +* PHPUnit: update configuration by @jrfnl in [#696](https://github.com/simplepie/simplepie/pull/696) +* fix: better deal with proxy returning proxy headers (in response to cURL's Proxy-Connection header) by @shunf4 in [#698](https://github.com/simplepie/simplepie/pull/698) +* Handle multiple Link headers by @voegelas in [#700](https://github.com/simplepie/simplepie/pull/700) +* PHP 8.2: explicitly declare properties by @jrfnl in [#705](https://github.com/simplepie/simplepie/pull/705) +* New Contributor: @shunf4 made their first contribution in [#698](https://github.com/simplepie/simplepie/pull/698) +* New Contributor: @voegelas made their first contribution in [#700](https://github.com/simplepie/simplepie/pull/700) + +## [1.5.6](https://github.com/simplepie/simplepie/compare/1.5.5...1.5.6) - 2020-10-14 + +* PHP 8.0: prevent ValueError for invalid encoding [#657](https://github.com/simplepie/simplepie/pull/657) +* Travis: test against more recent PHP versions [#653](https://github.com/simplepie/simplepie/pull/653) +* PHP 8.0: handle removal of get_magic_quotes_gpc() [#654](https://github.com/simplepie/simplepie/pull/654) +* PHP 7.4/8.0: curly brace array access deprecated & removed [#655](https://github.com/simplepie/simplepie/pull/655) +* PHP 8.0: required parameters are no longer allowed after optional parameters [#656](https://github.com/simplepie/simplepie/pull/656) +* Fix permanent_url for HTTP 301 [#660](https://github.com/simplepie/simplepie/pull/660) +* Fix typo in MIME type in Content_Type_Sniffer [#661](https://github.com/simplepie/simplepie/pull/661) + +## [1.5.5](https://github.com/simplepie/simplepie/compare/1.5.4...1.5.5) - 2020-05-01 + +* Ensure that feeds retrieved with `force_feed` do not share the same cache as those retrieved without. [#643](https://github.com/simplepie/simplepie/pull/643) +* Removed references to removed PHP directives and some PHP < 5.6 checks. [#645](https://github.com/simplepie/simplepie/pull/645) +* Corrected incorrect alumni name. [#638](https://github.com/simplepie/simplepie/pull/638) + +## [1.5.4](https://github.com/simplepie/simplepie/compare/1.5.3...1.5.4) - 2019-12-17 + +* PHP 5.6 or newer is now required. [#625](https://github.com/simplepie/simplepie/pull/625) +* Fixed invalid docblock parameter types [#633](https://github.com/simplepie/simplepie/pull/633) +* Added support for German short forms for weekdays and months. [#632](https://github.com/simplepie/simplepie/pull/632) +* PHP 7.4 support: Fixed instances of accessing array offset on null type values. [#628](https://github.com/simplepie/simplepie/pull/628) +* Return an effective feed URL when asking for non-permanent `subscribe_url`. [#627](https://github.com/simplepie/simplepie/pull/627) + +## [1.5.3](https://github.com/simplepie/simplepie/compare/1.5.2...1.5.3) - 2019-09-22 + +* Replaced `pow()` call with `**` operator (micro performance optimization). [#622](https://github.com/simplepie/simplepie/pull/622) +* Match links containing `feed` in the Locator class. [#621](https://github.com/simplepie/simplepie/pull/621) +* PHP 7.4 support: Ensure the proper argument order for `implode()` calls. [#617](https://github.com/simplepie/simplepie/pull/617) +* Added support for Russian dates. [#607](https://github.com/simplepie/simplepie/pull/607) +* Preemptively changed `is_writeable()` calls to `is_writable()` in case the former is deprecated in PHP. [#604](https://github.com/simplepie/simplepie/pull/604) + +## [1.5.2](https://github.com/simplepie/simplepie/compare/1.5.1...1.5.2) - 2018-08-02 + +* Added support for PHPUnit 6. [#565](https://github.com/simplepie/simplepie/pull/565) +* Added PHP module requirements to Composer. [#590](https://github.com/simplepie/simplepie/pull/590) +* Added support for Redis password and database. [#589](https://github.com/simplepie/simplepie/pull/589) +* Changed the spelling of `writeable` to `writable` within inline documentation. [#586](https://github.com/simplepie/simplepie/pull/586) +* Fixed various issues in the test suite and Travis. [#576](https://github.com/simplepie/simplepie/pull/576) +* Removed ambiguous tests failing on `usort()` in PHP 7. [#578](https://github.com/simplepie/simplepie/pull/578) +* Simplified logic for some function returns. [#573](https://github.com/simplepie/simplepie/pull/573) +* Fixed inline documentation for return value types for accuracy. [#570](https://github.com/simplepie/simplepie/pull/570) +* Fixed Travis to run `composer install`. [#567](https://github.com/simplepie/simplepie/pull/567) +* Removed unnecessary `else`s when a value has already been returned. [#566](https://github.com/simplepie/simplepie/pull/566) +* Fixed a bug where URL fragments are included when `SimplePie_File` normalizes URLs when really old versions of cURL are used. [#564](https://github.com/simplepie/simplepie/pull/564) +* Updated `SimplePie_Locator` to respect cURL options specified. [#561](https://github.com/simplepie/simplepie/pull/561) + +## [1.5.1](https://github.com/simplepie/simplepie/compare/1.5...1.5.1) - 2017-11-17 + +* Fixed photos so they are not added if the URL is empty. [#530](https://github.com/simplepie/simplepie/pull/530) +* Fixed issues with retrieving feeds from behind a proxy. [#512](https://github.com/simplepie/simplepie/pull/512)/[#548](https://github.com/simplepie/simplepie/pull/548) +* Updated favicon URL in `get_favicon()`. [#525](https://github.com/simplepie/simplepie/pull/525) +* Fixed inline documentation typo. [#540](https://github.com/simplepie/simplepie/pull/540) +* Removed extra closing `` tag. [#537](https://github.com/simplepie/simplepie/pull/537) +* Removed and updated feed URLs in the demo. [#535](https://github.com/simplepie/simplepie/pull/535) +* Improvements to microformat feed parsing. [#533](https://github.com/simplepie/simplepie/pull/533) +* Switched from regex to xpath for microformats discovery. [#536](https://github.com/simplepie/simplepie/pull/536) +* Update the registry if the Sanitize class has been changed. [#532](https://github.com/simplepie/simplepie/pull/532) +* Changed the sanitization type for author and category back to text from HTML. [#531](https://github.com/simplepie/simplepie/pull/531) + +## [1.5](https://github.com/simplepie/simplepie/compare/1.4.3...1.5) - 2017-04-17 + +* Introduced `SimplePie_Category->get_type()` for retrieving category type. [#492](https://github.com/simplepie/simplepie/pull/492) +* Added `$enable_exceptions` to the class property declarations for `SimplePie` class. [#504](https://github.com/simplepie/simplepie/pull/504) +* Titles are now parsed for ATOM10 enclosure links. [#507](https://github.com/simplepie/simplepie/pull/507) +* `$item->get_id()` can now be forced to return the supplied ID instead of generating a new one. [#509](https://github.com/simplepie/simplepie/pull/509) + +## [1.4.3](https://github.com/simplepie/simplepie/compare/1.4.2...1.4.3) - 2016-11-26 + +* Removed support for PHP 5.2. [#469](https://github.com/simplepie/simplepie/pull/469) +* Added support for the PHP `UConverter` class. [#485](https://github.com/simplepie/simplepie/pull/485) +* PHP 7.1 Support: Fixed PHP error when trying to use a non-numeric value in `round()`. [#458](https://github.com/simplepie/simplepie/pull/458) +* PHP 7 Support: Fixed deprecated message for old style constructors. [#489](https://github.com/simplepie/simplepie/pull/489) +* Fixed the error message shown when a feed has an empty body. [#487](https://github.com/simplepie/simplepie/pull/487) +* Added an error message when the XML or PCRE PHP extensions are missing. [#468](https://github.com/simplepie/simplepie/pull/468) +* Check the result of sanitize before returning in `get_content()` and `get_description()`. [#494](https://github.com/simplepie/simplepie/pull/494) +* Use `saveHTML()` to fix issues with non UTF-8 characters. [#470](https://github.com/simplepie/simplepie/pull/470) +* Stop passing compressed data through `trim()`. [#455](https://github.com/simplepie/simplepie/pull/455) +* Refactored the UTF-8 conversion error message. [#467](https://github.com/simplepie/simplepie/pull/467) +* Updated the readme file. [#486](https://github.com/simplepie/simplepie/pull/486) +* Added command line support for compayibility test. [#481](https://github.com/simplepie/simplepie/pull/481) +* Added PHP 7.1 to the testing matrix. [#462](https://github.com/simplepie/simplepie/pull/462) +* Use the latest HHVM version in testing (3.15.2). [#480](https://github.com/simplepie/simplepie/pull/480) +* Added PHPUnit as a `dev-dependency` in Composer. [#463](https://github.com/simplepie/simplepie/pull/463) +* Added `mf2/mf2` as a suggestion in Composer for use with microformats. [#491](https://github.com/simplepie/simplepie/pull/491) +* Fixed misspelled occurrences of "separated". [#459](https://github.com/simplepie/simplepie/pull/459) +* Improvements to the compatibility test and error messages. [#488](https://github.com/simplepie/simplepie/pull/488) + +## [1.4.2](https://github.com/simplepie/simplepie/compare/1.4.1...1.4.2) - 2016-06-14 + +* Fixed a bug with IRI parsing. +* More cleanly separates discovery of microformats and parsing when php-mf2 is not present. + +## [1.4.1](https://github.com/simplepie/simplepie/compare/1.4.0...1.4.1) - 2016-06-02 + +* Fixed inconsistent hash results in `SimplePie_Item->get_id()`. +* Leading and trailing whitespace is now trimmed from XML feed content to prevent errors. [#445](https://github.com/simplepie/simplepie/pull/445) +* Improved support for microformat feeds. + +## [1.4.0](https://github.com/simplepie/simplepie/compare/1.4-beta...1.4.0) - 2016-04-25 + +* Dropped support for PHP 5.2. [#348](https://github.com/simplepie/simplepie/pull/348) +* Serialized data is now used for hashing in `SimplePie_Item->get_id()`. [#348](https://github.com/simplepie/simplepie/pull/348) +* Added support for PHP 5.5 and 5.6. [#348](https://github.com/simplepie/simplepie/pull/348) +* Added the `add_attributes()` method to `SimplePie`. [#394](https://github.com/simplepie/simplepie/pull/394) +* Added the `force_cache_fallback()` method to `SimplePie` to allow an expired cache to be used when a feed is unavailable. [#389](https://github.com/simplepie/simplepie/pull/389) +* Added Memcached. [#386](https://github.com/simplepie/simplepie/pull/386) +* Added `set_curl_options()` method to `SimplePie` to allow custom options. [#348](https://github.com/simplepie/simplepie/pull/348) +* Added Redis Caching. [#348](https://github.com/simplepie/simplepie/pull/348) +* Added the CEST timezone. [#380](https://github.com/simplepie/simplepie/pull/380) +* Added support for HTTP 301 Moved Permanently. [#348](https://github.com/simplepie/simplepie/pull/348) +* Added support for `application/x-rss+xml` in `SimplePie_Locator`. [#348](https://github.com/simplepie/simplepie/pull/348) +* Added photo de-duping in microformats. [#348](https://github.com/simplepie/simplepie/pull/348) +* Added decoding for special characters in MAYBE_HTML. [#400](https://github.com/simplepie/simplepie/pull/400) +* Added `SimplePie_Exception` for internally reporting errors. Also, use this to show an error when trying to load the class instead of causing a failure. [#241](https://github.com/simplepie/simplepie/pull/241) +* Added sanitization of the `` and `` tags. [#348](https://github.com/simplepie/simplepie/pull/348) +* Added support for media thumbnails through `SimplePie_Item->get_thumbnail()`. [#348](https://github.com/simplepie/simplepie/pull/348) +* Added the `feed_url` to a returned error message. [#348](https://github.com/simplepie/simplepie/pull/348) +* Added cache purging after a specified period of time when using MySQL cache. [#329](https://github.com/simplepie/simplepie/pull/329) +* Added backwards compatibility for removed `subscribe_*()` and `enable_xml_dump()` methods. [#348](https://github.com/simplepie/simplepie/pull/348) +* Re-added the deprecated `get/set_favicon()` methods for backwards compatibility. +* Charsets are now compared without case sensitivity to avoid duplicates. [#352](https://github.com/simplepie/simplepie/pull/352) +* Fixed encoding of ampersands in `SimplePie->subscribe_url()`. [#348](https://github.com/simplepie/simplepie/pull/348) +* The feed URL is now updated based on the URL returned by cURL. [#348](https://github.com/simplepie/simplepie/pull/348) +* Explicitly use UTF-8 in `SimplePie_Misc->get_element()` and `Simple_ie_Misc->element_implode()`. [#348](https://github.com/simplepie/simplepie/pull/348) +* Improved support, feed and authorship discovery, and parsing for microformats. [#348](https://github.com/simplepie/simplepie/pull/348) +* `rss:pubDate` is now used over `atom:updated` when determining the posting date. [#288](https://github.com/simplepie/simplepie/pull/288) +* Simplified the use of `mtime()` and `touch()`. [#403](https://github.com/simplepie/simplepie/pull/403) +* All items are now forced to have a timestamp. [#348](https://github.com/simplepie/simplepie/pull/348) +* Fixed typo in the date parser that incorrectly identified September as month 8. [#348](https://github.com/simplepie/simplepie/pull/348) +* Fixed backwards compatibility with cache subclasses. [#243](https://github.com/simplepie/simplepie/pull/243) +* Fixed a bug where the updated date was not fetched correctly. [#239](https://github.com/simplepie/simplepie/pull/239) +* Fixed the datatype for `items.data` to be more appropriate in when using MySQL cache. [#302](https://github.com/simplepie/simplepie/pull/302) +* Fixed cURL not failing when the server returns an error. [#425](https://github.com/simplepie/simplepie/pull/425) +* Fixed an error caused when trying to instantiate a `SimplePie_File` object with a bad URI. [#272](https://github.com/simplepie/simplepie/pull/272) +* Fixed a PHP notice that occurs when a date starts with `(`. [#348](https://github.com/simplepie/simplepie/pull/348) +* Fixed uninitialized string offeset PHP notices. [#353](https://github.com/simplepie/simplepie/pull/353) +* Fixed call to non-existent property in Memcache. [#311](https://github.com/simplepie/simplepie/pull/311) +* Fixed a bug where MySQL statements were not being passed thorugh `prepare()`. [#348](https://github.com/simplepie/simplepie/pull/348) +* Fixed an instance where an error message in `SimplePie` was not being triggered correctly. [#348](https://github.com/simplepie/simplepie/pull/348) +* Fixed a bug with Russian feeds. [#348](https://github.com/simplepie/simplepie/pull/348) +* Fixed an issue with memory leaks. [#287](https://github.com/simplepie/simplepie/pull/287) +* Fixed use of `DOMElement` as array. [#315](https://github.com/simplepie/simplepie/pull/315) +* Improved the error message when a feed cannot be found. [#348](https://github.com/simplepie/simplepie/pull/348) diff --git a/lib/simplepie/README.markdown b/lib/simplepie/README.markdown index 5500f03c24b..ee8d08672cc 100644 --- a/lib/simplepie/README.markdown +++ b/lib/simplepie/README.markdown @@ -18,6 +18,22 @@ Requirements * PCRE support +PSR-16: Caching support +-------------- + +Since SimplePie 1.8.0 you can use the [PSR-16](https://www.php-fig.org/psr/psr-16/) cache from +[Symfony](https://symfony.com/doc/current/components/cache.html) +or [every other implementation](https://packagist.org/providers/psr/simple-cache-implementation). + +```php +$simplepie = new \SimplePie\SimplePie(); +$simplepie->set_cache( + new \Symfony\Component\Cache\Psr16Cache( + new \Symfony\Component\Cache\Adapter\FilesystemAdapter() + ), +); +``` + What comes in the package? -------------------------- 1. `src/` - SimplePie classes for use with the autoloader diff --git a/lib/simplepie/autoloader.php b/lib/simplepie/autoloader.php deleted file mode 100644 index a19c254766f..00000000000 --- a/lib/simplepie/autoloader.php +++ /dev/null @@ -1,128 +0,0 @@ -path = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'library'; - } - - /** - * Autoloader - * - * @param string $class The name of the class to attempt to load. - */ - public function autoload($class) - { - // Only load the class if it starts with "SimplePie" - if (strpos($class, 'SimplePie') !== 0) - { - return; - } - - $filename = $this->path . DIRECTORY_SEPARATOR . str_replace('_', DIRECTORY_SEPARATOR, $class) . '.php'; - include $filename; - } -} diff --git a/lib/simplepie/composer.json b/lib/simplepie/composer.json index cfede2b53b9..f0a800c8038 100644 --- a/lib/simplepie/composer.json +++ b/lib/simplepie/composer.json @@ -57,6 +57,7 @@ }, "config": { "bin-dir": "bin", + "lock": false, "sort-packages": true }, "scripts": { diff --git a/lib/simplepie/library/SimplePie.php b/lib/simplepie/library/SimplePie.php deleted file mode 100644 index 8a2b334e17a..00000000000 --- a/lib/simplepie/library/SimplePie.php +++ /dev/null @@ -1,488 +0,0 @@ - - * @link http://galvani.cz/ - * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version 0.2.9 - */ - -use SimplePie\Cache\Redis; - -class_exists('SimplePie\Cache\Redis'); - -// @trigger_error(sprintf('Using the "SimplePie_Cache_Redis" class is deprecated since SimplePie 1.7.0, use "SimplePie\Cache\Redis" instead.'), \E_USER_DEPRECATED); - -if (\false) { - /** @deprecated since SimplePie 1.7.0, use "SimplePie\Cache\Redis" instead */ - class SimplePie_Cache_Redis extends Redis - { - } -} diff --git a/lib/simplepie/library/SimplePie/Caption.php b/lib/simplepie/library/SimplePie/Caption.php deleted file mode 100644 index 6e96e11b2c0..00000000000 --- a/lib/simplepie/library/SimplePie/Caption.php +++ /dev/null @@ -1,57 +0,0 @@ -data = $data; - } - - /** - * Parse the input data - * - * @access public - * @return string Output data - */ - public function parse() - { - while (($this->position = strpos($this->data, '&', $this->position)) !== false) { - $this->consume(); - $this->entity(); - $this->consumed = ''; - } - return $this->data; - } - - /** - * Consume the next byte - * - * @access private - * @return mixed The next byte, or false, if there is no more data - */ - public function consume() - { - if (isset($this->data[$this->position])) { - $this->consumed .= $this->data[$this->position]; - return $this->data[$this->position++]; - } - - return false; - } - - /** - * Consume a range of characters - * - * @access private - * @param string $chars Characters to consume - * @return mixed A series of characters that match the range, or false - */ - public function consume_range($chars) - { - if ($len = strspn($this->data, $chars, $this->position)) { - $data = substr($this->data, $this->position, $len); - $this->consumed .= $data; - $this->position += $len; - return $data; - } - - return false; - } - - /** - * Unconsume one byte - * - * @access private - */ - public function unconsume() - { - $this->consumed = substr($this->consumed, 0, -1); - $this->position--; - } - - /** - * Decode an entity - * - * @access private - */ - public function entity() - { - switch ($this->consume()) { - case "\x09": - case "\x0A": - case "\x0B": - case "\x0C": - case "\x20": - case "\x3C": - case "\x26": - case false: - break; - - case "\x23": - switch ($this->consume()) { - case "\x78": - case "\x58": - $range = '0123456789ABCDEFabcdef'; - $hex = true; - break; - - default: - $range = '0123456789'; - $hex = false; - $this->unconsume(); - break; - } - - if ($codepoint = $this->consume_range($range)) { - static $windows_1252_specials = [0x0D => "\x0A", 0x80 => "\xE2\x82\xAC", 0x81 => "\xEF\xBF\xBD", 0x82 => "\xE2\x80\x9A", 0x83 => "\xC6\x92", 0x84 => "\xE2\x80\x9E", 0x85 => "\xE2\x80\xA6", 0x86 => "\xE2\x80\xA0", 0x87 => "\xE2\x80\xA1", 0x88 => "\xCB\x86", 0x89 => "\xE2\x80\xB0", 0x8A => "\xC5\xA0", 0x8B => "\xE2\x80\xB9", 0x8C => "\xC5\x92", 0x8D => "\xEF\xBF\xBD", 0x8E => "\xC5\xBD", 0x8F => "\xEF\xBF\xBD", 0x90 => "\xEF\xBF\xBD", 0x91 => "\xE2\x80\x98", 0x92 => "\xE2\x80\x99", 0x93 => "\xE2\x80\x9C", 0x94 => "\xE2\x80\x9D", 0x95 => "\xE2\x80\xA2", 0x96 => "\xE2\x80\x93", 0x97 => "\xE2\x80\x94", 0x98 => "\xCB\x9C", 0x99 => "\xE2\x84\xA2", 0x9A => "\xC5\xA1", 0x9B => "\xE2\x80\xBA", 0x9C => "\xC5\x93", 0x9D => "\xEF\xBF\xBD", 0x9E => "\xC5\xBE", 0x9F => "\xC5\xB8"]; - - if ($hex) { - $codepoint = hexdec($codepoint); - } else { - $codepoint = intval($codepoint); - } - - if (isset($windows_1252_specials[$codepoint])) { - $replacement = $windows_1252_specials[$codepoint]; - } else { - $replacement = SimplePie_Misc::codepoint_to_utf8($codepoint); - } - - if (!in_array($this->consume(), [';', false], true)) { - $this->unconsume(); - } - - $consumed_length = strlen($this->consumed); - $this->data = substr_replace($this->data, $replacement, $this->position - $consumed_length, $consumed_length); - $this->position += strlen($replacement) - $consumed_length; - } - break; - - default: - static $entities = [ - 'Aacute' => "\xC3\x81", - 'aacute' => "\xC3\xA1", - 'Aacute;' => "\xC3\x81", - 'aacute;' => "\xC3\xA1", - 'Acirc' => "\xC3\x82", - 'acirc' => "\xC3\xA2", - 'Acirc;' => "\xC3\x82", - 'acirc;' => "\xC3\xA2", - 'acute' => "\xC2\xB4", - 'acute;' => "\xC2\xB4", - 'AElig' => "\xC3\x86", - 'aelig' => "\xC3\xA6", - 'AElig;' => "\xC3\x86", - 'aelig;' => "\xC3\xA6", - 'Agrave' => "\xC3\x80", - 'agrave' => "\xC3\xA0", - 'Agrave;' => "\xC3\x80", - 'agrave;' => "\xC3\xA0", - 'alefsym;' => "\xE2\x84\xB5", - 'Alpha;' => "\xCE\x91", - 'alpha;' => "\xCE\xB1", - 'AMP' => "\x26", - 'amp' => "\x26", - 'AMP;' => "\x26", - 'amp;' => "\x26", - 'and;' => "\xE2\x88\xA7", - 'ang;' => "\xE2\x88\xA0", - 'apos;' => "\x27", - 'Aring' => "\xC3\x85", - 'aring' => "\xC3\xA5", - 'Aring;' => "\xC3\x85", - 'aring;' => "\xC3\xA5", - 'asymp;' => "\xE2\x89\x88", - 'Atilde' => "\xC3\x83", - 'atilde' => "\xC3\xA3", - 'Atilde;' => "\xC3\x83", - 'atilde;' => "\xC3\xA3", - 'Auml' => "\xC3\x84", - 'auml' => "\xC3\xA4", - 'Auml;' => "\xC3\x84", - 'auml;' => "\xC3\xA4", - 'bdquo;' => "\xE2\x80\x9E", - 'Beta;' => "\xCE\x92", - 'beta;' => "\xCE\xB2", - 'brvbar' => "\xC2\xA6", - 'brvbar;' => "\xC2\xA6", - 'bull;' => "\xE2\x80\xA2", - 'cap;' => "\xE2\x88\xA9", - 'Ccedil' => "\xC3\x87", - 'ccedil' => "\xC3\xA7", - 'Ccedil;' => "\xC3\x87", - 'ccedil;' => "\xC3\xA7", - 'cedil' => "\xC2\xB8", - 'cedil;' => "\xC2\xB8", - 'cent' => "\xC2\xA2", - 'cent;' => "\xC2\xA2", - 'Chi;' => "\xCE\xA7", - 'chi;' => "\xCF\x87", - 'circ;' => "\xCB\x86", - 'clubs;' => "\xE2\x99\xA3", - 'cong;' => "\xE2\x89\x85", - 'COPY' => "\xC2\xA9", - 'copy' => "\xC2\xA9", - 'COPY;' => "\xC2\xA9", - 'copy;' => "\xC2\xA9", - 'crarr;' => "\xE2\x86\xB5", - 'cup;' => "\xE2\x88\xAA", - 'curren' => "\xC2\xA4", - 'curren;' => "\xC2\xA4", - 'Dagger;' => "\xE2\x80\xA1", - 'dagger;' => "\xE2\x80\xA0", - 'dArr;' => "\xE2\x87\x93", - 'darr;' => "\xE2\x86\x93", - 'deg' => "\xC2\xB0", - 'deg;' => "\xC2\xB0", - 'Delta;' => "\xCE\x94", - 'delta;' => "\xCE\xB4", - 'diams;' => "\xE2\x99\xA6", - 'divide' => "\xC3\xB7", - 'divide;' => "\xC3\xB7", - 'Eacute' => "\xC3\x89", - 'eacute' => "\xC3\xA9", - 'Eacute;' => "\xC3\x89", - 'eacute;' => "\xC3\xA9", - 'Ecirc' => "\xC3\x8A", - 'ecirc' => "\xC3\xAA", - 'Ecirc;' => "\xC3\x8A", - 'ecirc;' => "\xC3\xAA", - 'Egrave' => "\xC3\x88", - 'egrave' => "\xC3\xA8", - 'Egrave;' => "\xC3\x88", - 'egrave;' => "\xC3\xA8", - 'empty;' => "\xE2\x88\x85", - 'emsp;' => "\xE2\x80\x83", - 'ensp;' => "\xE2\x80\x82", - 'Epsilon;' => "\xCE\x95", - 'epsilon;' => "\xCE\xB5", - 'equiv;' => "\xE2\x89\xA1", - 'Eta;' => "\xCE\x97", - 'eta;' => "\xCE\xB7", - 'ETH' => "\xC3\x90", - 'eth' => "\xC3\xB0", - 'ETH;' => "\xC3\x90", - 'eth;' => "\xC3\xB0", - 'Euml' => "\xC3\x8B", - 'euml' => "\xC3\xAB", - 'Euml;' => "\xC3\x8B", - 'euml;' => "\xC3\xAB", - 'euro;' => "\xE2\x82\xAC", - 'exist;' => "\xE2\x88\x83", - 'fnof;' => "\xC6\x92", - 'forall;' => "\xE2\x88\x80", - 'frac12' => "\xC2\xBD", - 'frac12;' => "\xC2\xBD", - 'frac14' => "\xC2\xBC", - 'frac14;' => "\xC2\xBC", - 'frac34' => "\xC2\xBE", - 'frac34;' => "\xC2\xBE", - 'frasl;' => "\xE2\x81\x84", - 'Gamma;' => "\xCE\x93", - 'gamma;' => "\xCE\xB3", - 'ge;' => "\xE2\x89\xA5", - 'GT' => "\x3E", - 'gt' => "\x3E", - 'GT;' => "\x3E", - 'gt;' => "\x3E", - 'hArr;' => "\xE2\x87\x94", - 'harr;' => "\xE2\x86\x94", - 'hearts;' => "\xE2\x99\xA5", - 'hellip;' => "\xE2\x80\xA6", - 'Iacute' => "\xC3\x8D", - 'iacute' => "\xC3\xAD", - 'Iacute;' => "\xC3\x8D", - 'iacute;' => "\xC3\xAD", - 'Icirc' => "\xC3\x8E", - 'icirc' => "\xC3\xAE", - 'Icirc;' => "\xC3\x8E", - 'icirc;' => "\xC3\xAE", - 'iexcl' => "\xC2\xA1", - 'iexcl;' => "\xC2\xA1", - 'Igrave' => "\xC3\x8C", - 'igrave' => "\xC3\xAC", - 'Igrave;' => "\xC3\x8C", - 'igrave;' => "\xC3\xAC", - 'image;' => "\xE2\x84\x91", - 'infin;' => "\xE2\x88\x9E", - 'int;' => "\xE2\x88\xAB", - 'Iota;' => "\xCE\x99", - 'iota;' => "\xCE\xB9", - 'iquest' => "\xC2\xBF", - 'iquest;' => "\xC2\xBF", - 'isin;' => "\xE2\x88\x88", - 'Iuml' => "\xC3\x8F", - 'iuml' => "\xC3\xAF", - 'Iuml;' => "\xC3\x8F", - 'iuml;' => "\xC3\xAF", - 'Kappa;' => "\xCE\x9A", - 'kappa;' => "\xCE\xBA", - 'Lambda;' => "\xCE\x9B", - 'lambda;' => "\xCE\xBB", - 'lang;' => "\xE3\x80\x88", - 'laquo' => "\xC2\xAB", - 'laquo;' => "\xC2\xAB", - 'lArr;' => "\xE2\x87\x90", - 'larr;' => "\xE2\x86\x90", - 'lceil;' => "\xE2\x8C\x88", - 'ldquo;' => "\xE2\x80\x9C", - 'le;' => "\xE2\x89\xA4", - 'lfloor;' => "\xE2\x8C\x8A", - 'lowast;' => "\xE2\x88\x97", - 'loz;' => "\xE2\x97\x8A", - 'lrm;' => "\xE2\x80\x8E", - 'lsaquo;' => "\xE2\x80\xB9", - 'lsquo;' => "\xE2\x80\x98", - 'LT' => "\x3C", - 'lt' => "\x3C", - 'LT;' => "\x3C", - 'lt;' => "\x3C", - 'macr' => "\xC2\xAF", - 'macr;' => "\xC2\xAF", - 'mdash;' => "\xE2\x80\x94", - 'micro' => "\xC2\xB5", - 'micro;' => "\xC2\xB5", - 'middot' => "\xC2\xB7", - 'middot;' => "\xC2\xB7", - 'minus;' => "\xE2\x88\x92", - 'Mu;' => "\xCE\x9C", - 'mu;' => "\xCE\xBC", - 'nabla;' => "\xE2\x88\x87", - 'nbsp' => "\xC2\xA0", - 'nbsp;' => "\xC2\xA0", - 'ndash;' => "\xE2\x80\x93", - 'ne;' => "\xE2\x89\xA0", - 'ni;' => "\xE2\x88\x8B", - 'not' => "\xC2\xAC", - 'not;' => "\xC2\xAC", - 'notin;' => "\xE2\x88\x89", - 'nsub;' => "\xE2\x8A\x84", - 'Ntilde' => "\xC3\x91", - 'ntilde' => "\xC3\xB1", - 'Ntilde;' => "\xC3\x91", - 'ntilde;' => "\xC3\xB1", - 'Nu;' => "\xCE\x9D", - 'nu;' => "\xCE\xBD", - 'Oacute' => "\xC3\x93", - 'oacute' => "\xC3\xB3", - 'Oacute;' => "\xC3\x93", - 'oacute;' => "\xC3\xB3", - 'Ocirc' => "\xC3\x94", - 'ocirc' => "\xC3\xB4", - 'Ocirc;' => "\xC3\x94", - 'ocirc;' => "\xC3\xB4", - 'OElig;' => "\xC5\x92", - 'oelig;' => "\xC5\x93", - 'Ograve' => "\xC3\x92", - 'ograve' => "\xC3\xB2", - 'Ograve;' => "\xC3\x92", - 'ograve;' => "\xC3\xB2", - 'oline;' => "\xE2\x80\xBE", - 'Omega;' => "\xCE\xA9", - 'omega;' => "\xCF\x89", - 'Omicron;' => "\xCE\x9F", - 'omicron;' => "\xCE\xBF", - 'oplus;' => "\xE2\x8A\x95", - 'or;' => "\xE2\x88\xA8", - 'ordf' => "\xC2\xAA", - 'ordf;' => "\xC2\xAA", - 'ordm' => "\xC2\xBA", - 'ordm;' => "\xC2\xBA", - 'Oslash' => "\xC3\x98", - 'oslash' => "\xC3\xB8", - 'Oslash;' => "\xC3\x98", - 'oslash;' => "\xC3\xB8", - 'Otilde' => "\xC3\x95", - 'otilde' => "\xC3\xB5", - 'Otilde;' => "\xC3\x95", - 'otilde;' => "\xC3\xB5", - 'otimes;' => "\xE2\x8A\x97", - 'Ouml' => "\xC3\x96", - 'ouml' => "\xC3\xB6", - 'Ouml;' => "\xC3\x96", - 'ouml;' => "\xC3\xB6", - 'para' => "\xC2\xB6", - 'para;' => "\xC2\xB6", - 'part;' => "\xE2\x88\x82", - 'permil;' => "\xE2\x80\xB0", - 'perp;' => "\xE2\x8A\xA5", - 'Phi;' => "\xCE\xA6", - 'phi;' => "\xCF\x86", - 'Pi;' => "\xCE\xA0", - 'pi;' => "\xCF\x80", - 'piv;' => "\xCF\x96", - 'plusmn' => "\xC2\xB1", - 'plusmn;' => "\xC2\xB1", - 'pound' => "\xC2\xA3", - 'pound;' => "\xC2\xA3", - 'Prime;' => "\xE2\x80\xB3", - 'prime;' => "\xE2\x80\xB2", - 'prod;' => "\xE2\x88\x8F", - 'prop;' => "\xE2\x88\x9D", - 'Psi;' => "\xCE\xA8", - 'psi;' => "\xCF\x88", - 'QUOT' => "\x22", - 'quot' => "\x22", - 'QUOT;' => "\x22", - 'quot;' => "\x22", - 'radic;' => "\xE2\x88\x9A", - 'rang;' => "\xE3\x80\x89", - 'raquo' => "\xC2\xBB", - 'raquo;' => "\xC2\xBB", - 'rArr;' => "\xE2\x87\x92", - 'rarr;' => "\xE2\x86\x92", - 'rceil;' => "\xE2\x8C\x89", - 'rdquo;' => "\xE2\x80\x9D", - 'real;' => "\xE2\x84\x9C", - 'REG' => "\xC2\xAE", - 'reg' => "\xC2\xAE", - 'REG;' => "\xC2\xAE", - 'reg;' => "\xC2\xAE", - 'rfloor;' => "\xE2\x8C\x8B", - 'Rho;' => "\xCE\xA1", - 'rho;' => "\xCF\x81", - 'rlm;' => "\xE2\x80\x8F", - 'rsaquo;' => "\xE2\x80\xBA", - 'rsquo;' => "\xE2\x80\x99", - 'sbquo;' => "\xE2\x80\x9A", - 'Scaron;' => "\xC5\xA0", - 'scaron;' => "\xC5\xA1", - 'sdot;' => "\xE2\x8B\x85", - 'sect' => "\xC2\xA7", - 'sect;' => "\xC2\xA7", - 'shy' => "\xC2\xAD", - 'shy;' => "\xC2\xAD", - 'Sigma;' => "\xCE\xA3", - 'sigma;' => "\xCF\x83", - 'sigmaf;' => "\xCF\x82", - 'sim;' => "\xE2\x88\xBC", - 'spades;' => "\xE2\x99\xA0", - 'sub;' => "\xE2\x8A\x82", - 'sube;' => "\xE2\x8A\x86", - 'sum;' => "\xE2\x88\x91", - 'sup;' => "\xE2\x8A\x83", - 'sup1' => "\xC2\xB9", - 'sup1;' => "\xC2\xB9", - 'sup2' => "\xC2\xB2", - 'sup2;' => "\xC2\xB2", - 'sup3' => "\xC2\xB3", - 'sup3;' => "\xC2\xB3", - 'supe;' => "\xE2\x8A\x87", - 'szlig' => "\xC3\x9F", - 'szlig;' => "\xC3\x9F", - 'Tau;' => "\xCE\xA4", - 'tau;' => "\xCF\x84", - 'there4;' => "\xE2\x88\xB4", - 'Theta;' => "\xCE\x98", - 'theta;' => "\xCE\xB8", - 'thetasym;' => "\xCF\x91", - 'thinsp;' => "\xE2\x80\x89", - 'THORN' => "\xC3\x9E", - 'thorn' => "\xC3\xBE", - 'THORN;' => "\xC3\x9E", - 'thorn;' => "\xC3\xBE", - 'tilde;' => "\xCB\x9C", - 'times' => "\xC3\x97", - 'times;' => "\xC3\x97", - 'TRADE;' => "\xE2\x84\xA2", - 'trade;' => "\xE2\x84\xA2", - 'Uacute' => "\xC3\x9A", - 'uacute' => "\xC3\xBA", - 'Uacute;' => "\xC3\x9A", - 'uacute;' => "\xC3\xBA", - 'uArr;' => "\xE2\x87\x91", - 'uarr;' => "\xE2\x86\x91", - 'Ucirc' => "\xC3\x9B", - 'ucirc' => "\xC3\xBB", - 'Ucirc;' => "\xC3\x9B", - 'ucirc;' => "\xC3\xBB", - 'Ugrave' => "\xC3\x99", - 'ugrave' => "\xC3\xB9", - 'Ugrave;' => "\xC3\x99", - 'ugrave;' => "\xC3\xB9", - 'uml' => "\xC2\xA8", - 'uml;' => "\xC2\xA8", - 'upsih;' => "\xCF\x92", - 'Upsilon;' => "\xCE\xA5", - 'upsilon;' => "\xCF\x85", - 'Uuml' => "\xC3\x9C", - 'uuml' => "\xC3\xBC", - 'Uuml;' => "\xC3\x9C", - 'uuml;' => "\xC3\xBC", - 'weierp;' => "\xE2\x84\x98", - 'Xi;' => "\xCE\x9E", - 'xi;' => "\xCE\xBE", - 'Yacute' => "\xC3\x9D", - 'yacute' => "\xC3\xBD", - 'Yacute;' => "\xC3\x9D", - 'yacute;' => "\xC3\xBD", - 'yen' => "\xC2\xA5", - 'yen;' => "\xC2\xA5", - 'yuml' => "\xC3\xBF", - 'Yuml;' => "\xC5\xB8", - 'yuml;' => "\xC3\xBF", - 'Zeta;' => "\xCE\x96", - 'zeta;' => "\xCE\xB6", - 'zwj;' => "\xE2\x80\x8D", - 'zwnj;' => "\xE2\x80\x8C" - ]; - - for ($i = 0, $match = null; $i < 9 && $this->consume() !== false; $i++) { - $consumed = substr($this->consumed, 1); - if (isset($entities[$consumed])) { - $match = $consumed; - } - } - - if ($match !== null) { - $this->data = substr_replace($this->data, $entities[$match], $this->position - strlen($consumed) - 1, strlen($match) + 1); - $this->position += strlen($entities[$match]) - strlen($consumed) - 1; - } - break; - } - } -} diff --git a/lib/simplepie/library/SimplePie/Enclosure.php b/lib/simplepie/library/SimplePie/Enclosure.php deleted file mode 100644 index a0e057511d6..00000000000 --- a/lib/simplepie/library/SimplePie/Enclosure.php +++ /dev/null @@ -1,57 +0,0 @@ -libdir.'/filelib.php'); +use SimplePie\SimplePie; +use SimplePie\File; +use SimplePie\Sanitize; +use SimplePie\HTTP\Parser; +use SimplePie\Misc; -// PLEASE NOTE: we use the simplepie class _unmodified_ -// through the joys of OO. Distros are free to use their stock -// version of this file. -require_once($CFG->libdir.'/simplepie/autoloader.php'); +require_once($CFG->libdir.'/filelib.php'); /** * Moodle Customised version of the SimplePie class @@ -46,7 +47,7 @@ require_once($CFG->libdir.'/simplepie/autoloader.php'); * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @since Moodle 2.0 */ -class moodle_simplepie extends SimplePie\SimplePie { +class moodle_simplepie extends SimplePie { /** * Constructor - creates an instance of the SimplePie class * with Moodle defaults. @@ -62,10 +63,10 @@ class moodle_simplepie extends SimplePie\SimplePie { // Use the Moodle class for http requests $registry = $this->get_registry(); - $registry->register(SimplePie\File::class, 'moodle_simplepie_file', true); + $registry->register(File::class, 'moodle_simplepie_file', true); // Use html purifier for text cleaning. - $registry->register(SimplePie\Sanitize::class, 'moodle_simplepie_sanitize', true); + $registry->register(Sanitize::class, 'moodle_simplepie_sanitize', true); $this->sanitize = new moodle_simplepie_sanitize(); // Match moodle encoding @@ -117,7 +118,7 @@ class moodle_simplepie extends SimplePie\SimplePie { * http requests. By using the moodle curl class * we ensure that the correct proxy configuration is used. */ -class moodle_simplepie_file extends SimplePie\File { +class moodle_simplepie_file extends File { /** * The constructor is a copy of the stock simplepie File class which has @@ -126,7 +127,7 @@ class moodle_simplepie_file extends SimplePie\File { */ public function __construct($url, $timeout = 10, $redirects = 5, $headers = null, $useragent = null, $force_fsockopen = false) { $this->url = $url; - $this->method = SimplePie\SimplePie::FILE_SOURCE_REMOTE | SimplePie\SimplePie::FILE_SOURCE_CURL; + $this->method = SimplePie::FILE_SOURCE_REMOTE | SimplePie::FILE_SOURCE_CURL; $curl = new curl(); $curl->setopt( array( @@ -151,7 +152,7 @@ class moodle_simplepie_file extends SimplePie\File { return false; } - $parser = new SimplePie\HTTP\Parser($this->headers); + $parser = new Parser($this->headers); if ($parser->parse()) { $this->headers = $parser->headers; @@ -163,7 +164,7 @@ class moodle_simplepie_file extends SimplePie\File { || $this->status_code == 307 || $this->status_code > 307 && $this->status_code < 400) && isset($this->headers['location']) && $this->redirects < $redirects) { $this->redirects++; - $location = SimplePie\Misc::absolutize_url($this->headers['location'], $url); + $location = Misc::absolutize_url($this->headers['location'], $url); return $this->__construct($location, $timeout, $redirects, $headers); } } @@ -174,7 +175,7 @@ class moodle_simplepie_file extends SimplePie\File { /** * Customised feed sanitization using HTMLPurifier. */ -class moodle_simplepie_sanitize extends SimplePie\Sanitize { +class moodle_simplepie_sanitize extends \SimplePie\Sanitize { public function sanitize($data, $type, $base = '') { $data = trim($data); @@ -182,20 +183,20 @@ class moodle_simplepie_sanitize extends SimplePie\Sanitize { return ''; } - if ($type & SimplePie\SimplePie::CONSTRUCT_BASE64){ + if ($type & SimplePie::CONSTRUCT_BASE64){ $data = base64_decode($data); } - if ($type & SimplePie\SimplePie::CONSTRUCT_MAYBE_HTML) { + if ($type & SimplePie::CONSTRUCT_MAYBE_HTML) { if (preg_match('/(&(#(x[0-9a-fA-F]+|[0-9]+)|[a-zA-Z0-9]+)|<\/[A-Za-z][^\x09\x0A\x0B\x0C\x0D\x20\x2F\x3E]*' - . SimplePie\SimplePie::PCRE_HTML_ATTRIBUTE . '>)/', $data)) { - $type |= SimplePie\SimplePie::CONSTRUCT_HTML; + . SimplePie::PCRE_HTML_ATTRIBUTE . '>)/', $data)) { + $type |= SimplePie::CONSTRUCT_HTML; } else { - $type |= SimplePie\SimplePie::CONSTRUCT_TEXT; + $type |= SimplePie::CONSTRUCT_TEXT; } } - if ($type & SimplePie\SimplePie::CONSTRUCT_IRI) { + if ($type & SimplePie::CONSTRUCT_IRI) { $absolute = $this->registry->call('Misc', 'absolutize_url', array($data, $base)); if ($absolute !== false) { $data = $absolute; @@ -203,17 +204,17 @@ class moodle_simplepie_sanitize extends SimplePie\Sanitize { $data = clean_param($data, PARAM_URL); } - if ($type & (SimplePie\SimplePie::CONSTRUCT_TEXT | SimplePie\SimplePie::CONSTRUCT_IRI)) { + if ($type & (SimplePie::CONSTRUCT_TEXT | SimplePie::CONSTRUCT_IRI)) { $data = htmlspecialchars($data, ENT_COMPAT, 'UTF-8'); } $data = purify_html($data); if ($this->remove_div) { - $data = preg_replace('/^/', '', $data); + $data = preg_replace('/^/', '', $data); $data = preg_replace('/<\/div>$/', '', $data); } else { - $data = preg_replace('/^/', '
', $data); + $data = preg_replace('/^/', '
', $data); } if ($this->output_encoding !== 'UTF-8') { diff --git a/lib/simplepie/readme_moodle.txt b/lib/simplepie/readme_moodle.txt index c50ee8ae33f..4343689ffec 100644 --- a/lib/simplepie/readme_moodle.txt +++ b/lib/simplepie/readme_moodle.txt @@ -7,16 +7,17 @@ To upgrade this library: 2. Remove everything inside lib/simplepie/ directory except readme_moodle.txt (this file) and moodle_simplepie.php. 3. Extract the contents of the release archive into a directory. 4. Move the following files/directories from the extracted directory into lib/simplepie: - - library/ - - src/ - - autoloader.php - - LICENSE.txt - - 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) - CHANGELOG.md - composer.json + - LICENSE.txt + - README.markdown + - src/ +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: + - autoloader.php - db.sql + - idn (This is a third-party library that SimplePie can optionally use. We don't use this in Moodle) + - library Changes: * None. This import contains _NO_CHANGES_ to the simplepie.inc file, changes are diff --git a/lib/simplepie/src/Author.php b/lib/simplepie/src/Author.php index f82a021e2f2..2cb7ad9ed06 100644 --- a/lib/simplepie/src/Author.php +++ b/lib/simplepie/src/Author.php @@ -1,6 +1,5 @@ cache->load(); - if (! is_array($data)) { + if (!is_array($data)) { return $default; } // ignore data if internal cache expiration time is not set - if (! array_key_exists('__cache_expiration_time', $data)) { + if (!array_key_exists('__cache_expiration_time', $data)) { return $default; } diff --git a/lib/simplepie/src/Cache/DB.php b/lib/simplepie/src/Cache/DB.php index 7994e32104b..a5357b26daf 100644 --- a/lib/simplepie/src/Cache/DB.php +++ b/lib/simplepie/src/Cache/DB.php @@ -1,6 +1,5 @@ data['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_10]['feed'][0])) { - $channel =& $data->data['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_10]['feed'][0]; + $channel = &$data->data['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_10]['feed'][0]; } elseif (isset($data->data['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_03]['feed'][0])) { - $channel =& $data->data['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_03]['feed'][0]; + $channel = &$data->data['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_03]['feed'][0]; } elseif (isset($data->data['child'][\SimplePie\SimplePie::NAMESPACE_RDF]['RDF'][0])) { - $channel =& $data->data['child'][\SimplePie\SimplePie::NAMESPACE_RDF]['RDF'][0]; + $channel = &$data->data['child'][\SimplePie\SimplePie::NAMESPACE_RDF]['RDF'][0]; } elseif (isset($data->data['child'][\SimplePie\SimplePie::NAMESPACE_RSS_20]['rss'][0]['child'][\SimplePie\SimplePie::NAMESPACE_RSS_20]['channel'][0])) { - $channel =& $data->data['child'][\SimplePie\SimplePie::NAMESPACE_RSS_20]['rss'][0]['child'][\SimplePie\SimplePie::NAMESPACE_RSS_20]['channel'][0]; + $channel = &$data->data['child'][\SimplePie\SimplePie::NAMESPACE_RSS_20]['rss'][0]['child'][\SimplePie\SimplePie::NAMESPACE_RSS_20]['channel'][0]; } else { $channel = null; } diff --git a/lib/simplepie/src/Cache/DataCache.php b/lib/simplepie/src/Cache/DataCache.php index bf3aebe9026..e7541324316 100644 --- a/lib/simplepie/src/Cache/DataCache.php +++ b/lib/simplepie/src/Cache/DataCache.php @@ -1,6 +1,5 @@ cache->get($key, $default); - if (! is_array($data) || $data === $default) { + if (!is_array($data) || $data === $default) { return $default; } diff --git a/lib/simplepie/src/Cache/Redis.php b/lib/simplepie/src/Cache/Redis.php index 0effccadb94..5997668c004 100644 --- a/lib/simplepie/src/Cache/Redis.php +++ b/lib/simplepie/src/Cache/Redis.php @@ -1,6 +1,5 @@ get_length(); if ($length !== null) { - return round($length/1048576, 2); + return round($length / 1048576, 2); } return null; @@ -812,7 +811,7 @@ class Enclosure * @param array|string $options See first parameter to {@see embed} * @return string HTML string to output */ - public function native_embed($options='') + public function native_embed($options = '') { return $this->embed($options, true); } @@ -943,9 +942,9 @@ class Enclosure if ($height === 'auto') { $width = 480; } elseif ($widescreen) { - $width = round((intval($height)/9)*16); + $width = round((intval($height) / 9) * 16); } else { - $width = round((intval($height)/3)*4); + $width = round((intval($height) / 3) * 4); } } else { $width = '100%'; @@ -963,9 +962,9 @@ class Enclosure $height = 360; } } elseif ($widescreen) { - $height = round((intval($width)/16)*9); + $height = round((intval($width) / 16) * 9); } else { - $height = round((intval($width)/4)*3); + $height = round((intval($width) / 4) * 3); } } else { $height = 376; @@ -1115,7 +1114,7 @@ class Enclosure $type = 'audio/x-ms-wma'; break; - // Video mime-types + // Video mime-types case '3gp': case '3gpp': $type = 'video/3gpp'; @@ -1178,7 +1177,7 @@ class Enclosure $type = 'video/x-ms-wvx'; break; - // Flash mime-types + // Flash mime-types case 'spl': $type = 'application/futuresplash'; break; diff --git a/lib/simplepie/src/Exception.php b/lib/simplepie/src/Exception.php index a20681f55f0..ae67ae38cd7 100644 --- a/lib/simplepie/src/Exception.php +++ b/lib/simplepie/src/Exception.php @@ -1,6 +1,5 @@ registry->call(Misc::class, 'is_isegment_nz_nc', [$key])) { if (isset($this->data['links'][\SimplePie\SimplePie::IANA_LINK_RELATIONS_REGISTRY . $key])) { $this->data['links'][\SimplePie\SimplePie::IANA_LINK_RELATIONS_REGISTRY . $key] = array_merge($this->data['links'][$key], $this->data['links'][\SimplePie\SimplePie::IANA_LINK_RELATIONS_REGISTRY . $key]); - $this->data['links'][$key] =& $this->data['links'][\SimplePie\SimplePie::IANA_LINK_RELATIONS_REGISTRY . $key]; + $this->data['links'][$key] = &$this->data['links'][\SimplePie\SimplePie::IANA_LINK_RELATIONS_REGISTRY . $key]; } else { - $this->data['links'][\SimplePie\SimplePie::IANA_LINK_RELATIONS_REGISTRY . $key] =& $this->data['links'][$key]; + $this->data['links'][\SimplePie\SimplePie::IANA_LINK_RELATIONS_REGISTRY . $key] = &$this->data['links'][$key]; } } elseif (substr($key, 0, 41) === \SimplePie\SimplePie::IANA_LINK_RELATIONS_REGISTRY) { - $this->data['links'][substr($key, 41)] =& $this->data['links'][$key]; + $this->data['links'][substr($key, 41)] = &$this->data['links'][$key]; } $this->data['links'][$key] = array_unique($this->data['links'][$key]); } diff --git a/lib/simplepie/src/Locator.php b/lib/simplepie/src/Locator.php index 1dc005b47ed..e17b3a37618 100644 --- a/lib/simplepie/src/Locator.php +++ b/lib/simplepie/src/Locator.php @@ -1,6 +1,5 @@ encoding, $this->separator); xml_parser_set_option($xml, XML_OPTION_SKIP_WHITE, 1); xml_parser_set_option($xml, XML_OPTION_CASE_FOLDING, 0); - xml_set_object($xml, $this); - xml_set_character_data_handler($xml, 'cdata'); - xml_set_element_handler($xml, 'tag_open', 'tag_close'); + xml_set_character_data_handler($xml, [$this, 'cdata']); + xml_set_element_handler($xml, [$this, 'tag_open'], [$this, 'tag_close']); // Parse! $wrapper = @is_writable(sys_get_temp_dir()) ? 'php://temp' : 'php://memory'; @@ -303,8 +301,8 @@ class Parser implements RegistryAware $this->data['data'] .= '>'; } } else { - $this->datas[] =& $this->data; - $this->data =& $this->data['child'][end($this->namespace)][end($this->element)][]; + $this->datas[] = &$this->data; + $this->data = &$this->data['child'][end($this->namespace)][end($this->element)][]; $this->data = ['data' => '', 'attribs' => $attribs, 'xml_base' => end($this->xml_base), 'xml_base_explicit' => end($this->xml_base_explicit), 'xml_lang' => end($this->xml_lang)]; if ((end($this->namespace) === \SimplePie\SimplePie::NAMESPACE_ATOM_03 && in_array(end($this->element), ['title', 'tagline', 'copyright', 'info', 'summary', 'content']) && isset($attribs['']['mode']) && $attribs['']['mode'] === 'xml') || (end($this->namespace) === \SimplePie\SimplePie::NAMESPACE_ATOM_10 && in_array(end($this->element), ['rights', 'subtitle', 'summary', 'info', 'title', 'content']) && isset($attribs['']['type']) && $attribs['']['type'] === 'xhtml') @@ -334,7 +332,7 @@ class Parser implements RegistryAware } } if ($this->current_xhtml_construct === -1) { - $this->data =& $this->datas[count($this->datas) - 1]; + $this->data = &$this->datas[count($this->datas) - 1]; array_pop($this->datas); } diff --git a/lib/simplepie/src/Rating.php b/lib/simplepie/src/Rating.php index f4f303d99f6..24c27337fb7 100644 --- a/lib/simplepie/src/Rating.php +++ b/lib/simplepie/src/Rating.php @@ -1,6 +1,5 @@ legacyTypes[$type]; } - if (! array_key_exists($type, $this->default)) { + if (!array_key_exists($type, $this->default)) { return false; } @@ -197,7 +196,7 @@ class Registry $type = $this->legacyTypes[$type]; } - if (! array_key_exists($type, $this->default)) { + if (!array_key_exists($type, $this->default)) { return null; } diff --git a/lib/simplepie/src/RegistryAware.php b/lib/simplepie/src/RegistryAware.php index 9d60bdd0f31..525d93140a8 100644 --- a/lib/simplepie/src/RegistryAware.php +++ b/lib/simplepie/src/RegistryAware.php @@ -1,6 +1,5 @@ registry = $registry; } - public function pass_cache_data($enable_cache = true, $cache_location = './cache', $cache_name_function = 'md5', $cache_class = 'SimplePie\Cache', DataCache $cache = null) + public function pass_cache_data($enable_cache = true, $cache_location = './cache', $cache_name_function = 'md5', $cache_class = 'SimplePie\Cache', ?DataCache $cache = null) { if (isset($enable_cache)) { $this->enable_cache = (bool) $enable_cache; @@ -143,7 +142,7 @@ class Sanitize implements RegistryAware $this->cache_location = (string) $cache_location; } - if (! is_string($cache_name_function) && ! is_object($cache_name_function) && ! $cache_name_function instanceof NameFilter) { + if (!is_string($cache_name_function) && !is_object($cache_name_function) && !$cache_name_function instanceof NameFilter) { throw new InvalidArgumentException(sprintf( '%s(): Argument #3 ($cache_name_function) must be of type %s', __METHOD__, @@ -297,7 +296,7 @@ class Sanitize implements RegistryAware foreach ($domains as $domain) { $domain = trim($domain, ". \t\n\r\0\x0B"); $segments = array_reverse(explode('.', $domain)); - $node =& $this->https_domains; + $node = &$this->https_domains; foreach ($segments as $segment) {//Build a tree if ($node === true) { break; @@ -305,7 +304,7 @@ class Sanitize implements RegistryAware if (!isset($node[$segment])) { $node[$segment] = []; } - $node =& $node[$segment]; + $node = &$node[$segment]; } $node = true; } @@ -318,10 +317,10 @@ class Sanitize implements RegistryAware { $domain = trim($domain, '. '); $segments = array_reverse(explode('.', $domain)); - $node =& $this->https_domains; + $node = &$this->https_domains; foreach ($segments as $segment) {//Explore the tree if (isset($node[$segment])) { - $node =& $node[$segment]; + $node = &$node[$segment]; } else { break; } diff --git a/lib/simplepie/src/SimplePie.php b/lib/simplepie/src/SimplePie.php index 1dfa39fadda..a0f6c17f442 100644 --- a/lib/simplepie/src/SimplePie.php +++ b/lib/simplepie/src/SimplePie.php @@ -1,6 +1,5 @@ set_useragent(); @@ -803,7 +801,7 @@ class SimplePie if ($file instanceof \SimplePie\File) { $this->feed_url = $file->url; $this->permanent_url = $this->feed_url; - $this->file =& $file; + $this->file = &$file; return true; } return false; @@ -1375,7 +1373,7 @@ class SimplePie } $this->sanitize->strip_htmltags($tags); if ($encode !== null) { - $this->sanitize->encode_instead_of_strip($tags); + $this->sanitize->encode_instead_of_strip($encode); } } @@ -1666,7 +1664,7 @@ class SimplePie // Cache the file if caching is enabled $this->data['cache_expiration_time'] = $this->cache_duration + time(); - if ($cache && ! $cache->set_data($this->get_cache_filename($this->feed_url), $this->data, $this->cache_duration)) { + if ($cache && !$cache->set_data($this->get_cache_filename($this->feed_url), $this->data, $this->cache_duration)) { trigger_error("$this->cache_location is not writable. Make sure you've set the correct relative or absolute path, and that the location is server-writable.", E_USER_WARNING); } return true; @@ -1716,7 +1714,7 @@ class SimplePie $cache = new BaseDataCache($cache); } - if ($cache !== false && ! $cache instanceof DataCache) { + if ($cache !== false && !$cache instanceof DataCache) { throw new InvalidArgumentException(sprintf( '%s(): Argument #1 ($cache) must be of type %s|false', __METHOD__, @@ -1774,7 +1772,7 @@ class SimplePie $headers['if-none-match'] = $this->data['headers']['etag']; } - $file = $this->registry->create(File::class, [$this->feed_url, $this->timeout/10, 5, $headers, $this->useragent, $this->force_fsockopen, $this->curl_options]); + $file = $this->registry->create(File::class, [$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) { @@ -1811,7 +1809,7 @@ class SimplePie // If we don't already have the file (it'll only exist if we've opened it to check if the cache has been modified), open it. if (!isset($file)) { if ($this->file instanceof \SimplePie\File && $this->file->url === $this->feed_url) { - $file =& $this->file; + $file = &$this->file; } else { $headers = [ 'Accept' => 'application/atom+xml, application/rss+xml, application/rdf+xml;q=0.9, application/xml;q=0.8, text/xml;q=0.8, text/html;q=0.7, unknown/unknown;q=0.1, application/unknown;q=0.1, */*;q=0.1', @@ -1833,7 +1831,7 @@ class SimplePie if (!$locate->is_feed($file)) { $copyStatusCode = $file->status_code; - $copyContentType = $file->headers['content-type']; + $copyContentType = $file->headers['content-type'] ?? ''; try { $microformats = false; if (class_exists('DOMXpath') && function_exists('Mf2\parse')) { @@ -2641,12 +2639,12 @@ class SimplePie if ($this->registry->call(Misc::class, 'is_isegment_nz_nc', [$key])) { if (isset($this->data['links'][self::IANA_LINK_RELATIONS_REGISTRY . $key])) { $this->data['links'][self::IANA_LINK_RELATIONS_REGISTRY . $key] = array_merge($this->data['links'][$key], $this->data['links'][self::IANA_LINK_RELATIONS_REGISTRY . $key]); - $this->data['links'][$key] =& $this->data['links'][self::IANA_LINK_RELATIONS_REGISTRY . $key]; + $this->data['links'][$key] = &$this->data['links'][self::IANA_LINK_RELATIONS_REGISTRY . $key]; } else { - $this->data['links'][self::IANA_LINK_RELATIONS_REGISTRY . $key] =& $this->data['links'][$key]; + $this->data['links'][self::IANA_LINK_RELATIONS_REGISTRY . $key] = &$this->data['links'][$key]; } } elseif (substr($key, 0, 41) === self::IANA_LINK_RELATIONS_REGISTRY) { - $this->data['links'][substr($key, 41)] =& $this->data['links'][$key]; + $this->data['links'][substr($key, 41)] = &$this->data['links'][$key]; } $this->data['links'][$key] = array_unique($this->data['links'][$key]); } @@ -3103,7 +3101,7 @@ class SimplePie $trace = debug_backtrace(); $file = $trace[0]['file']; $line = $trace[0]['line']; - trigger_error("Call to undefined method $class::$method() in $file on line $line", E_USER_ERROR); + throw new SimplePieException("Call to undefined method $class::$method() in $file on line $line"); } /** diff --git a/lib/simplepie/src/Source.php b/lib/simplepie/src/Source.php index c7ed11600c5..5a8f86de9f6 100644 --- a/lib/simplepie/src/Source.php +++ b/lib/simplepie/src/Source.php @@ -1,6 +1,5 @@ registry->call(Misc::class, 'is_isegment_nz_nc', [$key])) { if (isset($this->data['links'][\SimplePie\SimplePie::IANA_LINK_RELATIONS_REGISTRY . $key])) { $this->data['links'][\SimplePie\SimplePie::IANA_LINK_RELATIONS_REGISTRY . $key] = array_merge($this->data['links'][$key], $this->data['links'][\SimplePie\SimplePie::IANA_LINK_RELATIONS_REGISTRY . $key]); - $this->data['links'][$key] =& $this->data['links'][\SimplePie\SimplePie::IANA_LINK_RELATIONS_REGISTRY . $key]; + $this->data['links'][$key] = &$this->data['links'][\SimplePie\SimplePie::IANA_LINK_RELATIONS_REGISTRY . $key]; } else { - $this->data['links'][\SimplePie\SimplePie::IANA_LINK_RELATIONS_REGISTRY . $key] =& $this->data['links'][$key]; + $this->data['links'][\SimplePie\SimplePie::IANA_LINK_RELATIONS_REGISTRY . $key] = &$this->data['links'][$key]; } } elseif (substr($key, 0, 41) === \SimplePie\SimplePie::IANA_LINK_RELATIONS_REGISTRY) { - $this->data['links'][substr($key, 41)] =& $this->data['links'][$key]; + $this->data['links'][substr($key, 41)] = &$this->data['links'][$key]; } $this->data['links'][$key] = array_unique($this->data['links'][$key]); } diff --git a/lib/simplepie/src/XML/Declaration/Parser.php b/lib/simplepie/src/XML/Declaration/Parser.php index 5062e683f57..59a0d83eeaf 100644 --- a/lib/simplepie/src/XML/Declaration/Parser.php +++ b/lib/simplepie/src/XML/Declaration/Parser.php @@ -1,6 +1,5 @@ simplepie SimplePie Simple Pie helps with blogs. - 1.8.0 + 1.8.1 BSD https://github.com/simplepie/simplepie