Open dougwaldron opened 8 months ago
Well that was fun evening diving into the code and specs!
TLDR; It looks like the .NET SyndicationFeed
parser incorrectly throws an exception when the date uses a single digit day.
The RSS feed for The Talk Show uses single-digit days (when less than 10). The SyndicationFeed
parser has no problem with this episode:
<guid>https://daringfireball.net/thetalkshow/2023/06/17/ep-379</guid>
<pubDate>Sat, 17 Jun 2023 19:22:55 EDT</pubDate>
But fails for the next episode:
<guid>https://daringfireball.net/thetalkshow/2023/06/07/ep-378</guid>
<pubDate>Wed, 7 Jun 2023 20:13:43 EDT</pubDate>
with the exception message:
An error was encountered when parsing a DateTime value in the XML.
Diving into the code...
When SyndicationFeed
tries load an RSS feed, it first attempts to parse publication dates using the default DateTimeOffset
parser. If that doesn't work, it uses DateTimeOffset.TryParseExact
with an array of possible date formats based on RFC 822.
The RSS 2.0 spec does specify that pubDate
should conform to RFC 822 (except that years should be 4 digits).
RFC 822 in turn specifies that the date portion of the date-time value be formatted like so:
date = 1*2DIGIT month 2DIGIT ; day month year
; e.g. 20 Jun 82
where that 1*2DIGIT
notation indicates at least 1 and at most 2 digits for the day value. So single-digit dates are valid.
But the parseFormat
array includes no formats with single-digit days. This is a bug.
Bug report submitted: https://github.com/dotnet/runtime/issues/99193
Pull request submitted: https://github.com/dotnet/runtime/pull/99194
I updated the Sentry.io link in the original description since the old one had expired.
Reported via Sentry:
Affected page: https://podcast-rewind.azurewebsites.net/Setup?feedUrl=https%3A%2F%2Fdaringfireball.net%2Fthetalkshow%2Frss
Feed URL:
https://daringfireball.net/thetalkshow/rss
Exception:
Full stack trace:
``` System.Xml.XmlException: Error in line 754 position 43. An error was encountered when parsing a DateTime value in the XML. File "SyndicationItem.cs", line 138, in DateTimeOffset SyndicationItem.get_PublishDate() throw PublishDateException; File "Models/Dto/ViewPodcastEpisodeDto.cs", line 13, col 56, in new ViewPodcastEpisodeDto(SyndicationItem item) File "Pages/Setup.cshtml.cs", line 60, col 53, in void SetupModel.LoadData(SyndicationFeed feed)+(SyndicationItem item) => { } [0] File "Select.SpeedOpt.cs", line 428, in void SelectIListIterator