[PATCH] making ngx_http_parse_time support 1 digit day

Maxim Dounin mdounin at mdounin.ru
Fri Nov 9 15:53:06 UTC 2012


On Fri, Nov 09, 2012 at 12:37:50PM -0200, Wandenberg Peixoto wrote:

> I was checking a strange behavior when parsing dates coming from different
> browsers with this function and observed that it not supports dates with
> only one digit, it expect that the date comes with 01, 02, 03 ...
> But as rfc822 and rfc2822 says the day can be 1, 2 , 3, ... 10, 15, ...
> So I am proposing this patch to be compliant with the rfc.

What nginx supports is specified here:


This includes support for 1-digit years as per asctime() format.  
Format which is subset of date format defined by RFC 1123 (RFC822) 
require two digits as per syntax.

That is, nginx is perfectly RFC complaint - you just looking at 
wrong RFC.

Just for reference, here are the syntax provided in RFC 2616:

       HTTP-date    = rfc1123-date | rfc850-date | asctime-date
       rfc1123-date = wkday "," SP date1 SP time SP "GMT"
       rfc850-date  = weekday "," SP date2 SP time SP "GMT"
       asctime-date = wkday SP date3 SP time SP 4DIGIT
       date1        = 2DIGIT SP month SP 4DIGIT
                      ; day month year (e.g., 02 Jun 1982)
       date2        = 2DIGIT "-" month "-" 2DIGIT
                      ; day-month-year (e.g., 02-Jun-82)
       date3        = month SP ( 2DIGIT | ( SP 1DIGIT ))
                      ; month day (e.g., Jun  2)

> I expect that this patch could be applied to nginx code.

I don't think it's a good idea to relax parsing beyond what 
RFC 2616 requires unless there is really good reason to.


Maxim Dounin

More information about the nginx-devel mailing list