diff --git a/miniflux/vendor/PicoFeed/Filter.php b/miniflux/vendor/PicoFeed/Filter.php index 9c7dd24..f911014 100644 --- a/miniflux/vendor/PicoFeed/Filter.php +++ b/miniflux/vendor/PicoFeed/Filter.php @@ -45,7 +45,8 @@ class Filter 'figcaption' => array(), 'cite' => array(), 'time' => array('datetime'), - 'abbr' => array('title') + 'abbr' => array('title'), + 'iframe' => array('width', 'height', 'frameborder', 'src') ); public $strip_tags_content = array( @@ -82,6 +83,11 @@ class Filter 'a' => 'rel="noreferrer" target="_blank"' ); + public $iframe_allowed_resources = array( + 'http://www.youtube.com/', + 'http://player.vimeo.com/' + ); + public function __construct($data, $url) { @@ -104,7 +110,7 @@ class Filter if (! xml_parse($parser, $this->input, true)) { - var_dump($this->input); + //var_dump($this->input); die(xml_get_current_line_number($parser).'|'.xml_error_string(xml_get_error_code($parser))); } @@ -130,11 +136,16 @@ class Filter foreach ($attributes as $attribute => $value) { - if ($this->isAllowedAttribute($name, $attribute)) { + if ($value != '' && $this->isAllowedAttribute($name, $attribute)) { if ($this->isResource($attribute)) { - if ($this->isRelativePath($value)) { + if ($name === 'iframe' && $this->isAllowedIframeResource($value)) { + + $attr_data .= ' '.$attribute.'="'.$value.'"'; + $used_attributes[] = $attribute; + } + else if ($this->isRelativePath($value)) { $attr_data .= ' '.$attribute.'="'.$this->getAbsoluteUrl($value, $this->url).'"'; $used_attributes[] = $attribute; @@ -216,7 +227,6 @@ class Filter else { // Relative path - $url_path = $components['path']; if ($url_path{strlen($url_path) - 1} !== '/') { @@ -258,6 +268,20 @@ class Filter } + public function isAllowedIframeResource($value) + { + foreach ($this->iframe_allowed_resources as $url) { + + if (strpos($value, $url) === 0) { + + return true; + } + } + + return false; + } + + public function isAllowedProtocol($value) { foreach ($this->allowed_protocols as $protocol) { diff --git a/miniflux/vendor/PicoFeed/Parser.php b/miniflux/vendor/PicoFeed/Parser.php index 6612ebf..a494494 100644 --- a/miniflux/vendor/PicoFeed/Parser.php +++ b/miniflux/vendor/PicoFeed/Parser.php @@ -14,6 +14,7 @@ abstract class Parser public $title = ''; public $updated = ''; public $items = array(); + public $debug = false; abstract public function execute(); @@ -37,253 +38,25 @@ abstract class Parser return $content; } -} -class Atom extends Parser -{ - public function execute() + public function displayXmlErrors() { - try { + foreach(\libxml_get_errors() as $error) { - \libxml_use_internal_errors(true); - - $xml = new \SimpleXMLElement($this->content); - - $this->url = $this->getUrl($xml); - $this->title = (string) $xml->title; - $this->id = (string) $xml->id; - $this->updated = strtotime((string) $xml->updated); - $author = (string) $xml->author->name; - - foreach ($xml->entry as $entry) { - - if (isset($entry->author->name)) { - - $author = $entry->author->name; - } - - $item = new \StdClass; - $item->id = (string) $entry->id; - $item->title = (string) $entry->title; - $item->url = $this->getUrl($entry); - $item->updated = strtotime((string) $entry->updated); - $item->author = $author; - $item->content = $this->filterHtml($this->getContent($entry), $item->url); - - $this->items[] = $item; - } + printf("Message: %s\nLine: %d\nColumn: %d\nCode: %d\n", + $error->message, + $error->line, + $error->column, + $error->code + ); } - catch (\Exception $e) { - - } - - return $this; } - public function getContent($entry) + // Dirty quickfix before XML parsing + public function normalizeData($data) { - if (isset($entry->content) && ! empty($entry->content)) { - - if (count($entry->content->children())) { - - return (string) $entry->content->asXML(); - } - else { - - return (string) $entry->content; - } - } - else if (isset($entry->summary) && ! empty($entry->summary)) { - - return (string) $entry->summary; - } - - return ''; - } - - - public function getUrl($xml) - { - foreach ($xml->link as $link) { - - if ((string) $link['type'] === 'text/html') { - - return (string) $link['href']; - } - } - - return (string) $xml->link['href']; + return str_replace("\xc3\x20", '', $data); } } - - -class Rss20 extends Parser -{ - public function execute() - { - try { - - \libxml_use_internal_errors(true); - - $xml = new \SimpleXMLElement($this->content); - $ns = $xml->getNamespaces(true); - - $this->title = (string) $xml->channel->title; - $this->url = (string) $xml->channel->link; - $this->id = $this->url; - $this->updated = isset($xml->channel->pubDate) ? (string) $xml->channel->pubDate : (string) $xml->channel->lastBuildDate; - - if ($this->updated) { - - $this->updated = strtotime($this->updated); - } - else { - - $this->updated = time(); - } - - foreach ($xml->channel->item as $entry) { - - $author = ''; - $content = ''; - $pubdate = ''; - $link = ''; - - if (isset($ns['feedburner'])) { - - $ns_fb = $entry->children($ns['feedburner']); - $link = $ns_fb->origLink; - } - - if (isset($ns['dc'])) { - - $ns_dc = $entry->children($ns['dc']); - $author = (string) $ns_dc->creator; - $pubdate = (string) $ns_dc->date; - } - - if (isset($ns['content'])) { - - $ns_content = $entry->children($ns['content']); - $content = (string) $ns_content->encoded; - } - - if ($content === '' && isset($entry->description)) { - - $content = (string) $entry->description; - } - - if ($author === '') { - - if (isset($entry->author)) { - - $author = (string) $entry->author; - } - else if (isset($xml->channel->webMaster)) { - - $author = (string) $xml->channel->webMaster; - } - } - - $item = new \StdClass; - $item->title = (string) $entry->title; - $item->url = $link ?: (string) $entry->link; - $item->id = isset($entry->guid) ? (string) $entry->guid : $item->url; - $item->updated = strtotime($pubdate ?: (string) $entry->pubDate) ?: $this->updated; - $item->content = $this->filterHtml($content, $item->url); - $item->author = $author; - - $this->items[] = $item; - } - } - catch (\Exception $e) { - - } - - return $this; - } -} - - -class Rss10 extends Parser -{ - public function execute() - { - try { - - \libxml_use_internal_errors(true); - - $xml = new \SimpleXMLElement($this->content); - $ns = $xml->getNamespaces(true); - - $this->title = (string) $xml->channel->title; - $this->url = (string) $xml->channel->link; - $this->id = $this->url; - - if (isset($ns['dc'])) { - - $ns_dc = $xml->channel->children($ns['dc']); - $this->updated = isset($ns_dc->date) ? strtotime($ns_dc->date) : time(); - } - else { - - $this->updated = time(); - } - - foreach ($xml->item as $entry) { - - $author = ''; - $content = ''; - $pubdate = ''; - $link = ''; - - if (isset($ns['feedburner'])) { - - $ns_fb = $entry->children($ns['feedburner']); - $link = $ns_fb->origLink; - } - - if (isset($ns['dc'])) { - - $ns_dc = $entry->children($ns['dc']); - $author = (string) $ns_dc->creator; - $pubdate = (string) $ns_dc->date; - } - - if (isset($ns['content'])) { - - $ns_content = $entry->children($ns['content']); - $content = (string) $ns_content->encoded; - } - - if ($content === '' && isset($entry->description)) { - - $content = (string) $entry->description; - } - - $item = new \StdClass; - $item->title = (string) $entry->title; - $item->url = $link ?: (string) $entry->link; - $item->id = $item->url; - $item->updated = $pubdate ? strtotime($pubdate) : time(); - $item->content = $this->filterHtml($content, $item->url); - $item->author = $author ?: (string) $xml->channel->webMaster; - - $this->items[] = $item; - } - } - catch (\Exception $e) { - - } - - return $this; - } -} - - -class Rss92 extends Rss20 {} - - -class Rss91 extends Rss20 {} diff --git a/miniflux/vendor/PicoFeed/Parsers/Atom.php b/miniflux/vendor/PicoFeed/Parsers/Atom.php new file mode 100644 index 0000000..cf3f405 --- /dev/null +++ b/miniflux/vendor/PicoFeed/Parsers/Atom.php @@ -0,0 +1,83 @@ +content = $this->normalizeData($this->content); + + \libxml_use_internal_errors(true); + + $xml = \simplexml_load_string($this->content); + + if ($xml === false) { + + if ($this->debug) $this->displayXmlErrors(); + return false; + } + + $this->url = $this->getUrl($xml); + $this->title = (string) $xml->title; + $this->id = (string) $xml->id; + $this->updated = strtotime((string) $xml->updated); + $author = (string) $xml->author->name; + + foreach ($xml->entry as $entry) { + + if (isset($entry->author->name)) { + + $author = $entry->author->name; + } + + $item = new \StdClass; + $item->id = (string) $entry->id; + $item->title = (string) $entry->title; + $item->url = $this->getUrl($entry); + $item->updated = strtotime((string) $entry->updated); + $item->author = $author; + $item->content = $this->filterHtml($this->getContent($entry), $item->url); + + $this->items[] = $item; + } + + return $this; + } + + + public function getContent($entry) + { + if (isset($entry->content) && ! empty($entry->content)) { + + if (count($entry->content->children())) { + + return (string) $entry->content->asXML(); + } + else { + + return (string) $entry->content; + } + } + else if (isset($entry->summary) && ! empty($entry->summary)) { + + return (string) $entry->summary; + } + + return ''; + } + + + public function getUrl($xml) + { + foreach ($xml->link as $link) { + + if ((string) $link['type'] === 'text/html') { + + return (string) $link['href']; + } + } + + return (string) $xml->link['href']; + } +} \ No newline at end of file diff --git a/miniflux/vendor/PicoFeed/Parsers/Rss10.php b/miniflux/vendor/PicoFeed/Parsers/Rss10.php new file mode 100644 index 0000000..969ab8c --- /dev/null +++ b/miniflux/vendor/PicoFeed/Parsers/Rss10.php @@ -0,0 +1,81 @@ +content = $this->normalizeData($this->content); + + \libxml_use_internal_errors(true); + + $xml = \simplexml_load_string($this->content); + + if ($xml === false) { + + if ($this->debug) $this->displayXmlErrors(); + return false; + } + + $ns = $xml->getNamespaces(true); + + $this->title = (string) $xml->channel->title; + $this->url = (string) $xml->channel->link; + $this->id = $this->url; + + if (isset($ns['dc'])) { + + $ns_dc = $xml->channel->children($ns['dc']); + $this->updated = isset($ns_dc->date) ? strtotime($ns_dc->date) : time(); + } + else { + + $this->updated = time(); + } + + foreach ($xml->item as $entry) { + + $author = ''; + $content = ''; + $pubdate = ''; + $link = ''; + + if (isset($ns['feedburner'])) { + + $ns_fb = $entry->children($ns['feedburner']); + $link = $ns_fb->origLink; + } + + if (isset($ns['dc'])) { + + $ns_dc = $entry->children($ns['dc']); + $author = (string) $ns_dc->creator; + $pubdate = (string) $ns_dc->date; + } + + if (isset($ns['content'])) { + + $ns_content = $entry->children($ns['content']); + $content = (string) $ns_content->encoded; + } + + if ($content === '' && isset($entry->description)) { + + $content = (string) $entry->description; + } + + $item = new \StdClass; + $item->title = (string) $entry->title; + $item->url = $link ?: (string) $entry->link; + $item->id = $item->url; + $item->updated = $pubdate ? strtotime($pubdate) : time(); + $item->content = $this->filterHtml($content, $item->url); + $item->author = $author ?: (string) $xml->channel->webMaster; + + $this->items[] = $item; + } + + return $this; + } +} \ No newline at end of file diff --git a/miniflux/vendor/PicoFeed/Parsers/Rss20.php b/miniflux/vendor/PicoFeed/Parsers/Rss20.php new file mode 100644 index 0000000..7fced40 --- /dev/null +++ b/miniflux/vendor/PicoFeed/Parsers/Rss20.php @@ -0,0 +1,93 @@ +content = $this->normalizeData($this->content); + + \libxml_use_internal_errors(true); + + $xml = \simplexml_load_string($this->content); + + if ($xml === false) { + + if ($this->debug) $this->displayXmlErrors(); + return false; + } + + $ns = $xml->getNamespaces(true); + + $this->title = (string) $xml->channel->title; + $this->url = (string) $xml->channel->link; + $this->id = $this->url; + $this->updated = isset($xml->channel->pubDate) ? (string) $xml->channel->pubDate : (string) $xml->channel->lastBuildDate; + + if ($this->updated) { + + $this->updated = strtotime($this->updated); + } + else { + + $this->updated = time(); + } + + foreach ($xml->channel->item as $entry) { + + $author = ''; + $content = ''; + $pubdate = ''; + $link = ''; + + if (isset($ns['feedburner'])) { + + $ns_fb = $entry->children($ns['feedburner']); + $link = $ns_fb->origLink; + } + + if (isset($ns['dc'])) { + + $ns_dc = $entry->children($ns['dc']); + $author = (string) $ns_dc->creator; + $pubdate = (string) $ns_dc->date; + } + + if (isset($ns['content'])) { + + $ns_content = $entry->children($ns['content']); + $content = (string) $ns_content->encoded; + } + + if ($content === '' && isset($entry->description)) { + + $content = (string) $entry->description; + } + + if ($author === '') { + + if (isset($entry->author)) { + + $author = (string) $entry->author; + } + else if (isset($xml->channel->webMaster)) { + + $author = (string) $xml->channel->webMaster; + } + } + + $item = new \StdClass; + $item->title = (string) $entry->title; + $item->url = $link ?: (string) $entry->link; + $item->id = isset($entry->guid) ? (string) $entry->guid : $item->url; + $item->updated = strtotime($pubdate ?: (string) $entry->pubDate) ?: $this->updated; + $item->content = $this->filterHtml($content, $item->url); + $item->author = $author; + + $this->items[] = $item; + } + + return $this; + } +} \ No newline at end of file diff --git a/miniflux/vendor/PicoFeed/Parsers/Rss91.php b/miniflux/vendor/PicoFeed/Parsers/Rss91.php new file mode 100644 index 0000000..08716e9 --- /dev/null +++ b/miniflux/vendor/PicoFeed/Parsers/Rss91.php @@ -0,0 +1,7 @@ +content); } else if (strpos($first_tag, 'content); } else if (strpos($first_tag, 'content); } else if (strpos($first_tag, 'content); } else if (strpos($first_tag, 'content); } else if ($discover === true) {