Skip to content
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

Not completely RFC2822 conform #3

Closed
Skeeve opened this issue Jul 10, 2019 · 7 comments

Comments

@Skeeve
Copy link

commented Jul 10, 2019

Hi!

I'm testing Date headers with your module and it fails with this header

Date: Wed, 10 Jul 2019 11:20:02 +0200 (CEST)

At first I thought that the format is really not conform, but in fact it is as "(CEST)" simply is a comment, which seems to be allowed by CFWS

date-time       =       [ day-of-week "," ] date FWS time [CFWS]
@choroba

This comment has been minimized.

Copy link

commented Oct 2, 2019

What do you mean? I tried adding

Wed, 10 Jul 2019 11:20:02 +0200 (CEST)

into the t/sample_dates and the test still passes.

@Skeeve

This comment has been minimized.

Copy link
Author

commented Oct 2, 2019

I can recall that the script I wrote failed with exactly that string. Currently I'm removing the comment manually in order to parse using your module.

I will go and check again.

@Skeeve

This comment has been minimized.

Copy link
Author

commented Oct 2, 2019

So this is what I just tested:

perl -MDateTime::Format::Mail -MData::Dumper -e '
  $x=DateTime::Format::Mail->new->strict->parse_datetime("Wed, 10 Jul 2019 11:20:02 +0200 (CEST");
  print Dumper $x;
' 

Result is Invalid format for date! at -e line 2.

@choroba

This comment has been minimized.

Copy link

commented Oct 2, 2019

It's missing the closing parenthesis ), but after fixing it, it still only passes the loose translation.

@Skeeve

This comment has been minimized.

Copy link
Author

commented Oct 2, 2019

The parenthesis was a copy&paste error. Sorry for that.

So you're saying it's my misunderstanding and that this format isn't really RFC conform but just an allowed format?

If so, I think we can close the issue and I have to adjust my script.

Thanks for your effort and for explaining.

@Skeeve

This comment has been minimized.

Copy link
Author

commented Oct 2, 2019

Just realised (RFC2822):

Appendix B. Differences from earlier standards
This appendix contains a list of changes that have been made in the
Internet Message Format from earlier standards, specifically [RFC822]
[…]
14. Free insertion of comments not allowed in date.*

@Skeeve Skeeve closed this Oct 2, 2019
@pali

This comment has been minimized.

Copy link

commented Oct 2, 2019

RFC5322 4. Obsolete Syntax: https://tools.ietf.org/html/rfc5322#section-4

Though these syntactic forms MUST NOT be generated according to the grammar in section 3, they MUST be accepted and parsed by a conformant receiver.

RFC5322 4.3. Obsolete Date and Time: https://tools.ietf.org/html/rfc5322#section-4.3

It also permits comments and folding white space between many of the tokens.

So when parsing Date header you need to allow input which contains comments or folding whitespaces.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.