summaryrefslogtreecommitdiff
path: root/vendor/miniflux/picofeed/lib/PicoFeed/Parser
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/miniflux/picofeed/lib/PicoFeed/Parser')
-rw-r--r--vendor/miniflux/picofeed/lib/PicoFeed/Parser/Atom.php382
-rw-r--r--vendor/miniflux/picofeed/lib/PicoFeed/Parser/DateParser.php128
-rw-r--r--vendor/miniflux/picofeed/lib/PicoFeed/Parser/Feed.php315
-rw-r--r--vendor/miniflux/picofeed/lib/PicoFeed/Parser/Item.php534
-rw-r--r--vendor/miniflux/picofeed/lib/PicoFeed/Parser/MalformedXmlException.php13
-rw-r--r--vendor/miniflux/picofeed/lib/PicoFeed/Parser/Parser.php404
-rw-r--r--vendor/miniflux/picofeed/lib/PicoFeed/Parser/ParserException.php15
-rw-r--r--vendor/miniflux/picofeed/lib/PicoFeed/Parser/ParserInterface.php182
-rw-r--r--vendor/miniflux/picofeed/lib/PicoFeed/Parser/Rss10.php306
-rw-r--r--vendor/miniflux/picofeed/lib/PicoFeed/Parser/Rss20.php319
-rw-r--r--vendor/miniflux/picofeed/lib/PicoFeed/Parser/Rss91.php13
-rw-r--r--vendor/miniflux/picofeed/lib/PicoFeed/Parser/Rss92.php13
-rw-r--r--vendor/miniflux/picofeed/lib/PicoFeed/Parser/XmlEntityException.php13
-rw-r--r--vendor/miniflux/picofeed/lib/PicoFeed/Parser/XmlParser.php246
14 files changed, 0 insertions, 2883 deletions
diff --git a/vendor/miniflux/picofeed/lib/PicoFeed/Parser/Atom.php b/vendor/miniflux/picofeed/lib/PicoFeed/Parser/Atom.php
deleted file mode 100644
index 1c570a08..00000000
--- a/vendor/miniflux/picofeed/lib/PicoFeed/Parser/Atom.php
+++ /dev/null
@@ -1,382 +0,0 @@
-<?php
-
-namespace PicoFeed\Parser;
-
-use SimpleXMLElement;
-use PicoFeed\Filter\Filter;
-use PicoFeed\Client\Url;
-
-/**
- * Atom parser.
- *
- * @package PicoFeed\Parser
- * @author Frederic Guillot
- */
-class Atom extends Parser
-{
- /**
- * Supported namespaces.
- */
- protected $namespaces = array(
- 'atom' => 'http://www.w3.org/2005/Atom',
- );
-
- /**
- * Get the path to the items XML tree.
- *
- * @param SimpleXMLElement $xml Feed xml
- *
- * @return SimpleXMLElement
- */
- public function getItemsTree(SimpleXMLElement $xml)
- {
- return XmlParser::getXPathResult($xml, 'atom:entry', $this->namespaces)
- ?: XmlParser::getXPathResult($xml, 'entry');
- }
-
- /**
- * Find the feed url.
- *
- * @param SimpleXMLElement $xml Feed xml
- * @param \PicoFeed\Parser\Feed $feed Feed object
- */
- public function findFeedUrl(SimpleXMLElement $xml, Feed $feed)
- {
- $feed->setFeedUrl($this->getUrl($xml, 'self'));
- }
-
- /**
- * Find the site url.
- *
- * @param SimpleXMLElement $xml Feed xml
- * @param \PicoFeed\Parser\Feed $feed Feed object
- */
- public function findSiteUrl(SimpleXMLElement $xml, Feed $feed)
- {
- $feed->setSiteUrl($this->getUrl($xml, 'alternate', true));
- }
-
- /**
- * Find the feed description.
- *
- * @param SimpleXMLElement $xml Feed xml
- * @param \PicoFeed\Parser\Feed $feed Feed object
- */
- public function findFeedDescription(SimpleXMLElement $xml, Feed $feed)
- {
- $description = XmlParser::getXPathResult($xml, 'atom:subtitle', $this->namespaces)
- ?: XmlParser::getXPathResult($xml, 'subtitle');
-
- $feed->setDescription(XmlParser::getValue($description));
- }
-
- /**
- * Find the feed logo url.
- *
- * @param SimpleXMLElement $xml Feed xml
- * @param \PicoFeed\Parser\Feed $feed Feed object
- */
- public function findFeedLogo(SimpleXMLElement $xml, Feed $feed)
- {
- $logo = XmlParser::getXPathResult($xml, 'atom:logo', $this->namespaces)
- ?: XmlParser::getXPathResult($xml, 'logo');
-
- $feed->setLogo(XmlParser::getValue($logo));
- }
-
- /**
- * Find the feed icon.
- *
- * @param SimpleXMLElement $xml Feed xml
- * @param \PicoFeed\Parser\Feed $feed Feed object
- */
- public function findFeedIcon(SimpleXMLElement $xml, Feed $feed)
- {
- $icon = XmlParser::getXPathResult($xml, 'atom:icon', $this->namespaces)
- ?: XmlParser::getXPathResult($xml, 'icon');
-
- $feed->setIcon(XmlParser::getValue($icon));
- }
-
- /**
- * Find the feed title.
- *
- * @param SimpleXMLElement $xml Feed xml
- * @param \PicoFeed\Parser\Feed $feed Feed object
- */
- public function findFeedTitle(SimpleXMLElement $xml, Feed $feed)
- {
- $title = XmlParser::getXPathResult($xml, 'atom:title', $this->namespaces)
- ?: XmlParser::getXPathResult($xml, 'title');
-
- $feed->setTitle(Filter::stripWhiteSpace(XmlParser::getValue($title)) ?: $feed->getSiteUrl());
- }
-
- /**
- * Find the feed language.
- *
- * @param SimpleXMLElement $xml Feed xml
- * @param \PicoFeed\Parser\Feed $feed Feed object
- */
- public function findFeedLanguage(SimpleXMLElement $xml, Feed $feed)
- {
- $language = XmlParser::getXPathResult($xml, '*[not(self::atom:entry)]/@xml:lang', $this->namespaces)
- ?: XmlParser::getXPathResult($xml, '@xml:lang');
-
- $feed->setLanguage(XmlParser::getValue($language));
- }
-
- /**
- * Find the feed id.
- *
- * @param SimpleXMLElement $xml Feed xml
- * @param \PicoFeed\Parser\Feed $feed Feed object
- */
- public function findFeedId(SimpleXMLElement $xml, Feed $feed)
- {
- $id = XmlParser::getXPathResult($xml, 'atom:id', $this->namespaces)
- ?: XmlParser::getXPathResult($xml, 'id');
-
- $feed->setId(XmlParser::getValue($id));
- }
-
- /**
- * Find the feed date.
- *
- * @param SimpleXMLElement $xml Feed xml
- * @param \PicoFeed\Parser\Feed $feed Feed object
- */
- public function findFeedDate(SimpleXMLElement $xml, Feed $feed)
- {
- $updated = XmlParser::getXPathResult($xml, 'atom:updated', $this->namespaces)
- ?: XmlParser::getXPathResult($xml, 'updated');
-
- $feed->setDate($this->getDateParser()->getDateTime(XmlParser::getValue($updated)));
- }
-
- /**
- * Find the item published date.
- *
- * @param SimpleXMLElement $entry Feed item
- * @param Item $item Item object
- * @param \PicoFeed\Parser\Feed $feed Feed object
- */
- public function findItemPublishedDate(SimpleXMLElement $entry, Item $item, Feed $feed)
- {
- $date = XmlParser::getXPathResult($entry, 'atom:published', $this->namespaces)
- ?: XmlParser::getXPathResult($entry, 'published');
-
- $item->setPublishedDate(!empty($date) ? $this->getDateParser()->getDateTime((string) current($date)) : null);
- }
-
- /**
- * Find the item updated date.
- *
- * @param SimpleXMLElement $entry Feed item
- * @param Item $item Item object
- * @param \PicoFeed\Parser\Feed $feed Feed object
- */
- public function findItemUpdatedDate(SimpleXMLElement $entry, Item $item, Feed $feed)
- {
- $date = XmlParser::getXPathResult($entry, 'atom:updated', $this->namespaces)
- ?: XmlParser::getXPathResult($entry, 'updated');
-
- $item->setUpdatedDate(!empty($date) ? $this->getDateParser()->getDateTime((string) current($date)) : null);
- }
-
- /**
- * Find the item title.
- *
- * @param SimpleXMLElement $entry Feed item
- * @param Item $item Item object
- */
- public function findItemTitle(SimpleXMLElement $entry, Item $item)
- {
- $title = XmlParser::getXPathResult($entry, 'atom:title', $this->namespaces)
- ?: XmlParser::getXPathResult($entry, 'title');
-
- $item->setTitle(Filter::stripWhiteSpace(XmlParser::getValue($title)) ?: $item->getUrl());
- }
-
- /**
- * Find the item author.
- *
- * @param SimpleXMLElement $xml Feed
- * @param SimpleXMLElement $entry Feed item
- * @param \PicoFeed\Parser\Item $item Item object
- */
- public function findItemAuthor(SimpleXMLElement $xml, SimpleXMLElement $entry, Item $item)
- {
- $author = XmlParser::getXPathResult($entry, 'atom:author/atom:name', $this->namespaces)
- ?: XmlParser::getXPathResult($entry, 'author/name')
- ?: XmlParser::getXPathResult($xml, 'atom:author/atom:name', $this->namespaces)
- ?: XmlParser::getXPathResult($xml, 'author/name');
-
- $item->setAuthor(XmlParser::getValue($author));
- }
-
- /**
- * Find the item content.
- *
- * @param SimpleXMLElement $entry Feed item
- * @param \PicoFeed\Parser\Item $item Item object
- */
- public function findItemContent(SimpleXMLElement $entry, Item $item)
- {
- $item->setContent($this->getContent($entry));
- }
-
- /**
- * Find the item URL.
- *
- * @param SimpleXMLElement $entry Feed item
- * @param \PicoFeed\Parser\Item $item Item object
- */
- public function findItemUrl(SimpleXMLElement $entry, Item $item)
- {
- $item->setUrl($this->getUrl($entry, 'alternate', true));
- }
-
- /**
- * Genereate the item id.
- *
- * @param SimpleXMLElement $entry Feed item
- * @param \PicoFeed\Parser\Item $item Item object
- * @param \PicoFeed\Parser\Feed $feed Feed object
- */
- public function findItemId(SimpleXMLElement $entry, Item $item, Feed $feed)
- {
- $id = XmlParser::getXPathResult($entry, 'atom:id', $this->namespaces)
- ?: XmlParser::getXPathResult($entry, 'id');
-
- if (!empty($id)) {
- $item->setId($this->generateId(XmlParser::getValue($id)));
- } else {
- $item->setId($this->generateId(
- $item->getTitle(), $item->getUrl(), $item->getContent()
- ));
- }
- }
-
- /**
- * Find the item enclosure.
- *
- * @param SimpleXMLElement $entry Feed item
- * @param \PicoFeed\Parser\Item $item Item object
- * @param \PicoFeed\Parser\Feed $feed Feed object
- */
- public function findItemEnclosure(SimpleXMLElement $entry, Item $item, Feed $feed)
- {
- $enclosure = $this->findLink($entry, 'enclosure');
-
- if ($enclosure) {
- $item->setEnclosureUrl(Url::resolve((string) $enclosure['href'], $feed->getSiteUrl()));
- $item->setEnclosureType((string) $enclosure['type']);
- }
- }
-
- /**
- * Find the item language.
- *
- * @param SimpleXMLElement $entry Feed item
- * @param \PicoFeed\Parser\Item $item Item object
- * @param \PicoFeed\Parser\Feed $feed Feed object
- */
- public function findItemLanguage(SimpleXMLElement $entry, Item $item, Feed $feed)
- {
- $language = XmlParser::getXPathResult($entry, './/@xml:lang');
- $item->setLanguage(XmlParser::getValue($language) ?: $feed->getLanguage());
- }
-
- /**
- * Find the item categories.
- *
- * @param SimpleXMLElement $entry Feed item
- * @param Item $item Item object
- * @param Feed $feed Feed object
- */
- public function findItemCategories(SimpleXMLElement $entry, Item $item, Feed $feed)
- {
- $categories = XmlParser::getXPathResult($entry, 'atom:category/@term', $this->namespaces)
- ?: XmlParser::getXPathResult($entry, 'category/@term');
- $item->setCategoriesFromXml($categories);
- }
-
- /**
- * Get the URL from a link tag.
- *
- * @param SimpleXMLElement $xml XML tag
- * @param string $rel Link relationship: alternate, enclosure, related, self, via
- *
- * @return string
- */
- private function getUrl(SimpleXMLElement $xml, $rel, $fallback = false)
- {
- $link = $this->findLink($xml, $rel);
-
- if ($link) {
- return (string) $link['href'];
- }
-
- if ($fallback) {
- $link = $this->findLink($xml, '');
- return $link ? (string) $link['href'] : '';
- }
-
- return '';
- }
-
- /**
- * Get a link tag that match a relationship.
- *
- * @param SimpleXMLElement $xml XML tag
- * @param string $rel Link relationship: alternate, enclosure, related, self, via
- *
- * @return SimpleXMLElement|null
- */
- private function findLink(SimpleXMLElement $xml, $rel)
- {
- $links = XmlParser::getXPathResult($xml, 'atom:link', $this->namespaces)
- ?: XmlParser::getXPathResult($xml, 'link');
-
- foreach ($links as $link) {
- if ($rel === (string) $link['rel']) {
- return $link;
- }
- }
-
- return null;
- }
-
- /**
- * Get the entry content.
- *
- * @param SimpleXMLElement $entry XML Entry
- *
- * @return string
- */
- private function getContent(SimpleXMLElement $entry)
- {
- $content = current(
- XmlParser::getXPathResult($entry, 'atom:content', $this->namespaces)
- ?: XmlParser::getXPathResult($entry, 'content')
- );
-
- if (!empty($content) && count($content->children())) {
- $xml_string = '';
-
- foreach ($content->children() as $child) {
- $xml_string .= $child->asXML();
- }
-
- return $xml_string;
- } elseif (trim((string) $content) !== '') {
- return (string) $content;
- }
-
- $summary = XmlParser::getXPathResult($entry, 'atom:summary', $this->namespaces)
- ?: XmlParser::getXPathResult($entry, 'summary');
-
- return (string) current($summary);
- }
-}
diff --git a/vendor/miniflux/picofeed/lib/PicoFeed/Parser/DateParser.php b/vendor/miniflux/picofeed/lib/PicoFeed/Parser/DateParser.php
deleted file mode 100644
index 0e5b80e3..00000000
--- a/vendor/miniflux/picofeed/lib/PicoFeed/Parser/DateParser.php
+++ /dev/null
@@ -1,128 +0,0 @@
-<?php
-
-namespace PicoFeed\Parser;
-
-use DateTime;
-use DateTimeZone;
-use PicoFeed\Base;
-
-/**
- * Date Parser.
- *
- * @package PicoFeed\Parser
- * @author Frederic Guillot
- */
-class DateParser extends Base
-{
- /**
- * Timezone used to parse feed dates.
- *
- * @access private
- * @var string
- */
- private $timezone = 'UTC';
-
- /**
- * Supported formats [ 'format' => length ].
- *
- * @var array
- */
- public $formats = array(
- DATE_ATOM => null,
- DATE_RSS => null,
- DATE_COOKIE => null,
- DATE_ISO8601 => null,
- DATE_RFC822 => null,
- DATE_RFC850 => null,
- DATE_RFC1036 => null,
- DATE_RFC1123 => null,
- DATE_RFC2822 => null,
- DATE_RFC3339 => null,
- 'l, d M Y H:i:s' => null,
- 'D, d M Y H:i:s' => 25,
- 'D, d M Y h:i:s' => 25,
- 'D M d Y H:i:s' => 24,
- 'j M Y H:i:s' => 20,
- 'Y-m-d H:i:s' => 19,
- 'Y-m-d\TH:i:s' => 19,
- 'd/m/Y H:i:s' => 19,
- 'D, d M Y' => 16,
- 'Y-m-d' => 10,
- 'd-m-Y' => 10,
- 'm-d-Y' => 10,
- 'd.m.Y' => 10,
- 'm.d.Y' => 10,
- 'd/m/Y' => 10,
- 'm/d/Y' => 10,
- );
-
- /**
- * Try to parse all date format for broken feeds.
- *
- * @param string $value Original date format
- *
- * @return DateTime
- */
- public function getDateTime($value)
- {
- $value = trim($value);
-
- foreach ($this->formats as $format => $length) {
- $truncated_value = $value;
- if ($length !== null) {
- $truncated_value = substr($truncated_value, 0, $length);
- }
-
- $date = $this->getValidDate($format, $truncated_value);
- if ($date !== false) {
- return $date;
- }
- }
-
- return $this->getCurrentDateTime();
- }
-
- /**
- * Get a valid date from a given format.
- *
- * @param string $format Date format
- * @param string $value Original date value
- *
- * @return DateTime|bool
- */
- public function getValidDate($format, $value)
- {
- $date = DateTime::createFromFormat($format, $value, $this->getTimeZone());
-
- if ($date !== false) {
- $errors = DateTime::getLastErrors();
-
- if ($errors['error_count'] === 0 && $errors['warning_count'] === 0) {
- return $date;
- }
- }
-
- return false;
- }
-
- /**
- * Get the current datetime.
- *
- * @return DateTime
- */
- public function getCurrentDateTime()
- {
- return new DateTime('now', $this->getTimeZone());
- }
-
- /**
- * Get DateTimeZone instance
- *
- * @access public
- * @return DateTimeZone
- */
- public function getTimeZone()
- {
- return new DateTimeZone($this->config->getTimezone() ?: $this->timezone);
- }
-}
diff --git a/vendor/miniflux/picofeed/lib/PicoFeed/Parser/Feed.php b/vendor/miniflux/picofeed/lib/PicoFeed/Parser/Feed.php
deleted file mode 100644
index a56e71c3..00000000
--- a/vendor/miniflux/picofeed/lib/PicoFeed/Parser/Feed.php
+++ /dev/null
@@ -1,315 +0,0 @@
-<?php
-
-namespace PicoFeed\Parser;
-
-/**
- * Feed.
- *
- * @package PicoFeed\Parser
- * @author Frederic Guillot
- */
-class Feed
-{
- /**
- * Feed items.
- *
- * @var Item[]
- */
- public $items = array();
-
- /**
- * Feed id.
- *
- * @var string
- */
- public $id = '';
-
- /**
- * Feed title.
- *
- * @var string
- */
- public $title = '';
-
- /**
- * Feed description.
- *
- * @var string
- */
- public $description = '';
-
- /**
- * Feed url.
- *
- * @var string
- */
- public $feedUrl = '';
-
- /**
- * Site url.
- *
- * @var string
- */
- public $siteUrl = '';
-
- /**
- * Feed date.
- *
- * @var \DateTime
- */
- public $date = null;
-
- /**
- * Feed language.
- *
- * @var string
- */
- public $language = '';
-
- /**
- * Feed logo URL.
- *
- * @var string
- */
- public $logo = '';
-
- /**
- * Feed icon URL.
- *
- * @var string
- */
- public $icon = '';
-
- /**
- * Return feed information.
- */
- public function __toString()
- {
- $output = '';
-
- foreach (array('id', 'title', 'feedUrl', 'siteUrl', 'language', 'description', 'logo') as $property) {
- $output .= 'Feed::'.$property.' = '.$this->$property.PHP_EOL;
- }
-
- $output .= 'Feed::date = '.$this->date->format(DATE_RFC822).PHP_EOL;
- $output .= 'Feed::isRTL() = '.($this->isRTL() ? 'true' : 'false').PHP_EOL;
- $output .= 'Feed::items = '.count($this->items).' items'.PHP_EOL;
-
- foreach ($this->items as $item) {
- $output .= '----'.PHP_EOL;
- $output .= $item;
- }
-
- return $output;
- }
-
- /**
- * Get title.
- */
- public function getTitle()
- {
- return $this->title;
- }
-
- /**
- * Get description.
- */
- public function getDescription()
- {
- return $this->description;
- }
-
- /**
- * Get the logo url.
- */
- public function getLogo()
- {
- return $this->logo;
- }
-
- /**
- * Get the icon url.
- */
- public function getIcon()
- {
- return $this->icon;
- }
-
- /**
- * Get feed url.
- */
- public function getFeedUrl()
- {
- return $this->feedUrl;
- }
-
- /**
- * Get site url.
- */
- public function getSiteUrl()
- {
- return $this->siteUrl;
- }
-
- /**
- * Get date.
- */
- public function getDate()
- {
- return $this->date;
- }
-
- /**
- * Get language.
- */
- public function getLanguage()
- {
- return $this->language;
- }
-
- /**
- * Get id.
- */
- public function getId()
- {
- return $this->id;
- }
-
- /**
- * Get feed items.
- */
- public function getItems()
- {
- return $this->items;
- }
-
- /**
- * Return true if the feed is "Right to Left".
- *
- * @return bool
- */
- public function isRTL()
- {
- return Parser::isLanguageRTL($this->language);
- }
-
- /**
- * Set feed items.
- *
- * @param Item[] $items
- * @return Feed
- */
- public function setItems(array $items)
- {
- $this->items = $items;
- return $this;
- }
-
- /**
- * Set feed id.
- *
- * @param string $id
- * @return Feed
- */
- public function setId($id)
- {
- $this->id = $id;
- return $this;
- }
-
- /**
- * Set feed title.
- *
- * @param string $title
- * @return Feed
- */
- public function setTitle($title)
- {
- $this->title = $title;
- return $this;
- }
-
- /**
- * Set feed description.
- *
- * @param string $description
- * @return Feed
- */
- public function setDescription($description)
- {
- $this->description = $description;
- return $this;
- }
-
- /**
- * Set feed url.
- *
- * @param string $feedUrl
- * @return Feed
- */
- public function setFeedUrl($feedUrl)
- {
- $this->feedUrl = $feedUrl;
- return $this;
- }
-
- /**
- * Set feed website url.
- *
- * @param string $siteUrl
- * @return Feed
- */
- public function setSiteUrl($siteUrl)
- {
- $this->siteUrl = $siteUrl;
- return $this;
- }
-
- /**
- * Set feed date.
- *
- * @param \DateTime $date
- * @return Feed
- */
- public function setDate($date)
- {
- $this->date = $date;
- return $this;
- }
-
- /**
- * Set feed language.
- *
- * @param string $language
- * @return Feed
- */
- public function setLanguage($language)
- {
- $this->language = $language;
- return $this;
- }
-
- /**
- * Set feed logo.
- *
- * @param string $logo
- * @return Feed
- */
- public function setLogo($logo)
- {
- $this->logo = $logo;
- return $this;
- }
-
- /**
- * Set feed icon.
- *
- * @param string $icon
- * @return Feed
- */
- public function setIcon($icon)
- {
- $this->icon = $icon;
- return $this;
- }
-}
diff --git a/vendor/miniflux/picofeed/lib/PicoFeed/Parser/Item.php b/vendor/miniflux/picofeed/lib/PicoFeed/Parser/Item.php
deleted file mode 100644
index f9581941..00000000
--- a/vendor/miniflux/picofeed/lib/PicoFeed/Parser/Item.php
+++ /dev/null
@@ -1,534 +0,0 @@
-<?php
-
-namespace PicoFeed\Parser;
-
-/**
- * Feed Item.
- *
- * @package PicoFeed\Parser
- * @author Frederic Guillot
- */
-class Item
-{
- /**
- * List of known RTL languages.
- *
- * @var string[]
- */
- public $rtl = array(
- 'ar', // Arabic (ar-**)
- 'fa', // Farsi (fa-**)
- 'ur', // Urdu (ur-**)
- 'ps', // Pashtu (ps-**)
- 'syr', // Syriac (syr-**)
- 'dv', // Divehi (dv-**)
- 'he', // Hebrew (he-**)
- 'yi', // Yiddish (yi-**)
- );
-
- /**
- * Item id.
- *
- * @var string
- */
- public $id = '';
-
- /**
- * Item title.
- *
- * @var string
- */
- public $title = '';
-
- /**
- * Item url.
- *
- * @var string
- */
- public $url = '';
-
- /**
- * Item author.
- *
- * @var string
- */
- public $author = '';
-
- /**
- * Item date.
- *
- * @var \DateTime
- */
- public $date = null;
-
- /**
- * Item published date.
- *
- * @var \DateTime
- */
- public $publishedDate = null;
-
- /**
- * Item updated date.
- *
- * @var \DateTime
- */
- public $updatedDate = null;
-
- /**
- * Item content.
- *
- * @var string
- */
- public $content = '';
-
- /**
- * Item enclosure url.
- *
- * @var string
- */
- public $enclosureUrl = '';
-
- /**
- * Item enclusure type.
- *
- * @var string
- */
- public $enclosureType = '';
-
- /**
- * Item language.
- *
- * @var string
- */
- public $language = '';
-
- /**
- * Item categories.
- *
- * @var array
- */
- public $categories = array();
-
- /**
- * Raw XML.
- *
- * @var \SimpleXMLElement
- */
- public $xml;
-
- /**
- * List of namespaces.
- *
- * @var array
- */
- public $namespaces = array();
-
- /**
- * Check if a XML namespace exists
- *
- * @access public
- * @param string $namespace
- * @return bool
- */
- public function hasNamespace($namespace)
- {
- return array_key_exists($namespace, $this->namespaces);
- }
-
- /**
- * Get specific XML tag or attribute value.
- *
- * @param string $tag Tag name (examples: guid, media:content)
- * @param string $attribute Tag attribute
- *
- * @return array|false Tag values or error
- */
- public function getTag($tag, $attribute = '')
- {
- if ($attribute !== '') {
- $attribute = '/@'.$attribute;
- }
-
- $query = './/'.$tag.$attribute;
- $elements = XmlParser::getXPathResult($this->xml, $query, $this->namespaces);
-
- if ($elements === false) { // xPath error
- return false;
- }
-
- return array_map(function ($element) { return (string) $element;}, $elements);
- }
-
- /**
- * Return item information.
- *
- * @return string
- */
- public function __toString()
- {
- $output = '';
-
- foreach (array('id', 'title', 'url', 'language', 'author', 'enclosureUrl', 'enclosureType') as $property) {
- $output .= 'Item::'.$property.' = '.$this->$property.PHP_EOL;
- }
-
- $publishedDate = $this->publishedDate != null ? $this->publishedDate->format(DATE_RFC822) : null;
- $updatedDate = $this->updatedDate != null ? $this->updatedDate->format(DATE_RFC822) : null;
-
- $categoryString = $this->categories != null ? implode(',', $this->categories) : null;
-
- $output .= 'Item::date = '.$this->date->format(DATE_RFC822).PHP_EOL;
- $output .= 'Item::publishedDate = '.$publishedDate.PHP_EOL;
- $output .= 'Item::updatedDate = '.$updatedDate.PHP_EOL;
- $output .= 'Item::isRTL() = '.($this->isRTL() ? 'true' : 'false').PHP_EOL;
- $output .= 'Item::categories = ['.$categoryString.']'.PHP_EOL;
- $output .= 'Item::content = '.strlen($this->content).' bytes'.PHP_EOL;
-
- return $output;
- }
-
- /**
- * Get title.
- *
- * @return string
- */
- public function getTitle()
- {
- return $this->title;
- }
-
- /**
- * Get URL
- *
- * @access public
- * @return string
- */
- public function getUrl()
- {
- return $this->url;
- }
-
- /**
- * Set URL
- *
- * @access public
- * @param string $url
- * @return Item
- */
- public function setUrl($url)
- {
- $this->url = $url;
- return $this;
- }
-
- /**
- * Get id.
- *
- * @return string
- */
- public function getId()
- {
- return $this->id;
- }
-
- /**
- * Get date.
- *
- * @return \DateTime
- */
- public function getDate()
- {
- return $this->date;
- }
-
- /**
- * Get published date.
- *
- * @return \DateTime
- */
- public function getPublishedDate()
- {
- return $this->publishedDate;
- }
-
- /**
- * Get updated date.
- *
- * @return \DateTime
- */
- public function getUpdatedDate()
- {
- return $this->updatedDate;
- }
-
- /**
- * Get content.
- *
- * @return string
- */
- public function getContent()
- {
- return $this->content;
- }
-
- /**
- * Set content
- *
- * @access public
- * @param string $value
- * @return Item
- */
- public function setContent($value)
- {
- $this->content = $value;
- return $this;
- }
-
- /**
- * Get enclosure url.
- *
- * @return string
- */
- public function getEnclosureUrl()
- {
- return $this->enclosureUrl;
- }
-
- /**
- * Get enclosure type.
- *
- * @return string
- */
- public function getEnclosureType()
- {
- return $this->enclosureType;
- }
-
- /**
- * Get language.
- *
- * @return string
- */
- public function getLanguage()
- {
- return $this->language;
- }
-
- /**
- * Get categories.
- *
- * @return string
- */
- public function getCategories()
- {
- return $this->categories;
- }
-
- /**
- * Get author.
- *
- * @return string
- */
- public function getAuthor()
- {
- return $this->author;
- }
-
- /**
- * Return true if the item is "Right to Left".
- *
- * @return bool
- */
- public function isRTL()
- {
- return Parser::isLanguageRTL($this->language);
- }
-
- /**
- * Set item id.
- *
- * @param string $id
- * @return Item
- */
- public function setId($id)
- {
- $this->id = $id;
- return $this;
- }
-
- /**
- * Set item title.
- *
- * @param string $title
- * @return Item
- */
- public function setTitle($title)
- {
- $this->title = $title;
- return $this;
- }
-
- /**
- * Set author.
- *
- * @param string $author
- * @return Item
- */
- public function setAuthor($author)
- {
- $this->author = $author;
- return $this;
- }
-
- /**
- * Set item date.
- *
- * @param \DateTime $date
- * @return Item
- */
- public function setDate($date)
- {
- $this->date = $date;
- return $this;
- }
-
- /**
- * Set item published date.
- *
- * @param \DateTime $publishedDate
- * @return Item
- */
- public function setPublishedDate($publishedDate)
- {
- $this->publishedDate = $publishedDate;
- return $this;
- }
-
- /**
- * Set item updated date.
- *
- * @param \DateTime $updatedDate
- * @return Item
- */
- public function setUpdatedDate($updatedDate)
- {
- $this->updatedDate = $updatedDate;
- return $this;
- }
-
- /**
- * Set enclosure url.
- *
- * @param string $enclosureUrl
- * @return Item
- */
- public function setEnclosureUrl($enclosureUrl)
- {
- $this->enclosureUrl = $enclosureUrl;
- return $this;
- }
-
- /**
- * Set enclosure type.
- *
- * @param string $enclosureType
- * @return Item
- */
- public function setEnclosureType($enclosureType)
- {
- $this->enclosureType = $enclosureType;
- return $this;
- }
-
- /**
- * Set item language.
- *
- * @param string $language
- * @return Item
- */
- public function setLanguage($language)
- {
- $this->language = $language;
- return $this;
- }
-
- /**
- * Set item categories.
- *
- * @param array $categories
- * @return Item
- */
- public function setCategories($categories)
- {
- $this->categories = $categories;
- return $this;
- }
-
- /**
- * Set item categories from xml.
- *
- * @param SimpleXMLElement[] $categories
- * @return Item
- */
- public function setCategoriesFromXml($categories)
- {
- if ($categories !== false) {
- $this->setCategories(
- array_map(
- function ($element) {
- return trim((string) $element);
- },
- $categories
- )
- );
- } else {
- $categories = array();
- }
- return $this;
- }
-
- /**
- * Set raw XML.
- *
- * @param \SimpleXMLElement $xml
- * @return Item
- */
- public function setXml($xml)
- {
- $this->xml = $xml;
- return $this;
- }
-
- /**
- * Get raw XML.
- *
- * @return \SimpleXMLElement
- */
- public function getXml()
- {
- return $this->xml;
- }
-
- /**
- * Set XML namespaces.
- *
- * @param array $namespaces
- * @return Item
- */
- public function setNamespaces($namespaces)
- {
- $this->namespaces = $namespaces;
- return $this;
- }
-
- /**
- * Get XML namespaces.
- *
- * @return array
- */
- public function getNamespaces()
- {
- return $this->namespaces;
- }
-}
diff --git a/vendor/miniflux/picofeed/lib/PicoFeed/Parser/MalformedXmlException.php b/vendor/miniflux/picofeed/lib/PicoFeed/Parser/MalformedXmlException.php
deleted file mode 100644
index efaf0ff1..00000000
--- a/vendor/miniflux/picofeed/lib/PicoFeed/Parser/MalformedXmlException.php
+++ /dev/null
@@ -1,13 +0,0 @@
-<?php
-
-namespace PicoFeed\Parser;
-
-/**
- * MalformedXmlException Exception.
- *
- * @package PicoFeed\Parser
- * @author Frederic Guillot
- */
-class MalformedXmlException extends ParserException
-{
-}
diff --git a/vendor/miniflux/picofeed/lib/PicoFeed/Parser/Parser.php b/vendor/miniflux/picofeed/lib/PicoFeed/Parser/Parser.php
deleted file mode 100644
index 3ee99f59..00000000
--- a/vendor/miniflux/picofeed/lib/PicoFeed/Parser/Parser.php
+++ /dev/null
@@ -1,404 +0,0 @@
-<?php
-
-namespace PicoFeed\Parser;
-
-use PicoFeed\Processor\ContentFilterProcessor;
-use PicoFeed\Processor\ContentGeneratorProcessor;
-use PicoFeed\Processor\ItemPostProcessor;
-use PicoFeed\Processor\ScraperProcessor;
-use SimpleXMLElement;
-use PicoFeed\Client\Url;
-use PicoFeed\Encoding\Encoding;
-use PicoFeed\Filter\Filter;
-use PicoFeed\Logging\Logger;
-
-/**
- * Base parser class.
- *
- * @package PicoFeed\Parser
- * @author Frederic Guillot
- */
-abstract class Parser implements ParserInterface
-{
- /**
- * Config object.
- *
- * @var \PicoFeed\Config\Config
- */
- private $config;
-
- /**
- * DateParser object.
- *
- * @var \PicoFeed\Parser\DateParser
- */
- private $dateParser;
-
- /**
- * Hash algorithm used to generate item id, any value supported by PHP, see hash_algos().
- *
- * @var string
- */
- private $hash_algo = 'sha256';
-
- /**
- * Feed content (XML data).
- *
- * @var string
- */
- protected $content = '';
-
- /**
- * Fallback url.
- *
- * @var string
- */
- protected $fallback_url = '';
-
- /**
- * XML namespaces supported by parser.
- *
- * @var array
- */
- protected $namespaces = array();
-
- /**
- * XML namespaces used in document.
- *
- * @var array
- */
- protected $used_namespaces = array();
-
- /**
- * Item Post Processor instance
- *
- * @access private
- * @var ItemPostProcessor
- */
- private $itemPostProcessor;
-
- /**
- * Constructor.
- *
- * @param string $content Feed content
- * @param string $http_encoding HTTP encoding (headers)
- * @param string $fallback_url Fallback url when the feed provide relative or broken url
- */
- public function __construct($content, $http_encoding = '', $fallback_url = '')
- {
- $this->fallback_url = $fallback_url;
- $xml_encoding = XmlParser::getEncodingFromXmlTag($content);
-
- // Strip XML tag to avoid multiple encoding/decoding in the next XML processing
- $this->content = Filter::stripXmlTag($content);
-
- // Encode everything in UTF-8
- Logger::setMessage(get_called_class().': HTTP Encoding "'.$http_encoding.'" ; XML Encoding "'.$xml_encoding.'"');
- $this->content = Encoding::convert($this->content, $xml_encoding ?: $http_encoding);
-
- $this->itemPostProcessor = new ItemPostProcessor($this->config);
- $this->itemPostProcessor->register(new ContentGeneratorProcessor($this->config));
- $this->itemPostProcessor->register(new ContentFilterProcessor($this->config));
- }
-
- /**
- * Parse the document.
- *
- * @return \PicoFeed\Parser\Feed
- */
- public function execute()
- {
- Logger::setMessage(get_called_class().': begin parsing');
-
- $xml = XmlParser::getSimpleXml($this->content);
-
- if ($xml === false) {
- Logger::setMessage(get_called_class().': Applying XML workarounds');
- $this->content = Filter::normalizeData($this->content);
- $xml = XmlParser::getSimpleXml($this->content);
-
- if ($xml === false) {
- Logger::setMessage(get_called_class().': XML parsing error');
- Logger::setMessage(XmlParser::getErrors());
- throw new MalformedXmlException('XML parsing error');
- }
- }
-
- $this->used_namespaces = $xml->getNamespaces(true);
- $xml = $this->registerSupportedNamespaces($xml);
-
- $feed = new Feed();
-
- $this->findFeedUrl($xml, $feed);
- $this->checkFeedUrl($feed);
-
- $this->findSiteUrl($xml, $feed);
- $this->checkSiteUrl($feed);
-
- $this->findFeedTitle($xml, $feed);
- $this->findFeedDescription($xml, $feed);
- $this->findFeedLanguage($xml, $feed);
- $this->findFeedId($xml, $feed);
- $this->findFeedDate($xml, $feed);
- $this->findFeedLogo($xml, $feed);
- $this->findFeedIcon($xml, $feed);
-
- foreach ($this->getItemsTree($xml) as $entry) {
- $entry = $this->registerSupportedNamespaces($entry);
-
- $item = new Item();
- $item->xml = $entry;
- $item->namespaces = $this->used_namespaces;
-
- $this->findItemAuthor($xml, $entry, $item);
-
- $this->findItemUrl($entry, $item);
- $this->checkItemUrl($feed, $item);
-
- $this->findItemTitle($entry, $item);
- $this->findItemContent($entry, $item);
-
- // Id generation can use the item url/title/content (order is important)
- $this->findItemId($entry, $item, $feed);
- $this->findItemDate($entry, $item, $feed);
- $this->findItemEnclosure($entry, $item, $feed);
- $this->findItemLanguage($entry, $item, $feed);
- $this->findItemCategories($entry, $item, $feed);
-
- $this->itemPostProcessor->execute($feed, $item);
- $feed->items[] = $item;
- }
-
- Logger::setMessage(get_called_class().PHP_EOL.$feed);
-
- return $feed;
- }
-
- /**
- * Check if the feed url is correct.
- *
- * @param Feed $feed Feed object
- */
- public function checkFeedUrl(Feed $feed)
- {
- if ($feed->getFeedUrl() === '') {
- $feed->feedUrl = $this->fallback_url;
- } else {
- $feed->feedUrl = Url::resolve($feed->getFeedUrl(), $this->fallback_url);
- }
- }
-
- /**
- * Check if the site url is correct.
- *
- * @param Feed $feed Feed object
- */
- public function checkSiteUrl(Feed $feed)
- {
- if ($feed->getSiteUrl() === '') {
- $feed->siteUrl = Url::base($feed->getFeedUrl());
- } else {
- $feed->siteUrl = Url::resolve($feed->getSiteUrl(), $this->fallback_url);
- }
- }
-
- /**
- * Check if the item url is correct.
- *
- * @param Feed $feed Feed object
- * @param Item $item Item object
- */
- public function checkItemUrl(Feed $feed, Item $item)
- {
- $item->url = Url::resolve($item->getUrl(), $feed->getSiteUrl());
- }
-
- /**
- * Find the item date.
- *
- * @param SimpleXMLElement $entry Feed item
- * @param Item $item Item object
- * @param \PicoFeed\Parser\Feed $feed Feed object
- */
- public function findItemDate(SimpleXMLElement $entry, Item $item, Feed $feed)
- {
- $this->findItemPublishedDate($entry, $item, $feed);
- $this->findItemUpdatedDate($entry, $item, $feed);
-
- if ($item->getPublishedDate() === null) {
- // Use the updated date if available, otherwise use the feed date
- $item->setPublishedDate($item->getUpdatedDate() ?: $feed->getDate());
- }
-
- if ($item->getUpdatedDate() === null) {
- // Use the published date as fallback
- $item->setUpdatedDate($item->getPublishedDate());
- }
-
- // Use the most recent of published and updated dates
- $item->setDate(max($item->getPublishedDate(), $item->getUpdatedDate()));
- }
-
- /**
- * Get Item Post Processor instance
- *
- * @access public
- * @return ItemPostProcessor
- */
- public function getItemPostProcessor()
- {
- return $this->itemPostProcessor;
- }
-
- /**
- * Get DateParser instance
- *
- * @access public
- * @return DateParser
- */
- public function getDateParser()
- {
- if ($this->dateParser === null) {
- $this->dateParser = new DateParser($this->config);
- }
-
- return $this->dateParser;
- }
-
- /**
- * Generate a unique id for an entry (hash all arguments).
- *
- * @return string
- */
- public function generateId()
- {
- return hash($this->hash_algo, implode(func_get_args()));
- }
-
- /**
- * Return true if the given language is "Right to Left".
- *
- * @static
- *
- * @param string $language Language: fr-FR, en-US
- *
- * @return bool
- */
- public static function isLanguageRTL($language)
- {
- $language = strtolower($language);
-
- $rtl_languages = array(
- 'ar', // Arabic (ar-**)
- 'fa', // Farsi (fa-**)
- 'ur', // Urdu (ur-**)
- 'ps', // Pashtu (ps-**)
- 'syr', // Syriac (syr-**)
- 'dv', // Divehi (dv-**)
- 'he', // Hebrew (he-**)
- 'yi', // Yiddish (yi-**)
- );
-
- foreach ($rtl_languages as $prefix) {
- if (strpos($language, $prefix) === 0) {
- return true;
- }
- }
-
- return false;
- }
-
- /**
- * Set Hash algorithm used for id generation.
- *
- * @param string $algo Algorithm name
- * @return \PicoFeed\Parser\Parser
- */
- public function setHashAlgo($algo)
- {
- $this->hash_algo = $algo ?: $this->hash_algo;
- return $this;
- }
-
- /**
- * Set config object.
- *
- * @param \PicoFeed\Config\Config $config Config instance
- *
- * @return \PicoFeed\Parser\Parser
- */
- public function setConfig($config)
- {
- $this->config = $config;
- $this->itemPostProcessor->setConfig($config);
- return $this;
- }
-
- /**
- * Enable the content grabber.
- *
- * @return \PicoFeed\Parser\Parser
- */
- public function disableContentFiltering()
- {
- $this->itemPostProcessor->unregister('PicoFeed\Processor\ContentFilterProcessor');
- return $this;
- }
-
- /**
- * Enable the content grabber.
- *
- * @param bool $needsRuleFile true if only pages with rule files should be
- * scraped
- * @param null|\Closure $scraperCallback Callback function that gets called for each
- * scraper execution
- *
- * @return \PicoFeed\Parser\Parser
- */
- public function enableContentGrabber($needsRuleFile = false, $scraperCallback = null)
- {
- $processor = new ScraperProcessor($this->config);
-
- if ($needsRuleFile) {
- $processor->getScraper()->disableCandidateParser();
- }
-
- if ($scraperCallback !== null) {
- $processor->setExecutionCallback($scraperCallback);
- }
-
- $this->itemPostProcessor->register($processor);
- return $this;
- }
-
- /**
- * Set ignored URLs for the content grabber.
- *
- * @param array $urls URLs
- *
- * @return \PicoFeed\Parser\Parser
- */
- public function setGrabberIgnoreUrls(array $urls)
- {
- $this->itemPostProcessor->getProcessor('PicoFeed\Processor\ScraperProcessor')->ignoreUrls($urls);
- return $this;
- }
-
- /**
- * Register all supported namespaces to be used within an xpath query.
- *
- * @param SimpleXMLElement $xml Feed xml
- *
- * @return SimpleXMLElement
- */
- public function registerSupportedNamespaces(SimpleXMLElement $xml)
- {
- foreach ($this->namespaces as $prefix => $ns) {
- $xml->registerXPathNamespace($prefix, $ns);
- }
-
- return $xml;
- }
-
-
-}
diff --git a/vendor/miniflux/picofeed/lib/PicoFeed/Parser/ParserException.php b/vendor/miniflux/picofeed/lib/PicoFeed/Parser/ParserException.php
deleted file mode 100644
index b5fbb699..00000000
--- a/vendor/miniflux/picofeed/lib/PicoFeed/Parser/ParserException.php
+++ /dev/null
@@ -1,15 +0,0 @@
-<?php
-
-namespace PicoFeed\Parser;
-
-use PicoFeed\PicoFeedException;
-
-/**
- * ParserException Exception.
- *
- * @package PicoFeed\Parser
- * @author Frederic Guillot
- */
-abstract class ParserException extends PicoFeedException
-{
-}
diff --git a/vendor/miniflux/picofeed/lib/PicoFeed/Parser/ParserInterface.php b/vendor/miniflux/picofeed/lib/PicoFeed/Parser/ParserInterface.php
deleted file mode 100644
index 8d6be085..00000000
--- a/vendor/miniflux/picofeed/lib/PicoFeed/Parser/ParserInterface.php
+++ /dev/null
@@ -1,182 +0,0 @@
-<?php
-
-namespace PicoFeed\Parser;
-
-use SimpleXMLElement;
-
-/**
- * Interface ParserInterface
- *
- * @package PicoFeed\Parser
- * @author Frederic Guillot
- */
-interface ParserInterface
-{
- /**
- * Find the feed url.
- *
- * @param SimpleXMLElement $xml Feed xml
- * @param Feed $feed Feed object
- */
- public function findFeedUrl(SimpleXMLElement $xml, Feed $feed);
-
- /**
- * Find the site url.
- *
- * @param SimpleXMLElement $xml Feed xml
- * @param Feed $feed Feed object
- */
- public function findSiteUrl(SimpleXMLElement $xml, Feed $feed);
-
- /**
- * Find the feed title.
- *
- * @param SimpleXMLElement $xml Feed xml
- * @param Feed $feed Feed object
- */
- public function findFeedTitle(SimpleXMLElement $xml, Feed $feed);
-
- /**
- * Find the feed description.
- *
- * @param SimpleXMLElement $xml Feed xml
- * @param Feed $feed Feed object
- */
- public function findFeedDescription(SimpleXMLElement $xml, Feed $feed);
-
- /**
- * Find the feed language.
- *
- * @param SimpleXMLElement $xml Feed xml
- * @param Feed $feed Feed object
- */
- public function findFeedLanguage(SimpleXMLElement $xml, Feed $feed);
-
- /**
- * Find the feed id.
- *
- * @param SimpleXMLElement $xml Feed xml
- * @param Feed $feed Feed object
- */
- public function findFeedId(SimpleXMLElement $xml, Feed $feed);
-
- /**
- * Find the feed date.
- *
- * @param SimpleXMLElement $xml Feed xml
- * @param Feed $feed Feed object
- */
- public function findFeedDate(SimpleXMLElement $xml, Feed $feed);
-
- /**
- * Find the feed logo url.
- *
- * @param SimpleXMLElement $xml Feed xml
- * @param Feed $feed Feed object
- */
- public function findFeedLogo(SimpleXMLElement $xml, Feed $feed);
-
- /**
- * Find the feed icon.
- *
- * @param SimpleXMLElement $xml Feed xml
- * @param Feed $feed Feed object
- */
- public function findFeedIcon(SimpleXMLElement $xml, Feed $feed);
-
- /**
- * Get the path to the items XML tree.
- *
- * @param SimpleXMLElement $xml Feed xml
- *
- * @return SimpleXMLElement
- */
- public function getItemsTree(SimpleXMLElement $xml);
-
- /**
- * Find the item author.
- *
- * @param SimpleXMLElement $xml Feed
- * @param SimpleXMLElement $entry Feed item
- * @param Item $item Item object
- */
- public function findItemAuthor(SimpleXMLElement $xml, SimpleXMLElement $entry, Item $item);
-
- /**
- * Find the item URL.
- *
- * @param SimpleXMLElement $entry Feed item
- * @param Item $item Item object
- */
- public function findItemUrl(SimpleXMLElement $entry, Item $item);
-
- /**
- * Find the item title.
- *
- * @param SimpleXMLElement $entry Feed item
- * @param Item $item Item object
- */
- public function findItemTitle(SimpleXMLElement $entry, Item $item);
-
- /**
- * Genereate the item id.
- *
- * @param SimpleXMLElement $entry Feed item
- * @param Item $item Item object
- * @param Feed $feed Feed object
- */
- public function findItemId(SimpleXMLElement $entry, Item $item, Feed $feed);
-
- /**
- * Find the item published date.
- *
- * @param SimpleXMLElement $entry Feed item
- * @param Item $item Item object
- * @param Feed $feed Feed object
- */
- public function findItemPublishedDate(SimpleXMLElement $entry, Item $item, Feed $feed);
-
- /**
- * Find the item updated date.
- *
- * @param SimpleXMLElement $entry Feed item
- * @param Item $item Item object
- * @param Feed $feed Feed object
- */
- public function findItemUpdatedDate(SimpleXMLElement $entry, Item $item, Feed $feed);
-
- /**
- * Find the item content.
- *
- * @param SimpleXMLElement $entry Feed item
- * @param Item $item Item object
- */
- public function findItemContent(SimpleXMLElement $entry, Item $item);
-
- /**
- * Find the item enclosure.
- *
- * @param SimpleXMLElement $entry Feed item
- * @param Item $item Item object
- * @param Feed $feed Feed object
- */
- public function findItemEnclosure(SimpleXMLElement $entry, Item $item, Feed $feed);
-
- /**
- * Find the item language.
- *
- * @param SimpleXMLElement $entry Feed item
- * @param Item $item Item object
- * @param Feed $feed Feed object
- */
- public function findItemLanguage(SimpleXMLElement $entry, Item $item, Feed $feed);
-
- /**
- * Find the item categories.
- *
- * @param SimpleXMLElement $entry Feed item
- * @param Item $item Item object
- * @param Feed $feed Feed object
- */
- public function findItemCategories(SimpleXMLElement $entry, Item $item, Feed $feed);
-}
diff --git a/vendor/miniflux/picofeed/lib/PicoFeed/Parser/Rss10.php b/vendor/miniflux/picofeed/lib/PicoFeed/Parser/Rss10.php
deleted file mode 100644
index bb9bf424..00000000
--- a/vendor/miniflux/picofeed/lib/PicoFeed/Parser/Rss10.php
+++ /dev/null
@@ -1,306 +0,0 @@
-<?php
-
-namespace PicoFeed\Parser;
-
-use SimpleXMLElement;
-use PicoFeed\Filter\Filter;
-
-/**
- * RSS 1.0 parser.
- *
- * @package PicoFeed\Parser
- * @author Frederic Guillot
- */
-class Rss10 extends Parser
-{
- /**
- * Supported namespaces.
- */
- protected $namespaces = array(
- 'rss' => 'http://purl.org/rss/1.0/',
- 'dc' => 'http://purl.org/dc/elements/1.1/',
- 'content' => 'http://purl.org/rss/1.0/modules/content/',
- 'feedburner' => 'http://rssnamespace.org/feedburner/ext/1.0',
- );
-
- /**
- * Get the path to the items XML tree.
- *
- * @param SimpleXMLElement $xml Feed xml
- *
- * @return SimpleXMLElement
- */
- public function getItemsTree(SimpleXMLElement $xml)
- {
- return XmlParser::getXPathResult($xml, 'rss:item', $this->namespaces)
- ?: XmlParser::getXPathResult($xml, 'item')
- ?: $xml->item;
- }
-
- /**
- * Find the feed url.
- *
- * @param SimpleXMLElement $xml Feed xml
- * @param \PicoFeed\Parser\Feed $feed Feed object
- */
- public function findFeedUrl(SimpleXMLElement $xml, Feed $feed)
- {
- $feed->setFeedUrl('');
- }
-
- /**
- * Find the site url.
- *
- * @param SimpleXMLElement $xml Feed xml
- * @param \PicoFeed\Parser\Feed $feed Feed object
- */
- public function findSiteUrl(SimpleXMLElement $xml, Feed $feed)
- {
- $value = XmlParser::getXPathResult($xml, 'rss:channel/rss:link', $this->namespaces)
- ?: XmlParser::getXPathResult($xml, 'channel/link')
- ?: $xml->channel->link;
-
- $feed->setSiteUrl(XmlParser::getValue($value));
- }
-
- /**
- * Find the feed description.
- *
- * @param SimpleXMLElement $xml Feed xml
- * @param \PicoFeed\Parser\Feed $feed Feed object
- */
- public function findFeedDescription(SimpleXMLElement $xml, Feed $feed)
- {
- $description = XmlParser::getXPathResult($xml, 'rss:channel/rss:description', $this->namespaces)
- ?: XmlParser::getXPathResult($xml, 'channel/description')
- ?: $xml->channel->description;
-
- $feed->setDescription(XmlParser::getValue($description));
- }
-
- /**
- * Find the feed logo url.
- *
- * @param SimpleXMLElement $xml Feed xml
- * @param \PicoFeed\Parser\Feed $feed Feed object
- */
- public function findFeedLogo(SimpleXMLElement $xml, Feed $feed)
- {
- $logo = XmlParser::getXPathResult($xml, 'rss:image/rss:url', $this->namespaces)
- ?: XmlParser::getXPathResult($xml, 'image/url');
-
- $feed->setLogo(XmlParser::getValue($logo));
- }
-
- /**
- * Find the feed icon.
- *
- * @param SimpleXMLElement $xml Feed xml
- * @param \PicoFeed\Parser\Feed $feed Feed object
- */
- public function findFeedIcon(SimpleXMLElement $xml, Feed $feed)
- {
- $feed->setIcon('');
- }
-
- /**
- * Find the feed title.
- *
- * @param SimpleXMLElement $xml Feed xml
- * @param \PicoFeed\Parser\Feed $feed Feed object
- */
- public function findFeedTitle(SimpleXMLElement $xml, Feed $feed)
- {
- $title = XmlParser::getXPathResult($xml, 'rss:channel/rss:title', $this->namespaces)
- ?: XmlParser::getXPathResult($xml, 'channel/title')
- ?: $xml->channel->title;
-
- $feed->setTitle(Filter::stripWhiteSpace(XmlParser::getValue($title)) ?: $feed->getSiteUrl());
- }
-
- /**
- * Find the feed language.
- *
- * @param SimpleXMLElement $xml Feed xml
- * @param \PicoFeed\Parser\Feed $feed Feed object
- */
- public function findFeedLanguage(SimpleXMLElement $xml, Feed $feed)
- {
- $language = XmlParser::getXPathResult($xml, 'rss:channel/dc:language', $this->namespaces)
- ?: XmlParser::getXPathResult($xml, 'channel/dc:language', $this->namespaces);
-
- $feed->setLanguage(XmlParser::getValue($language));
- }
-
- /**
- * Find the feed id.
- *
- * @param SimpleXMLElement $xml Feed xml
- * @param \PicoFeed\Parser\Feed $feed Feed object
- */
- public function findFeedId(SimpleXMLElement $xml, Feed $feed)
- {
- $feed->setId($feed->getFeedUrl() ?: $feed->getSiteUrl());
- }
-
- /**
- * Find the feed date.
- *
- * @param SimpleXMLElement $xml Feed xml
- * @param \PicoFeed\Parser\Feed $feed Feed object
- */
- public function findFeedDate(SimpleXMLElement $xml, Feed $feed)
- {
- $date = XmlParser::getXPathResult($xml, 'rss:channel/dc:date', $this->namespaces)
- ?: XmlParser::getXPathResult($xml, 'channel/dc:date', $this->namespaces);
-
- $feed->setDate($this->getDateParser()->getDateTime(XmlParser::getValue($date)));
- }
-
- /**
- * Find the item published date.
- *
- * @param SimpleXMLElement $entry Feed item
- * @param Item $item Item object
- * @param \PicoFeed\Parser\Feed $feed Feed object
- */
- public function findItemPublishedDate(SimpleXMLElement $entry, Item $item, Feed $feed)
- {
- $date = XmlParser::getXPathResult($entry, 'dc:date', $this->namespaces);
-
- $item->setPublishedDate(!empty($date) ? $this->getDateParser()->getDateTime(XmlParser::getValue($date)) : null);
- }
-
- /**
- * Find the item updated date.
- *
- * @param SimpleXMLElement $entry Feed item
- * @param Item $item Item object
- * @param \PicoFeed\Parser\Feed $feed Feed object
- */
- public function findItemUpdatedDate(SimpleXMLElement $entry, Item $item, Feed $feed)
- {
- if ($item->publishedDate === null) {
- $this->findItemPublishedDate($entry, $item, $feed);
- }
- $item->setUpdatedDate($item->getPublishedDate()); // No updated date in RSS 1.0 specifications
- }
-
- /**
- * Find the item title.
- *
- * @param SimpleXMLElement $entry Feed item
- * @param \PicoFeed\Parser\Item $item Item object
- */
- public function findItemTitle(SimpleXMLElement $entry, Item $item)
- {
- $title = XmlParser::getXPathResult($entry, 'rss:title', $this->namespaces)
- ?: XmlParser::getXPathResult($entry, 'title')
- ?: $entry->title;
-
- $item->setTitle(Filter::stripWhiteSpace(XmlParser::getValue($title)) ?: $item->getUrl());
- }
-
- /**
- * Find the item author.
- *
- * @param SimpleXMLElement $xml Feed
- * @param SimpleXMLElement $entry Feed item
- * @param \PicoFeed\Parser\Item $item Item object
- */
- public function findItemAuthor(SimpleXMLElement $xml, SimpleXMLElement $entry, Item $item)
- {
- $author = XmlParser::getXPathResult($entry, 'dc:creator', $this->namespaces)
- ?: XmlParser::getXPathResult($xml, 'rss:channel/dc:creator', $this->namespaces)
- ?: XmlParser::getXPathResult($xml, 'channel/dc:creator', $this->namespaces);
-
- $item->setAuthor(XmlParser::getValue($author));
- }
-
- /**
- * Find the item content.
- *
- * @param SimpleXMLElement $entry Feed item
- * @param \PicoFeed\Parser\Item $item Item object
- */
- public function findItemContent(SimpleXMLElement $entry, Item $item)
- {
- $content = XmlParser::getXPathResult($entry, 'content:encoded', $this->namespaces);
-
- if (XmlParser::getValue($content) === '') {
- $content = XmlParser::getXPathResult($entry, 'rss:description', $this->namespaces)
- ?: XmlParser::getXPathResult($entry, 'description')
- ?: $entry->description;
- }
-
- $item->setContent(XmlParser::getValue($content));
- }
-
- /**
- * Find the item URL.
- *
- * @param SimpleXMLElement $entry Feed item
- * @param \PicoFeed\Parser\Item $item Item object
- */
- public function findItemUrl(SimpleXMLElement $entry, Item $item)
- {
- $link = XmlParser::getXPathResult($entry, 'feedburner:origLink', $this->namespaces)
- ?: XmlParser::getXPathResult($entry, 'rss:link', $this->namespaces)
- ?: XmlParser::getXPathResult($entry, 'link')
- ?: $entry->link;
-
- $item->setUrl(XmlParser::getValue($link));
- }
-
- /**
- * Genereate the item id.
- *
- * @param SimpleXMLElement $entry Feed item
- * @param \PicoFeed\Parser\Item $item Item object
- * @param \PicoFeed\Parser\Feed $feed Feed object
- */
- public function findItemId(SimpleXMLElement $entry, Item $item, Feed $feed)
- {
- $item->setId($this->generateId(
- $item->getTitle(), $item->getUrl(), $item->getContent()
- ));
- }
-
- /**
- * Find the item enclosure.
- *
- * @param SimpleXMLElement $entry Feed item
- * @param \PicoFeed\Parser\Item $item Item object
- * @param \PicoFeed\Parser\Feed $feed Feed object
- */
- public function findItemEnclosure(SimpleXMLElement $entry, Item $item, Feed $feed)
- {
- }
-
- /**
- * Find the item language.
- *
- * @param SimpleXMLElement $entry Feed item
- * @param \PicoFeed\Parser\Item $item Item object
- * @param \PicoFeed\Parser\Feed $feed Feed object
- */
- public function findItemLanguage(SimpleXMLElement $entry, Item $item, Feed $feed)
- {
- $language = XmlParser::getXPathResult($entry, 'dc:language', $this->namespaces);
-
- $item->setLanguage(XmlParser::getValue($language) ?: $feed->getLanguage());
- }
-
- /**
- * Find the item categories.
- *
- * @param SimpleXMLElement $entry Feed item
- * @param Item $item Item object
- * @param Feed $feed Feed object
- */
- public function findItemCategories(SimpleXMLElement $entry, Item $item, Feed $feed)
- {
- $categories = XmlParser::getXPathResult($entry, 'dc:subject', $this->namespaces);
- $item->setCategoriesFromXml($categories);
- }
-}
diff --git a/vendor/miniflux/picofeed/lib/PicoFeed/Parser/Rss20.php b/vendor/miniflux/picofeed/lib/PicoFeed/Parser/Rss20.php
deleted file mode 100644
index 1dd3bf8c..00000000
--- a/vendor/miniflux/picofeed/lib/PicoFeed/Parser/Rss20.php
+++ /dev/null
@@ -1,319 +0,0 @@
-<?php
-
-namespace PicoFeed\Parser;
-
-use SimpleXMLElement;
-use PicoFeed\Filter\Filter;
-use PicoFeed\Client\Url;
-
-/**
- * RSS 2.0 Parser.
- *
- * @package PicoFeed\Parser
- * @author Frederic Guillot
- */
-class Rss20 extends Parser
-{
- /**
- * Supported namespaces.
- */
- protected $namespaces = array(
- 'dc' => 'http://purl.org/dc/elements/1.1/',
- 'content' => 'http://purl.org/rss/1.0/modules/content/',
- 'feedburner' => 'http://rssnamespace.org/feedburner/ext/1.0',
- 'atom' => 'http://www.w3.org/2005/Atom',
- );
-
- /**
- * Get the path to the items XML tree.
- *
- * @param SimpleXMLElement $xml Feed xml
- *
- * @return SimpleXMLElement
- */
- public function getItemsTree(SimpleXMLElement $xml)
- {
- return XmlParser::getXPathResult($xml, 'channel/item');
- }
-
- /**
- * Find the feed url.
- *
- * @param SimpleXMLElement $xml Feed xml
- * @param \PicoFeed\Parser\Feed $feed Feed object
- */
- public function findFeedUrl(SimpleXMLElement $xml, Feed $feed)
- {
- $feed->setFeedUrl('');
- }
-
- /**
- * Find the site url.
- *
- * @param SimpleXMLElement $xml Feed xml
- * @param \PicoFeed\Parser\Feed $feed Feed object
- */
- public function findSiteUrl(SimpleXMLElement $xml, Feed $feed)
- {
- $value = XmlParser::getXPathResult($xml, 'channel/link');
- $feed->setSiteUrl(XmlParser::getValue($value));
- }
-
- /**
- * Find the feed description.
- *
- * @param SimpleXMLElement $xml Feed xml
- * @param \PicoFeed\Parser\Feed $feed Feed object
- */
- public function findFeedDescription(SimpleXMLElement $xml, Feed $feed)
- {
- $value = XmlParser::getXPathResult($xml, 'channel/description');
- $feed->setDescription(XmlParser::getValue($value));
- }
-
- /**
- * Find the feed logo url.
- *
- * @param SimpleXMLElement $xml Feed xml
- * @param \PicoFeed\Parser\Feed $feed Feed object
- */
- public function findFeedLogo(SimpleXMLElement $xml, Feed $feed)
- {
- $value = XmlParser::getXPathResult($xml, 'channel/image/url');
- $feed->setLogo(XmlParser::getValue($value));
- }
-
- /**
- * Find the feed icon.
- *
- * @param SimpleXMLElement $xml Feed xml
- * @param \PicoFeed\Parser\Feed $feed Feed object
- */
- public function findFeedIcon(SimpleXMLElement $xml, Feed $feed)
- {
- $feed->setIcon('');
- }
-
- /**
- * Find the feed title.
- *
- * @param SimpleXMLElement $xml Feed xml
- * @param \PicoFeed\Parser\Feed $feed Feed object
- */
- public function findFeedTitle(SimpleXMLElement $xml, Feed $feed)
- {
- $title = XmlParser::getXPathResult($xml, 'channel/title');
- $feed->setTitle(Filter::stripWhiteSpace(XmlParser::getValue($title)) ?: $feed->getSiteUrl());
- }
-
- /**
- * Find the feed language.
- *
- * @param SimpleXMLElement $xml Feed xml
- * @param \PicoFeed\Parser\Feed $feed Feed object
- */
- public function findFeedLanguage(SimpleXMLElement $xml, Feed $feed)
- {
- $value = XmlParser::getXPathResult($xml, 'channel/language');
- $feed->setLanguage(XmlParser::getValue($value));
- }
-
- /**
- * Find the feed id.
- *
- * @param SimpleXMLElement $xml Feed xml
- * @param \PicoFeed\Parser\Feed $feed Feed object
- */
- public function findFeedId(SimpleXMLElement $xml, Feed $feed)
- {
- $feed->setId($feed->getFeedUrl() ?: $feed->getSiteUrl());
- }
-
- /**
- * Find the feed date.
- *
- * @param SimpleXMLElement $xml Feed xml
- * @param \PicoFeed\Parser\Feed $feed Feed object
- */
- public function findFeedDate(SimpleXMLElement $xml, Feed $feed)
- {
- $publish_date = XmlParser::getXPathResult($xml, 'channel/pubDate');
- $update_date = XmlParser::getXPathResult($xml, 'channel/lastBuildDate');
-
- $published = !empty($publish_date) ? $this->getDateParser()->getDateTime(XmlParser::getValue($publish_date)) : null;
- $updated = !empty($update_date) ? $this->getDateParser()->getDateTime(XmlParser::getValue($update_date)) : null;
-
- if ($published === null && $updated === null) {
- $feed->setDate($this->getDateParser()->getCurrentDateTime()); // We use the current date if there is no date for the feed
- } elseif ($published !== null && $updated !== null) {
- $feed->setDate(max($published, $updated)); // We use the most recent date between published and updated
- } else {
- $feed->setDate($updated ?: $published);
- }
- }
-
- /**
- * Find the item published date.
- *
- * @param SimpleXMLElement $entry Feed item
- * @param Item $item Item object
- * @param \PicoFeed\Parser\Feed $feed Feed object
- */
- public function findItemPublishedDate(SimpleXMLElement $entry, Item $item, Feed $feed)
- {
- $date = XmlParser::getXPathResult($entry, 'pubDate');
-
- $item->setPublishedDate(!empty($date) ? $this->getDateParser()->getDateTime(XmlParser::getValue($date)) : null);
- }
-
- /**
- * Find the item updated date.
- *
- * @param SimpleXMLElement $entry Feed item
- * @param Item $item Item object
- * @param \PicoFeed\Parser\Feed $feed Feed object
- */
- public function findItemUpdatedDate(SimpleXMLElement $entry, Item $item, Feed $feed)
- {
- if ($item->publishedDate === null) {
- $this->findItemPublishedDate($entry, $item, $feed);
- }
- $item->setUpdatedDate($item->getPublishedDate()); // No updated date in RSS 2.0 specifications
- }
-
- /**
- * Find the item title.
- *
- * @param SimpleXMLElement $entry Feed item
- * @param \PicoFeed\Parser\Item $item Item object
- */
- public function findItemTitle(SimpleXMLElement $entry, Item $item)
- {
- $value = XmlParser::getXPathResult($entry, 'title');
- $item->setTitle(Filter::stripWhiteSpace(XmlParser::getValue($value)) ?: $item->getUrl());
- }
-
- /**
- * Find the item author.
- *
- * @param SimpleXMLElement $xml Feed
- * @param SimpleXMLElement $entry Feed item
- * @param \PicoFeed\Parser\Item $item Item object
- */
- public function findItemAuthor(SimpleXMLElement $xml, SimpleXMLElement $entry, Item $item)
- {
- $value = XmlParser::getXPathResult($entry, 'dc:creator', $this->namespaces)
- ?: XmlParser::getXPathResult($entry, 'author')
- ?: XmlParser::getXPathResult($xml, 'channel/dc:creator', $this->namespaces)
- ?: XmlParser::getXPathResult($xml, 'channel/managingEditor');
-
- $item->setAuthor(XmlParser::getValue($value));
- }
-
- /**
- * Find the item content.
- *
- * @param SimpleXMLElement $entry Feed item
- * @param \PicoFeed\Parser\Item $item Item object
- */
- public function findItemContent(SimpleXMLElement $entry, Item $item)
- {
- $content = XmlParser::getXPathResult($entry, 'content:encoded', $this->namespaces);
-
- if (XmlParser::getValue($content) === '') {
- $content = XmlParser::getXPathResult($entry, 'description');
- }
-
- $item->setContent(XmlParser::getValue($content));
- }
-
- /**
- * Find the item URL.
- *
- * @param SimpleXMLElement $entry Feed item
- * @param \PicoFeed\Parser\Item $item Item object
- */
- public function findItemUrl(SimpleXMLElement $entry, Item $item)
- {
- $link = XmlParser::getXPathResult($entry, 'feedburner:origLink', $this->namespaces)
- ?: XmlParser::getXPathResult($entry, 'link')
- ?: XmlParser::getXPathResult($entry, 'atom:link/@href', $this->namespaces);
-
- if (!empty($link)) {
- $item->setUrl(XmlParser::getValue($link));
- } else {
- $link = XmlParser::getXPathResult($entry, 'guid');
- $link = XmlParser::getValue($link);
-
- if (filter_var($link, FILTER_VALIDATE_URL) !== false) {
- $item->setUrl($link);
- }
- }
- }
-
- /**
- * Genereate the item id.
- *
- * @param SimpleXMLElement $entry Feed item
- * @param \PicoFeed\Parser\Item $item Item object
- * @param \PicoFeed\Parser\Feed $feed Feed object
- */
- public function findItemId(SimpleXMLElement $entry, Item $item, Feed $feed)
- {
- $id = XmlParser::getValue(XmlParser::getXPathResult($entry, 'guid'));
-
- if ($id) {
- $item->setId($this->generateId($id));
- } else {
- $item->setId($this->generateId(
- $item->getTitle(), $item->getUrl(), $item->getContent()
- ));
- }
- }
-
- /**
- * Find the item enclosure.
- *
- * @param SimpleXMLElement $entry Feed item
- * @param \PicoFeed\Parser\Item $item Item object
- * @param \PicoFeed\Parser\Feed $feed Feed object
- */
- public function findItemEnclosure(SimpleXMLElement $entry, Item $item, Feed $feed)
- {
- if (isset($entry->enclosure)) {
- $type = XmlParser::getXPathResult($entry, 'enclosure/@type');
- $url = XmlParser::getXPathResult($entry, 'feedburner:origEnclosureLink', $this->namespaces)
- ?: XmlParser::getXPathResult($entry, 'enclosure/@url');
-
- $item->setEnclosureUrl(Url::resolve(XmlParser::getValue($url), $feed->getSiteUrl()));
- $item->setEnclosureType(XmlParser::getValue($type));
- }
- }
-
- /**
- * Find the item language.
- *
- * @param SimpleXMLElement $entry Feed item
- * @param \PicoFeed\Parser\Item $item Item object
- * @param \PicoFeed\Parser\Feed $feed Feed object
- */
- public function findItemLanguage(SimpleXMLElement $entry, Item $item, Feed $feed)
- {
- $language = XmlParser::getXPathResult($entry, 'dc:language', $this->namespaces);
- $item->setLanguage(XmlParser::getValue($language) ?: $feed->getLanguage());
- }
-
- /**
- * Find the item categories.
- *
- * @param SimpleXMLElement $entry Feed item
- * @param Item $item Item object
- * @param Feed $feed Feed object
- */
- public function findItemCategories(SimpleXMLElement $entry, Item $item, Feed $feed)
- {
- $categories = XmlParser::getXPathResult($entry, 'category');
- $item->setCategoriesFromXml($categories);
- }
-
-}
diff --git a/vendor/miniflux/picofeed/lib/PicoFeed/Parser/Rss91.php b/vendor/miniflux/picofeed/lib/PicoFeed/Parser/Rss91.php
deleted file mode 100644
index 058fca1b..00000000
--- a/vendor/miniflux/picofeed/lib/PicoFeed/Parser/Rss91.php
+++ /dev/null
@@ -1,13 +0,0 @@
-<?php
-
-namespace PicoFeed\Parser;
-
-/**
- * RSS 0.91 Parser.
- *
- * @package PicoFeed\Parser
- * @author Frederic Guillot
- */
-class Rss91 extends Rss20
-{
-}
diff --git a/vendor/miniflux/picofeed/lib/PicoFeed/Parser/Rss92.php b/vendor/miniflux/picofeed/lib/PicoFeed/Parser/Rss92.php
deleted file mode 100644
index e3df3c8b..00000000
--- a/vendor/miniflux/picofeed/lib/PicoFeed/Parser/Rss92.php
+++ /dev/null
@@ -1,13 +0,0 @@
-<?php
-
-namespace PicoFeed\Parser;
-
-/**
- * RSS 0.92 Parser.
- *
- * @package PicoFeed\Parser
- * @author Frederic Guillot
- */
-class Rss92 extends Rss20
-{
-}
diff --git a/vendor/miniflux/picofeed/lib/PicoFeed/Parser/XmlEntityException.php b/vendor/miniflux/picofeed/lib/PicoFeed/Parser/XmlEntityException.php
deleted file mode 100644
index 1188217d..00000000
--- a/vendor/miniflux/picofeed/lib/PicoFeed/Parser/XmlEntityException.php
+++ /dev/null
@@ -1,13 +0,0 @@
-<?php
-
-namespace PicoFeed\Parser;
-
-/**
- * XmlEntityException Exception.
- *
- * @package PicoFeed\Parser
- * @author Bernhard Posselt
- */
-class XmlEntityException extends MalformedXmlException
-{
-}
diff --git a/vendor/miniflux/picofeed/lib/PicoFeed/Parser/XmlParser.php b/vendor/miniflux/picofeed/lib/PicoFeed/Parser/XmlParser.php
deleted file mode 100644
index ea42949f..00000000
--- a/vendor/miniflux/picofeed/lib/PicoFeed/Parser/XmlParser.php
+++ /dev/null
@@ -1,246 +0,0 @@
-<?php
-
-namespace PicoFeed\Parser;
-
-use DOMDocument;
-use SimpleXMLElement;
-use ZendXml\Exception\RuntimeException;
-use ZendXml\Security;
-
-/**
- * XML parser class.
- *
- * Checks for XML eXternal Entity (XXE) and XML Entity Expansion (XEE) attacks on XML documents
- *
- * @package PicoFeed\Parser
- * @author Frederic Guillot
- */
-class XmlParser
-{
- /**
- * Get a SimpleXmlElement instance or return false.
- *
- * @static
- * @param string $input XML content
- * @return mixed
- */
- public static function getSimpleXml($input)
- {
- return self::scan($input);
- }
-
- /**
- * Get a DomDocument instance or return false.
- *
- * @static
- * @param string $input XML content
- * @return DOMDocument
- */
- public static function getDomDocument($input)
- {
- if (empty($input)) {
- return false;
- }
-
- $dom = self::scan($input, new DOMDocument());
-
- // The document is empty, there is probably some parsing errors
- if ($dom && $dom->childNodes->length === 0) {
- return false;
- }
-
- return $dom;
- }
-
- /**
- * Small wrapper around ZendXml to turn their exceptions into PicoFeed exceptions
- *
- * @static
- * @access private
- * @param string $input
- * @param DOMDocument $dom
- * @throws XmlEntityException
- * @return SimpleXMLElement|DomDocument|boolean
- */
- private static function scan($input, $dom = null)
- {
- try {
- return Security::scan($input, $dom);
- } catch(RuntimeException $e) {
- throw new XmlEntityException($e->getMessage());
- }
- }
-
- /**
- * Load HTML document by using a DomDocument instance or return false on failure.
- *
- * @static
- * @access public
- * @param string $input XML content
- * @return DOMDocument
- */
- public static function getHtmlDocument($input)
- {
- $dom = new DomDocument();
-
- if (empty($input)) {
- return $dom;
- }
-
- libxml_use_internal_errors(true);
-
- if (version_compare(PHP_VERSION, '5.4.0', '>=')) {
- $dom->loadHTML($input, LIBXML_NONET);
- } else {
- $dom->loadHTML($input);
- }
-
- return $dom;
- }
-
- /**
- * Convert a HTML document to XML.
- *
- * @static
- * @access public
- * @param string $html HTML document
- * @return string
- */
- public static function htmlToXml($html)
- {
- $dom = self::getHtmlDocument('<?xml version="1.0" encoding="UTF-8">'.$html);
- return $dom->saveXML($dom->getElementsByTagName('body')->item(0));
- }
-
- /**
- * Get XML parser errors.
- *
- * @static
- * @access public
- * @return string
- */
- public static function getErrors()
- {
- $errors = array();
-
- foreach (libxml_get_errors() as $error) {
- $errors[] = sprintf('XML error: %s (Line: %d - Column: %d - Code: %d)',
- $error->message,
- $error->line,
- $error->column,
- $error->code
- );
- }
-
- return implode(', ', $errors);
- }
-
- /**
- * Get the encoding from a xml tag.
- *
- * @static
- * @access public
- * @param string $data Input data
- * @return string
- */
- public static function getEncodingFromXmlTag($data)
- {
- $encoding = '';
-
- if (strpos($data, '<?xml') !== false) {
- $data = substr($data, 0, strrpos($data, '?>'));
- $data = str_replace("'", '"', $data);
-
- $p1 = strpos($data, 'encoding=');
- $p2 = strpos($data, '"', $p1 + 10);
-
- if ($p1 !== false && $p2 !== false) {
- $encoding = substr($data, $p1 + 10, $p2 - $p1 - 10);
- $encoding = strtolower($encoding);
- }
- }
-
- return $encoding;
- }
-
- /**
- * Get the charset from a meta tag.
- *
- * @static
- * @access public
- * @param string $data Input data
- * @return string
- */
- public static function getEncodingFromMetaTag($data)
- {
- $encoding = '';
-
- if (preg_match('/<meta.*?charset\s*=\s*["\']?\s*([^"\'\s\/>;]+)/i', $data, $match) === 1) {
- $encoding = strtolower($match[1]);
- }
-
- return $encoding;
- }
-
- /**
- * Rewrite XPath query to use namespace-uri and local-name derived from prefix.
- *
- * @static
- * @access public
- * @param string $query XPath query
- * @param array $ns Prefix to namespace URI mapping
- * @return string
- */
- public static function replaceXPathPrefixWithNamespaceURI($query, array $ns)
- {
- return preg_replace_callback('/([A-Z0-9]+):([A-Z0-9]+)/iu', function ($matches) use ($ns) {
- // don't try to map the special prefix XML
- if (strtolower($matches[1]) === 'xml') {
- return $matches[0];
- }
-
- return '*[namespace-uri()="'.$ns[$matches[1]].'" and local-name()="'.$matches[2].'"]';
- },
- $query);
- }
-
- /**
- * Get the result elements of a XPath query.
- *
- * @static
- * @access public
- * @param SimpleXMLElement $xml XML element
- * @param string $query XPath query
- * @param array $ns Prefix to namespace URI mapping
- * @return SimpleXMLElement[]
- */
- public static function getXPathResult(SimpleXMLElement $xml, $query, array $ns = array())
- {
- if (!empty($ns)) {
- $query = static::replaceXPathPrefixWithNamespaceURI($query, $ns);
- }
-
- return $xml->xpath($query);
- }
-
- /**
- * Get the first Xpath result or SimpleXMLElement value
- *
- * @static
- * @access public
- * @param mixed $value
- * @return string
- */
- public static function getValue($value)
- {
- $result = '';
-
- if (is_array($value) && count($value) > 0) {
- $result = (string) $value[0];
- } elseif (is_a($value, 'SimpleXMLElement')) {
- return $result = (string) $value;
- }
-
- return trim($result);
- }
-}