Hey all,
I ran into a problem in the way RoundCube handles mail messages with
"Date:" headers that aren't 100% compliant with RFC 2822's date format.
The header in question is:
Date: Tue, 21 Oct 2008 00:13:54 0600
Notice that the time zone offset specifier is missing the "+/-" prefix.
Thunderbird seems to drop the zone offset in this case and assume it's
a local date. RoundCube, on the other hand, passes it into PHP's handy
"strtotime" function which interprets 0600 as the year. This leads at
the very least to display problems (in the message list and the message
display), and worst case to invalid dates in the database if caching is
enabled.
I'd like to make RoundCube a little more tolerant, so I was wondering
what everyone else thought about possible solutions. The options I'm
considering are:
- Parse the date using a fixed format string (e.g.
"D, d M Y H:i:s O") and one of PHP's other date functions. This would
prevent misinterpretation but might be even less tolerant.
- Analyze the string before passing to strtotime()
to identify and work around known issues (of which there would be
exactly one at this point). This is a single special case kind of
solution, but strtotime might be reliable enough that this is the only
case we'll hit.
- Find a 3rd party RFC2822-compliant PHP date
parser library.
What do you all think?