// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
// SPDX-License-Identifier: BSD-3-Clause
use InvalidArgumentException;
use Psr\Http\Client\ClientInterface;
use Psr\Http\Message\RequestFactoryInterface;
use Psr\Http\Message\UriFactoryInterface;
use Psr\SimpleCache\CacheInterface;
use SimplePie\Cache\Base;
use SimplePie\Cache\BaseDataCache;
use SimplePie\Cache\CallableNameFilter;
use SimplePie\Cache\DataCache;
use SimplePie\Cache\NameFilter;
use SimplePie\Cache\Psr16;
use SimplePie\Content\Type\Sniffer;
use SimplePie\Exception as SimplePieException;
use SimplePie\HTTP\Client;
use SimplePie\HTTP\ClientException;
use SimplePie\HTTP\FileClient;
use SimplePie\HTTP\Psr18Client;
use SimplePie\HTTP\Response;
public const NAME = 'SimplePie';
public const VERSION = '1.9.0';
public const URL = 'http://simplepie.org';
public const LINKBACK = '<a href="' . self::URL . '" title="' . self::NAME . ' ' . self::VERSION . '">' . self::NAME . '</a>';
* @see SimplePie::set_autodiscovery_level()
public const LOCATOR_NONE = 0;
* Feed Link Element Autodiscovery
* @see SimplePie::set_autodiscovery_level()
public const LOCATOR_AUTODISCOVERY = 1;
* Local Feed Extension Autodiscovery
* @see SimplePie::set_autodiscovery_level()
public const LOCATOR_LOCAL_EXTENSION = 2;
* Local Feed Body Autodiscovery
* @see SimplePie::set_autodiscovery_level()
public const LOCATOR_LOCAL_BODY = 4;
* Remote Feed Extension Autodiscovery
* @see SimplePie::set_autodiscovery_level()
public const LOCATOR_REMOTE_EXTENSION = 8;
* Remote Feed Body Autodiscovery
* @see SimplePie::set_autodiscovery_level()
public const LOCATOR_REMOTE_BODY = 16;
* @see SimplePie::set_autodiscovery_level()
public const LOCATOR_ALL = 31;
public const TYPE_NONE = 0;
public const TYPE_RSS_090 = 1;
public const TYPE_RSS_091_NETSCAPE = 2;
public const TYPE_RSS_091_USERLAND = 4;
* RSS 0.91 (both Netscape and Userland)
public const TYPE_RSS_091 = 6;
public const TYPE_RSS_092 = 8;
public const TYPE_RSS_093 = 16;
public const TYPE_RSS_094 = 32;
public const TYPE_RSS_10 = 64;
public const TYPE_RSS_20 = 128;
public const TYPE_RSS_RDF = 65;
* Non-RDF-based RSS (truly intended as syndication format)
public const TYPE_RSS_SYNDICATION = 190;
public const TYPE_RSS_ALL = 255;
public const TYPE_ATOM_03 = 256;
public const TYPE_ATOM_10 = 512;
public const TYPE_ATOM_ALL = 768;
public const TYPE_ALL = 1023;
public const CONSTRUCT_NONE = 0;
public const CONSTRUCT_TEXT = 1;
public const CONSTRUCT_HTML = 2;
public const CONSTRUCT_XHTML = 4;
* base64-encoded construct
public const CONSTRUCT_BASE64 = 8;
public const CONSTRUCT_IRI = 16;
* A construct that might be HTML
public const CONSTRUCT_MAYBE_HTML = 32;
public const CONSTRUCT_ALL = 63;
public const SAME_CASE = 1;
public const LOWERCASE = 2;
public const UPPERCASE = 4;
* PCRE for HTML attributes
public const PCRE_HTML_ATTRIBUTE = '((?:[\x09\x0A\x0B\x0C\x0D\x20]+[^\x09\x0A\x0B\x0C\x0D\x20\x2F\x3E][^\x09\x0A\x0B\x0C\x0D\x20\x2F\x3D\x3E]*(?:[\x09\x0A\x0B\x0C\x0D\x20]*=[\x09\x0A\x0B\x0C\x0D\x20]*(?:"(?:[^"]*)"|\'(?:[^\']*)\'|(?:[^\x09\x0A\x0B\x0C\x0D\x20\x22\x27\x3E][^\x09\x0A\x0B\x0C\x0D\x20\x3E]*)?))?)*)[\x09\x0A\x0B\x0C\x0D\x20]*';
* PCRE for XML attributes
public const PCRE_XML_ATTRIBUTE = '((?:\s+(?:(?:[^\s:]+:)?[^\s:]+)\s*=\s*(?:"(?:[^"]*)"|\'(?:[^\']*)\'))*)\s*';
public const NAMESPACE_XML = 'http://www.w3.org/XML/1998/namespace';
public const NAMESPACE_ATOM_10 = 'http://www.w3.org/2005/Atom';
public const NAMESPACE_ATOM_03 = 'http://purl.org/atom/ns#';
public const NAMESPACE_RDF = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#';
public const NAMESPACE_RSS_090 = 'http://my.netscape.com/rdf/simple/0.9/';
public const NAMESPACE_RSS_10 = 'http://purl.org/rss/1.0/';
* RSS 1.0 Content Module Namespace
public const NAMESPACE_RSS_10_MODULES_CONTENT = 'http://purl.org/rss/1.0/modules/content/';
* (Stupid, I know, but I'm certain it will confuse people less with support.)
public const NAMESPACE_RSS_20 = '';
public const NAMESPACE_DC_10 = 'http://purl.org/dc/elements/1.0/';
public const NAMESPACE_DC_11 = 'http://purl.org/dc/elements/1.1/';
* W3C Basic Geo (WGS84 lat/long) Vocabulary Namespace
public const NAMESPACE_W3C_BASIC_GEO = 'http://www.w3.org/2003/01/geo/wgs84_pos#';
public const NAMESPACE_GEORSS = 'http://www.georss.org/georss';
public const NAMESPACE_MEDIARSS = 'http://search.yahoo.com/mrss/';
* Wrong Media RSS Namespace. Caused by a long-standing typo in the spec.
public const NAMESPACE_MEDIARSS_WRONG = 'http://search.yahoo.com/mrss';
* Wrong Media RSS Namespace #2. New namespace introduced in Media RSS 1.5.
public const NAMESPACE_MEDIARSS_WRONG2 = 'http://video.search.yahoo.com/mrss';
* Wrong Media RSS Namespace #3. A possible typo of the Media RSS 1.5 namespace.
public const NAMESPACE_MEDIARSS_WRONG3 = 'http://video.search.yahoo.com/mrss/';
* Wrong Media RSS Namespace #4. New spec location after the RSS Advisory Board takes it over, but not a valid namespace.
public const NAMESPACE_MEDIARSS_WRONG4 = 'http://www.rssboard.org/media-rss';
* Wrong Media RSS Namespace #5. A possible typo of the RSS Advisory Board URL.
public const NAMESPACE_MEDIARSS_WRONG5 = 'http://www.rssboard.org/media-rss/';
public const NAMESPACE_ITUNES = 'http://www.itunes.com/dtds/podcast-1.0.dtd';
public const NAMESPACE_XHTML = 'http://www.w3.org/1999/xhtml';
* IANA Link Relations Registry
public const IANA_LINK_RELATIONS_REGISTRY = 'http://www.iana.org/assignments/relation/';
public const FILE_SOURCE_NONE = 0;
public const FILE_SOURCE_REMOTE = 1;
public const FILE_SOURCE_LOCAL = 2;
* fsockopen() file source
public const FILE_SOURCE_FSOCKOPEN = 4;
public const FILE_SOURCE_CURL = 8;
* file_get_contents() file source
public const FILE_SOURCE_FILE_GET_CONTENTS = 16;
* @internal Default value of the HTTP Accept header when fetching/locating feeds
public const DEFAULT_HTTP_ACCEPT_HEADER = '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';
* @var array<string, mixed> Raw data
* @var string|string[]|null Error string (or array when multiple feeds are initialized)
* @var int HTTP status code
* @see SimplePie::status_code()
* @var Sanitize instance of Sanitize class
* @see SimplePie::set_sanitize_class()
* @var string SimplePie Useragent
* @see SimplePie::set_useragent()
* @see SimplePie::set_feed_url()
* @var ?string Original feed URL, or new feed URL iff HTTP 301 Moved Permanently
* @see SimplePie::subscribe_url()
public $permanent_url = null;
* @var File Instance of File class to use as a feed
* @see SimplePie::set_file()
* @var string|false Raw feed data
* @see SimplePie::set_raw_data()
* @var int Timeout for fetching remote files
* @see SimplePie::set_timeout()
* @var array<int, mixed> Custom curl options
* @see SimplePie::set_curl_options()
public $curl_options = [];
* @var bool Forces fsockopen() to be used for remote files instead
* of cURL, even if a new enough version is installed
* @see SimplePie::force_fsockopen()
public $force_fsockopen = false;
* @var bool Force the given data/URL to be treated as a feed no matter what
* @see SimplePie::force_feed()
public $force_feed = false;
* @var bool Enable/Disable Caching
* @see SimplePie::enable_cache()
private $enable_cache = true;
* @see SimplePie::set_cache()
* @see SimplePie::set_cache_namefilter()
private $cache_namefilter;
* @var bool Force SimplePie to fallback to expired cache, if enabled,
* when feed is unavailable.
* @see SimplePie::force_cache_fallback()