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

Already on GitHub? Sign in to your account

Handle invalid date for robustness #594

wants to merge 3 commits into


None yet
7 participants

okkez commented Aug 6, 2013

This PR can improve robustness for parsing mail that have invalid date in Date and Received header.

This PR can also fix #564.


bpot commented Jan 7, 2014

This looks pretty good to me. We're seeing the same issue.

I'm seeing this same issue. Is there any particular reason this hasn't been merged? Should I look for an alternative fix?


okkez commented May 30, 2014

Please merge into 2-5-stable.
Something wrong? Please tell me.

mgoggin commented Jun 6, 2014

I was bitten by this today. Found out that our incoming mail parser hadn't been running for ~2 months. It was because the format returned by the ::DateTime#to_s method couldn't be parsed by ::DateTime#parse.

We have to use a weird string format for DateTimes because there's a non-technical executive who insists that peoples' brains read the date in that format.

My solution was somewhat similar, albeit not nearly as robust: monkey-patch Mail:ReceivedField#date_time to only parse the string representation of element.date_time if it isn't already a ::DateTime object.

Looking forward to seeing this merged in and part of a formal release.


bf4 commented Jun 7, 2014

Shouldn't the invalid date_time return a kind of DateTime::Invalid < DateTime rather than nil?


okkez commented Oct 24, 2014

Shouldn't the invalid date_time return a kind of DateTime::Invalid < DateTime rather than nil?

I think nil is proper for this.
Because we don't have DateTime::Invalid class or constant.

jmehnle commented Mar 19, 2015

Knock, knock. What does it take to get this merged?

okkez added some commits Aug 5, 2013

Reduce redundant method call
Because element.date_time is already DateTime in normal case.
Handle invalid date without exception in Date header
This change can improve robustness.

okkez commented Nov 11, 2016

I've rebased against master branch and force pushed.

@jeremy jeremy self-assigned this May 17, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment