Loading lib/parsedate.c +31 −5 Original line number Original line Diff line number Diff line Loading @@ -21,6 +21,8 @@ * $Id$ * $Id$ ***************************************************************************/ ***************************************************************************/ /* /* A brief summary of the date string formats this parser groks: RFC 2616 3.3.1 RFC 2616 3.3.1 Sun, 06 Nov 1994 08:49:37 GMT ; RFC 822, updated by RFC 1123 Sun, 06 Nov 1994 08:49:37 GMT ; RFC 822, updated by RFC 1123 Loading @@ -33,17 +35,28 @@ 06-Nov-94 08:49:37 GMT 06-Nov-94 08:49:37 GMT Nov 6 08:49:37 1994 Nov 6 08:49:37 1994 and without the time zone (we always assume GMT): without the time zone (we always assume GMT): 06 Nov 1994 08:49:37 06 Nov 1994 08:49:37 06-Nov-94 08:49:37 06-Nov-94 08:49:37 or even in weird order: weird order: 1994 Nov 6 08:49:37 (curl_getdate() and GNU date fails) 1994 Nov 6 08:49:37 (curl_getdate() and GNU date fails) 08:49:37 06-Nov-94 GMT 08:49:37 06-Nov-94 Sunday 94 6 Nov 08:49:37 (curl_getdate() and GNU date fails) 94 6 Nov 08:49:37 (curl_getdate() and GNU date fails) time left out: 1994 Nov 6 06-Nov-94 Sun Nov 6 94 odd separators: 1994.Nov.6 Sun/Nov/6/94/GMT */ */ #include "setup.h" #include "setup.h" #include <stdio.h> #include <stdio.h> Loading Loading @@ -132,6 +145,7 @@ static void skip(const char **date) (*date)++; (*date)++; } } #if 0 #define TM_YEAR_ORIGIN 1900 #define TM_YEAR_ORIGIN 1900 /* Yield A - B, measured in seconds. (from getdate.y) */ /* Yield A - B, measured in seconds. (from getdate.y) */ Loading @@ -154,6 +168,7 @@ difftm (struct tm *a, struct tm *b) + (a->tm_min - b->tm_min)) + (a->tm_min - b->tm_min)) + (a->tm_sec - b->tm_sec)); + (a->tm_sec - b->tm_sec)); } } #endif enum assume { enum assume { DATE_MDAY, DATE_MDAY, Loading @@ -177,7 +192,7 @@ time_t Curl_parsedate(const char *date) int part = 0; /* max 6 parts */ int part = 0; /* max 6 parts */ while(part < 6) { while(*date && (part < 6)) { bool found=FALSE; bool found=FALSE; skip(&date); skip(&date); Loading @@ -186,7 +201,7 @@ time_t Curl_parsedate(const char *date) /* a name coming up */ /* a name coming up */ char buf[32]=""; char buf[32]=""; size_t len; size_t len; sscanf(date, "%31[^ ,\n\t-]", buf); sscanf(date, "%31[A-Za-z]", buf); len = strlen(buf); len = strlen(buf); if(wdaynum == -1) { if(wdaynum == -1) { Loading Loading @@ -281,6 +296,8 @@ time_t Curl_parsedate(const char *date) { { struct tm *gmt; struct tm *gmt; long delta; long delta; time_t t2; #ifdef HAVE_GMTIME_R #ifdef HAVE_GMTIME_R /* thread-safe version */ /* thread-safe version */ struct tm keeptime2; struct tm keeptime2; Loading @@ -288,7 +305,16 @@ time_t Curl_parsedate(const char *date) #else #else gmt = gmtime(&t); /* use gmtime_r() if available */ gmt = gmtime(&t); /* use gmtime_r() if available */ #endif #endif #if 0 /* previous involved version (that bugs?) */ delta = difftm(&tm, gmt); delta = difftm(&tm, gmt); #endif t2 = mktime(gmt); delta = t - t2; /* if we would like to adjust to a different input time zone than GMT, we would add that to the delta value right here */ if(t + delta < t) if(t + delta < t) return -1; /* time_t overflow */ return -1; /* time_t overflow */ Loading Loading
lib/parsedate.c +31 −5 Original line number Original line Diff line number Diff line Loading @@ -21,6 +21,8 @@ * $Id$ * $Id$ ***************************************************************************/ ***************************************************************************/ /* /* A brief summary of the date string formats this parser groks: RFC 2616 3.3.1 RFC 2616 3.3.1 Sun, 06 Nov 1994 08:49:37 GMT ; RFC 822, updated by RFC 1123 Sun, 06 Nov 1994 08:49:37 GMT ; RFC 822, updated by RFC 1123 Loading @@ -33,17 +35,28 @@ 06-Nov-94 08:49:37 GMT 06-Nov-94 08:49:37 GMT Nov 6 08:49:37 1994 Nov 6 08:49:37 1994 and without the time zone (we always assume GMT): without the time zone (we always assume GMT): 06 Nov 1994 08:49:37 06 Nov 1994 08:49:37 06-Nov-94 08:49:37 06-Nov-94 08:49:37 or even in weird order: weird order: 1994 Nov 6 08:49:37 (curl_getdate() and GNU date fails) 1994 Nov 6 08:49:37 (curl_getdate() and GNU date fails) 08:49:37 06-Nov-94 GMT 08:49:37 06-Nov-94 Sunday 94 6 Nov 08:49:37 (curl_getdate() and GNU date fails) 94 6 Nov 08:49:37 (curl_getdate() and GNU date fails) time left out: 1994 Nov 6 06-Nov-94 Sun Nov 6 94 odd separators: 1994.Nov.6 Sun/Nov/6/94/GMT */ */ #include "setup.h" #include "setup.h" #include <stdio.h> #include <stdio.h> Loading Loading @@ -132,6 +145,7 @@ static void skip(const char **date) (*date)++; (*date)++; } } #if 0 #define TM_YEAR_ORIGIN 1900 #define TM_YEAR_ORIGIN 1900 /* Yield A - B, measured in seconds. (from getdate.y) */ /* Yield A - B, measured in seconds. (from getdate.y) */ Loading @@ -154,6 +168,7 @@ difftm (struct tm *a, struct tm *b) + (a->tm_min - b->tm_min)) + (a->tm_min - b->tm_min)) + (a->tm_sec - b->tm_sec)); + (a->tm_sec - b->tm_sec)); } } #endif enum assume { enum assume { DATE_MDAY, DATE_MDAY, Loading @@ -177,7 +192,7 @@ time_t Curl_parsedate(const char *date) int part = 0; /* max 6 parts */ int part = 0; /* max 6 parts */ while(part < 6) { while(*date && (part < 6)) { bool found=FALSE; bool found=FALSE; skip(&date); skip(&date); Loading @@ -186,7 +201,7 @@ time_t Curl_parsedate(const char *date) /* a name coming up */ /* a name coming up */ char buf[32]=""; char buf[32]=""; size_t len; size_t len; sscanf(date, "%31[^ ,\n\t-]", buf); sscanf(date, "%31[A-Za-z]", buf); len = strlen(buf); len = strlen(buf); if(wdaynum == -1) { if(wdaynum == -1) { Loading Loading @@ -281,6 +296,8 @@ time_t Curl_parsedate(const char *date) { { struct tm *gmt; struct tm *gmt; long delta; long delta; time_t t2; #ifdef HAVE_GMTIME_R #ifdef HAVE_GMTIME_R /* thread-safe version */ /* thread-safe version */ struct tm keeptime2; struct tm keeptime2; Loading @@ -288,7 +305,16 @@ time_t Curl_parsedate(const char *date) #else #else gmt = gmtime(&t); /* use gmtime_r() if available */ gmt = gmtime(&t); /* use gmtime_r() if available */ #endif #endif #if 0 /* previous involved version (that bugs?) */ delta = difftm(&tm, gmt); delta = difftm(&tm, gmt); #endif t2 = mktime(gmt); delta = t - t2; /* if we would like to adjust to a different input time zone than GMT, we would add that to the delta value right here */ if(t + delta < t) if(t + delta < t) return -1; /* time_t overflow */ return -1; /* time_t overflow */ Loading