fossar / selfoss

multipurpose rss reader, live stream, mashup, aggregation web application
https://selfoss.aditu.de
GNU General Public License v3.0
2.35k stars 343 forks source link

Failure to parse date in RSS feed #1384

Closed fmunch closed 1 year ago

fmunch commented 1 year ago

For the feed https://www.commitstrip.com/fr/feed/ I get the following error:

[2022-10-16 23:42:01] selfoss.ERROR: error loading feed content for CommitStrip {"exception":"[object] (Exception(code: 0): DateTimeImmutable::__construct(): Failed to parse time string (@) at position 0 (@): Unexpected character at /var/www/selfoss/selfoss-2.19/src/spouts/rss/feed.php:108)
[stacktrace]
#0 /var/www/selfoss/selfoss-2.19/src/spouts/rss/feed.php(108): DateTimeImmutable->__construct()
#1 [internal function]: spouts\^Mss\\feed->getItems()
#2 /var/www/selfoss/selfoss-2.19/src/helpers/ContentLoader.php(145): iterator_to_array()
#3 /var/www/selfoss/selfoss-2.19/src/helpers/ContentLoader.php(71): helpers\\ContentLoader->fetch()
#4 /var/www/selfoss/selfoss-2.19/cliupdate.php(7): helpers\\ContentLoader->update()
#5 {main}
"} 

In feed.php:

            $unixDate = $item->get_date('U');
            $date = $unixDate !== null ? new \DateTimeImmutable('@' . $unixDate) : new \DateTimeImmutable();

In my case SimplePie's get_date() returns false (probably because the date cannot be parsed). Maybe $unixDate !== null should be relaxed a bit.

jtojnar commented 1 year ago

Thanks for reporting, I have opened a fix upstream: https://github.com/simplepie/simplepie/pull/753