[erlang-questions] httpd_util:convert_request_date bad_date handling broken?

Zoltan Lajos Kis kiszl@REDACTED
Fri Aug 14 18:15:55 CEST 2009


Look at the source code.
The function clause expects at least four characters to guess the parser 
function to use (three characters for day, forth for separator or 
continuation).
If your input is shorter, the clause won't match and an exception is 
thrown. If it is long enough, the parser function will return bad_date.

Regards,
Zoltan.



cayle.spandon@REDACTED wrote:
> httpd_util:convert_request_date/1 is supposed to return bad_date if 
> the date string is invalid.
>
> For some string it does indeed do that:
>
>> httpd_util:convert_request_date("Sun, 06 Nov 1994 08:49:37 GMT").
> {{1994,11,6},{8,49,37}}
>
>> httpd_util:convert_request_date("Sun, 06 Nov 1994").
> bad_date
>
>> httpd_util:convert_request_date("Nonsense").
> bad_date
>
> However, for other strings it does not return bad_date:
>
>> httpd_util:convert_request_date("Sun").
> ** exception error: no function clause matching 
> httpd_util:convert_request_date("Sun")
>
>> httpd_util:convert_request_date("-1").
> ** exception error: no function clause matching 
> httpd_util:convert_request_date("-1")
>
> Is this a bug in convert_request_date or am I missing something?
>



More information about the erlang-questions mailing list