dotnet / runtime

.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
https://docs.microsoft.com/dotnet/core/
MIT License
15.26k stars 4.73k forks source link

System.ServiceModel.Syndication RSS 2.0 pubdate field,, error parsing Timezone #65212

Open pkar70 opened 2 years ago

pkar70 commented 2 years ago

Description

When feed <rss version="2.0", in <item , has field <pubDate>Fri, 11 Feb 2022 19:58:02 CET</pubDate>, such date is not interpreted.

Reproduction Steps

<rss version="2.0" xmlns:media="http://search.yahoo.com/mrss/">
<channel>
<title>Devilsy</title>
<description>Ostatnio dodane</description>
<link>https://devil-torrents.pl</link>
<lastBuildDate>Fri, 11 Feb 2022 22:03:07 +0100</lastBuildDate>
<generator>generator</generator>
<image>
<title>Devilsy</title>
<height>150</height>
<width>120</width>
</image>
<language>pl</language>
<item>
            <title>BEHEMOTH - IN ABSENTIA DEI (2021)</title>
             <link>https://XXXX</link>
            <description><![CDATA[<img src="https://XXXXXX/332566.jpg" align="left"><br>]]></description>
            <author>FallenAngel</author>
            <category>Muzyka -> Koncerty</category>
            <guid>https://XXXX</guid>
            <pubDate>Fri, 11 Feb 2022 19:58:02 CET</pubDate>
</item>
</channel>
</rss>

Expected behavior

Date interpreted as date with time zone CET.

Actual behavior

Date is not interpreted (ServiceModel.Syndication.SyndicationItem.PublishDate is not set).

Regression?

No response

Known Workarounds

As workaround, one can use Net.Http.HttpClient.GetAsync / Net.Http.HttpResponseMessage.Content.ReadAsStringAsync(), then use string replace before using XMLreader

  sPage = sPage.Replace("CET</pubDate>", "</pubDate>")
  sPage = sPage.Replace("CEST</pubDate>", "</pubDate>")
    Using oReader As Xml.XmlReader = Xml.XmlReader.Create(New IO.StringReader(sPage))
        oRssFeed = ServiceModel.Syndication.SyndicationFeed.Load(oReader)
    End Using

Configuration

Compiled within UWP, and within Class Library .Net Standard 2.0 Microsoft Windows [Version 10.0.19044.1526] Architecture x86

Other information

No response

dotnet-issue-labeler[bot] commented 2 years ago

I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.