-
Notifications
You must be signed in to change notification settings - Fork 543
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
DateTime::parse_from_rfc2822 not compliant with RFC2822 comments #732
Comments
I would tend to agree that we should probably provide an actual RFC 2822 parser. If you would submit a PR to make the necessary changes, I would like to review the amount of complexity necessary to do so. |
@djc I already thought about it and it seems to be not quite trivial; comments are (roughly) defined as:
Might work on that, but after an initial review I don't think I'll be able to do so within the next week, probably. I'll make an attempt, but if someone else feels like he could do it easily, please don't wait for me |
I'm not in a hurry, and will definitely not have time to move this forward myself. |
@djc Well, seems like I found the time after all. Feedback appreciated. |
Ping :) |
Your PR is on my list and won't be forgotten, but I'm currently on holidays, so please have some patience. |
No problem. Didn't mean to stress you out :) enjoy your holiday |
Problem
According to RFC2822, an RFC2822 string can end with a
CFWS
.However, the
DateTime::parse_from_rfc2822
cannot deal with comments:Implementation Details
The implementation explicitly distances itself from comments and calls itself not an actual rfc2822 parser:
I'd argue that
chrono
is the defacto go-to library for anything date/time related in Rust, so this parser should be an actual parser.Rationale
The documentation of
DateTime::parse_from_rfc2822
states:This sounds like it should:
Sadly, most email headers use a comment after the string that reflects the timezone, like
"2 Nov 2021 14:26:12 +0000 (UTC)"
. So I'd argue that the behaviour of the library is not consistent with the documentation; it should state that this is not an actualRFC2822
parser, but instead only parses a subset and is explicitly not compatible with email headers.Solutions
I can see two possible solutions:
This issue was already brought up in #462, but back then it was dismissed as not being a valid RFC2822 string, which is incorrect.
The text was updated successfully, but these errors were encountered: