Skip to content

Fix the Syndication Feed RFC822 DateTimeParser #99194

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -92,28 +92,28 @@ private static bool Rfc822DateTimeParser(string dateTimeString, out DateTimeOffs
DateTimeOffset theTime;
string[] parseFormat =
{
"ddd, dd MMMM yyyy HH:mm:ss zzz",
"dd MMMM yyyy HH:mm:ss zzz",
"ddd, dd MMM yyyy HH:mm:ss zzz",
"dd MMM yyyy HH:mm:ss zzz",
"ddd, d MMMM yyyy HH:mm:ss zzz",
"d MMMM yyyy HH:mm:ss zzz",
"ddd, d MMM yyyy HH:mm:ss zzz",
"d MMM yyyy HH:mm:ss zzz",

"ddd, dd MMMM yyyy HH:mm zzz",
"dd MMMM yyyy HH:mm zzz",
"ddd, dd MMM yyyy HH:mm zzz",
"dd MMM yyyy HH:mm zzz",
Comment on lines -100 to -103
Copy link
Member

@filipnavara filipnavara Mar 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is removing the overloads without the :ss part, why? (seconds are optional in the time-of-day ABNF in RFC 5322)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure what you mean; I didn't remove any overloads or change the :ss part. All the previously existing formats are still there, just with the correct number of digits for date and year.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, sorry, it was hidden under the messages about whitespace error.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, that makes sense, there were a LOT of error messages! 😅

"ddd, d MMMM yyyy HH:mm zzz",
"d MMMM yyyy HH:mm zzz",
"ddd, d MMM yyyy HH:mm zzz",
"d MMM yyyy HH:mm zzz",

// The original RFC822 spec listed 2 digit years. RFC1123 updated the format to include 4 digit years and states that you should use 4 digits.
// Technically RSS2.0 specifies RFC822 but it's presumed that RFC1123 will be used as we're now past Y2K and everyone knows better. The 4 digit
// formats are listed first for performance reasons as it's presumed they will be more likely to match first.
"ddd, dd MMMM yy HH:mm:ss zzz",
"dd MMMM yyyy HH:mm:ss zzz",
"ddd, dd MMM yy HH:mm:ss zzz",
"dd MMM yyyy HH:mm:ss zzz",

"ddd, dd MMMM yy HH:mm zzz",
"dd MMMM yyyy HH:mm zzz",
"ddd, dd MMM yy HH:mm zzz",
"dd MMM yyyy HH:mm zzz"
"ddd, d MMMM yy HH:mm:ss zzz",
"d MMMM yy HH:mm:ss zzz",
"ddd, d MMM yy HH:mm:ss zzz",
"d MMM yy HH:mm:ss zzz",

"ddd, d MMMM yy HH:mm zzz",
"d MMMM yy HH:mm zzz",
"ddd, d MMM yy HH:mm zzz",
"d MMM yy HH:mm zzz"
};

if (DateTimeOffset.TryParseExact(wellFormattedString, parseFormat,
Expand Down