]> granicus.if.org Git - curl/commitdiff
parsedate: allow time specified without seconds
authorDaniel Stenberg <daniel@haxx.se>
Mon, 27 Sep 2010 14:54:02 +0000 (16:54 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Mon, 27 Sep 2010 14:54:02 +0000 (16:54 +0200)
The date format in RFC822 allows that the seconds part of HH:MM:SS is
left out, but this function didn't allow it. This change also includes a
modified test case that makes sure that this now works.

Reported by: Matt Ford
Bug: http://curl.haxx.se/bug/view.cgi?id=3076529

lib/parsedate.c
tests/data/test517
tests/libtest/lib517.c

index 26f7d84cee0192a64a0e62502277e04adc2f641f..5d8af26925c85bbbf101bf318c5af5ca8f9a7155 100644 (file)
@@ -371,6 +371,12 @@ int Curl_parsedate(const char *date, time_t *output)
         /* time stamp! */
         date += 8;
       }
+      else if((secnum == -1) &&
+              (2 == sscanf(date, "%02d:%02d", &hournum, &minnum))) {
+        /* time stamp without seconds */
+        date += 5;
+        secnum = 0;
+      }
       else {
         val = (int)strtol(date, &end, 10);
 
index 04aa6a089b79077de0e2be5e09154b4df10ff6c9..d7b91842c9d54dcf62892487999669ea6c9548ae 100644 (file)
@@ -103,6 +103,7 @@ nothing
 74: Thu, 999999999999-Aug-2007 20:49:07 GMT => -1
 75: Thu, 12-Aug-2007 20:61:99999999999 GMT => -1
 76: IAintNoDateFool => -1
+77: Thu Apr 18 22:50 2007 GMT => 1176936600
 </stdout>
 
 # This test case previously testes an overflow case ("2094 Nov 6 =>
index 3f7b064ab23b58d43362f7ce32ddd206bed89bc2..38a65d30b3308fd5eb6a7fbb36b6d6a39cfdc066 100644 (file)
@@ -97,6 +97,8 @@ static const char *dates[]={
   "Thu, 999999999999-Aug-2007 20:49:07 GMT",
   "Thu, 12-Aug-2007 20:61:99999999999 GMT",
   "IAintNoDateFool",
+  "Thu Apr 18 22:50 2007 GMT", /* without seconds */
+
   NULL
 };