| 49 |
void check_header(const char *name, const char *value); |
void check_header(const char *name, const char *value); |
| 50 |
bool parse_date(const char *s, struct tm *tm); |
bool parse_date(const char *s, struct tm *tm); |
| 51 |
int month(const char *s); |
int month(const char *s); |
| 52 |
|
time_t mktime_from_utc(struct tm *t); |
| 53 |
const char *skip_lws(const char *s); |
const char *skip_lws(const char *s); |
| 54 |
bool parse_list(const char *s, regex_t *preg, unsigned int n, unsigned int m, |
bool parse_list(const char *s, regex_t *preg, unsigned int n, unsigned int m, |
| 55 |
void (*callback)(const char *s, regmatch_t pmatch[])); |
void (*callback)(const char *s, regmatch_t pmatch[])); |
| 177 |
"^HTTP/([0-9]+)[.]([0-9]+) ([0-9][0-9][0-9]) ([\t -~€-ÿ]*)$", |
"^HTTP/([0-9]+)[.]([0-9]+) ([0-9][0-9][0-9]) ([\t -~€-ÿ]*)$", |
| 178 |
REG_EXTENDED); |
REG_EXTENDED); |
| 179 |
regcomp_wrapper(&re_token, |
regcomp_wrapper(&re_token, |
| 180 |
"^([-0-9a-zA-Z_.]+)", |
"^([-0-9a-zA-Z_.!]+)", |
| 181 |
REG_EXTENDED); |
REG_EXTENDED); |
| 182 |
regcomp_wrapper(&re_token_value, |
regcomp_wrapper(&re_token_value, |
| 183 |
"^([-0-9a-zA-Z_.]+)(=([-0-9a-zA-Z_.]+|\"([^\"]|[\\].)*\"))?", |
"^([-0-9a-zA-Z_.!]+)(=([-0-9a-zA-Z_.!]+|\"([^\"]|[\\].)*\"))?", |
| 184 |
REG_EXTENDED); |
REG_EXTENDED); |
| 185 |
regcomp_wrapper(&re_content_type, |
regcomp_wrapper(&re_content_type, |
| 186 |
"^([-0-9a-zA-Z_.]+)/([-0-9a-zA-Z_.]+)[ \t]*" |
"^([-0-9a-zA-Z_.]+)/([-0-9a-zA-Z_.]+)[ \t]*" |
| 194 |
"^(W/[ \t]*)?\"([^\"]|[\\].)*\"$", |
"^(W/[ \t]*)?\"([^\"]|[\\].)*\"$", |
| 195 |
REG_EXTENDED); |
REG_EXTENDED); |
| 196 |
regcomp_wrapper(&re_server, |
regcomp_wrapper(&re_server, |
| 197 |
"^((([-0-9a-zA-Z_.]+(/[-0-9a-zA-Z_.]+)?)|(\\(.*\\)))[ \t]*)+$", |
"^((([-0-9a-zA-Z_.!]+(/[-0-9a-zA-Z_.]+)?)|(\\(.*\\)))[ \t]*)+$", |
| 198 |
REG_EXTENDED); |
REG_EXTENDED); |
| 199 |
regcomp_wrapper(&re_transfer_coding, |
regcomp_wrapper(&re_transfer_coding, |
| 200 |
"^([-0-9a-zA-Z_.]+)[ \t]*" |
"^([-0-9a-zA-Z_.]+)[ \t]*" |
| 205 |
"^([-0-9a-zA-Z_.](/[-0-9a-zA-Z_.])?)+$", |
"^([-0-9a-zA-Z_.](/[-0-9a-zA-Z_.])?)+$", |
| 206 |
REG_EXTENDED); |
REG_EXTENDED); |
| 207 |
regcomp_wrapper(&re_ugly, |
regcomp_wrapper(&re_ugly, |
| 208 |
"^[a-zA-Z0-9]+://[^/]+[/a-zA-Z0-9-_]*$", |
"^[a-zA-Z0-9]+://[^/]+[-/a-zA-Z0-9_]*$", |
| 209 |
REG_EXTENDED); |
REG_EXTENDED); |
| 210 |
regcomp_wrapper(&re_rfc1123, |
regcomp_wrapper(&re_rfc1123, |
| 211 |
"^(Mon|Tue|Wed|Thu|Fri|Sat|Sun), ([0123][0-9]) " |
"^(Mon|Tue|Wed|Thu|Fri|Sat|Sun), ([0123][0-9]) " |
| 398 |
if (header) { |
if (header) { |
| 399 |
header->count++; |
header->count++; |
| 400 |
header->handler(value); |
header->handler(value); |
| 401 |
} else |
} else if ((name[0] == 'X' || name[0] == 'x') && name[1] == '-') { |
| 402 |
|
lookup("xheader"); |
| 403 |
|
} else { |
| 404 |
lookup("nonstandard"); |
lookup("nonstandard"); |
| 405 |
|
} |
| 406 |
} |
} |
| 407 |
|
|
| 408 |
|
|
| 415 |
int len = strlen(s); |
int len = strlen(s); |
| 416 |
regmatch_t pmatch[20]; |
regmatch_t pmatch[20]; |
| 417 |
|
|
|
tm->tm_wday = 0; |
|
|
tm->tm_yday = 0; |
|
|
tm->tm_isdst = 0; |
|
|
tm->tm_gmtoff = 0; |
|
|
tm->tm_zone = "GMT"; |
|
|
|
|
| 418 |
if (len == 29) { |
if (len == 29) { |
| 419 |
/* RFC 1123 */ |
/* RFC 1123 */ |
| 420 |
r = regexec(&re_rfc1123, s, 20, pmatch, 0); |
r = regexec(&re_rfc1123, s, 20, pmatch, 0); |
| 499 |
|
|
| 500 |
|
|
| 501 |
/** |
/** |
| 502 |
|
* UTC version of mktime, from |
| 503 |
|
* http://lists.debian.org/deity/2002/deity-200204/msg00082.html |
| 504 |
|
*/ |
| 505 |
|
time_t mktime_from_utc(struct tm *t) |
| 506 |
|
{ |
| 507 |
|
time_t tl, tb; |
| 508 |
|
struct tm *tg; |
| 509 |
|
|
| 510 |
|
tl = mktime (t); |
| 511 |
|
if (tl == -1) |
| 512 |
|
{ |
| 513 |
|
t->tm_hour--; |
| 514 |
|
tl = mktime (t); |
| 515 |
|
if (tl == -1) |
| 516 |
|
return -1; /* can't deal with output from strptime */ |
| 517 |
|
tl += 3600; |
| 518 |
|
} |
| 519 |
|
tg = gmtime (&tl); |
| 520 |
|
tg->tm_isdst = 0; |
| 521 |
|
tb = mktime (tg); |
| 522 |
|
if (tb == -1) |
| 523 |
|
{ |
| 524 |
|
tg->tm_hour--; |
| 525 |
|
tb = mktime (tg); |
| 526 |
|
if (tb == -1) |
| 527 |
|
return -1; /* can't deal with output from gmtime */ |
| 528 |
|
tb += 3600; |
| 529 |
|
} |
| 530 |
|
return (tl - (tb - tl)); |
| 531 |
|
} |
| 532 |
|
|
| 533 |
|
|
| 534 |
|
/** |
| 535 |
* Skip optional LWS (linear white space) [2.2] |
* Skip optional LWS (linear white space) [2.2] |
| 536 |
*/ |
*/ |
| 537 |
const char *skip_lws(const char *s) |
const char *skip_lws(const char *s) |
| 785 |
time0 = time(0); |
time0 = time(0); |
| 786 |
if (!parse_date(s, &tm)) |
if (!parse_date(s, &tm)) |
| 787 |
return; |
return; |
| 788 |
time1 = mktime(&tm); |
time1 = mktime_from_utc(&tm); |
| 789 |
|
|
| 790 |
diff = difftime(time0, time1); |
diff = difftime(time0, time1); |
| 791 |
if (10 < fabs(diff)) |
if (10 < fabs(diff)) |
| 820 |
time0 = time(0); |
time0 = time(0); |
| 821 |
if (!parse_date(s, &tm)) |
if (!parse_date(s, &tm)) |
| 822 |
return; |
return; |
| 823 |
time1 = mktime(&tm); |
time1 = mktime_from_utc(&tm); |
| 824 |
|
|
| 825 |
diff = difftime(time1, time0); |
diff = difftime(time1, time0); |
| 826 |
if (10 < diff) |
if (10 < diff) |
| 1089 |
{ "via", "This header was added by a proxy, cache or gateway." }, |
{ "via", "This header was added by a proxy, cache or gateway." }, |
| 1090 |
{ "wrongdate", "Warning: The server date-time differs from this system's " |
{ "wrongdate", "Warning: The server date-time differs from this system's " |
| 1091 |
"date-time by more than 10 seconds. Check that both the " |
"date-time by more than 10 seconds. Check that both the " |
| 1092 |
"system clocks are correct." } |
"system clocks are correct." }, |
| 1093 |
|
{ "xheader", "This is an extension header. I don't know how to check it." } |
| 1094 |
}; |
}; |
| 1095 |
|
|
| 1096 |
|
|