zendframework / zend-feed

Feed component from Zend Framework
BSD 3-Clause "New" or "Revised" License
166 stars 42 forks source link

Zend-Feed Reader : Failing if there is DOCTYPE tag in the rss #71

Closed rajjanorkar closed 6 years ago

rajjanorkar commented 6 years ago

Hi Team,

This rss feed https://forward.com/rss/ is valid but i can jus see there is extra doctype tag at the very top.

Have look here view-source:https://forward.com/rss/

<!DOCTYPE rss PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

because of that reader import string is failing

Code to reproduce the issue

$feed = Zend\Feed\Reader\Reader::import('https://forward.com/rss/');
$data = [
    'title'        => $feed->getTitle(),
    'link'         => $feed->getLink(),
    'dateModified' => $feed->getDateModified(),
    'description'  => $feed->getDescription(),
    'language'     => $feed->getLanguage(),
    'entries'      => [],
];

Expected results

Ideally it should not fail because it is valid RSS feed

Actual results


exception 'Zend\Feed\Reader\Exception\InvalidArgumentException' with message 'Invalid XML: Detected use of illegal DOCTYPE' in /home/example/vendor/zendframework/zend-feed/src/Reader/Reader.php:328 
#0 /home/example/vendor/zendframework/zend-feed/src/Reader/Reader.php(266): Zend\Feed\Reader\Reader::importString('<!DOCTYPE rss P...')
#1 /home/example/app/Reader/FeedLoaderService.php(90): Zend\Feed\Reader\Reader::import('https://forward.com/rss/')

Same issue for this rss view-source:https://www.brainyquote.com/link/quotefu.rss

https://www.brainyquote.com/link/quotefu.rss

froschdesign commented 6 years ago

This is not the same issue, because the doctype is wrong here. Please look at the error message:

Invalid XML: Detected use of illegal DOCTYPE

Also the second line in the feed is wrong. RSS and Atom are different formats.