-
Notifications
You must be signed in to change notification settings - Fork 31
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
Wm_util.Date? #91
Comments
I only looked into RFC 1123 and never verified if this is actually the correct RFC for HTTP headers. And RFC 1123 Section 5.2.14 states:
and RFC 822 Section 5.1. states:
You are right, the year calculations are useless, because it's always parsed with 4 digits. I didn't spend too much time on that parser, I just wanted something independent of CalendarLib that is at least not worse than the old parser. So I avoided to read RFCs as much as possible, which is not a joy for me anyway. So if we need a different parser, and not RFC1123, feel free to replace it. So we should implement an RFC7231 parser instead? Regarding the accepted input I would go with Postel's law and be liberal about it as long as it doesn't impair security. But also here I don't have a strong opinion. |
FWIW I haven't been able to find any examples of clients that send timezones alternative to "GMT", and I believe that doing so is wrong. I checked apache's httpd, and nginx, and they seem to agree:
|
to address @hannesm's points:
|
Before the date has been parsed according to RFC 1123. However, as pointed out by issue inhabitedtype#91, RFC 7231 defines a subset of this format for HTTP dates (IMF-fixdate). This change simplifies the parser, assuming the IMF-fixdate format according to RFC 7231. In violence to RFC 7231 the legacy RFC 850 and asctime() formats are intentionally not handled, as before. Closes inhabitedtype#91
Before the date has been parsed according to RFC 1123. However, as pointed out by issue inhabitedtype#91, RFC 7231 defines a subset of this format for HTTP dates (IMF-fixdate). This change simplifies the parser, assuming the IMF-fixdate format according to RFC 7231. In violence to RFC 7231 the legacy RFC 850 and asctime() formats are intentionally not handled, as before. Closes inhabitedtype#91
|
|
ACKing discussion. I haven't had a chance to read it thoroughly but I will get to it this weekend. |
while reviewing the diff between 0.5 and 0.6, I couldn't resist to lookup the specification of HTTP 1.1 and especially the
Date
header (see (obsoleted) RFC 2616 Sec 3.3 and RFC 7231 Section 7.1.1.1) as references):An HTTP-date value represents time as an instance of Coordinated Universal Time (UTC).
-- why does the parser in Wm_util include (i.e. are there clients out there who actually set a different timezone which webmachine needs to support - and what is the reason to hardcode the 8 timezones below)?HTTP-date is case sensitive.
this doesn't seem to be taken care of in webmachine at allyear
is bound toif year < 50 then 2000 + year else if year < 1000 then year + 1000
after%4d
was used insscanf
(which parses a 4 digit number)The function is named
parse_rfc1123_date
(which may actually parse a full RFC 1123 timestamp), but in HTTP theHTTP-Date
is slightly different (a subset thereof, plus allowing other formats) according to the RFCs mentioned above.Using
sscanf
is dangerous: there can be characters at the end of the input which are not matched by the expression, thus a date such asMon, 10 Mar 1994 10:20:30 a0040abcdef
is accepted by webmachine.Should we revise the implementation to (a) include some test cases and (b) be more strict about its input? It is not clear to me whether there are still clients out there (which we would like to talk to) that don't use
IMF-fixdate
, but RFC 850 (Sunday, 06-Nov-94 08:49:37 GMT
) orasctime ()
(Sun Nov 6 08:49:37 1994
), which are both required by 7231. If this is worthwhile, I suspect usingangstrom
for the parser would be more convenient than the OCaml stdlib utilities. or is a dependency onto angstrom in webmachine intentionally avoided?/cc @ansiwen @seliopou
The text was updated successfully, but these errors were encountered: