1 |
/* |
/* |
2 |
* HTTP Header Lint |
* HTTP Header Lint |
3 |
* Licensed under the same license as Curl |
* Licensed under the MIT License |
4 |
* http://curl.haxx.se/docs/copyright.html |
* http://www.opensource.org/licenses/mit-license |
5 |
* Copyright 2003 James Bursa <bursa@users.sourceforge.net> |
* Copyright 2004 James Bursa <bursa@users.sourceforge.net> |
6 |
*/ |
*/ |
7 |
|
|
8 |
/* |
/* |
32 |
|
|
33 |
|
|
34 |
bool start; |
bool start; |
35 |
|
bool html = false; |
36 |
CURL *curl; |
CURL *curl; |
37 |
int status_code; |
int status_code; |
38 |
char error_buffer[CURL_ERROR_SIZE]; |
char error_buffer[CURL_ERROR_SIZE]; |
39 |
regex_t re_status_line, re_token, re_token_value, re_content_type, re_ugly, |
regex_t re_status_line, re_token, re_token_value, re_content_type, re_ugly, |
40 |
re_absolute_uri, re_etag, re_server, re_transfer_coding, re_upgrade, |
re_absolute_uri, re_etag, re_server, re_transfer_coding, re_upgrade, |
41 |
re_rfc1123, re_rfc1036, re_asctime; |
re_rfc1123, re_rfc1036, re_asctime, re_cookie_nameval, re_cookie_expires; |
42 |
|
|
43 |
|
|
44 |
void init(void); |
void init(void); |
82 |
void header_upgrade(const char *s); |
void header_upgrade(const char *s); |
83 |
void header_vary(const char *s); |
void header_vary(const char *s); |
84 |
void header_via(const char *s); |
void header_via(const char *s); |
85 |
|
void header_set_cookie(const char *s); |
86 |
void die(const char *error); |
void die(const char *error); |
|
void warning(const char *message); |
|
|
void error(const char *message); |
|
87 |
void print(const char *s, size_t len); |
void print(const char *s, size_t len); |
88 |
void lookup(const char *key); |
void lookup(const char *key); |
89 |
|
|
114 |
{ "Pragma", header_pragma, 0, 0 }, |
{ "Pragma", header_pragma, 0, 0 }, |
115 |
{ "Retry-After", header_retry_after, 0, 0 }, |
{ "Retry-After", header_retry_after, 0, 0 }, |
116 |
{ "Server", header_server, 0, 0 }, |
{ "Server", header_server, 0, 0 }, |
117 |
|
{ "Set-Cookie", header_set_cookie, 0, 0 }, |
118 |
{ "Trailer", header_trailer, 0, 0 }, |
{ "Trailer", header_trailer, 0, 0 }, |
119 |
{ "Transfer-Encoding", header_transfer_encoding, 0, 0 }, |
{ "Transfer-Encoding", header_transfer_encoding, 0, 0 }, |
120 |
{ "Upgrade", header_upgrade, 0, 0 }, |
{ "Upgrade", header_upgrade, 0, 0 }, |
128 |
*/ |
*/ |
129 |
int main(int argc, char *argv[]) |
int main(int argc, char *argv[]) |
130 |
{ |
{ |
131 |
int i; |
int i = 1; |
132 |
|
|
133 |
if (argc < 2) |
if (argc < 2) |
134 |
die("Usage: httplint url [url ...]"); |
die("Usage: httplint [--html] url [url ...]"); |
135 |
|
|
136 |
init(); |
init(); |
137 |
|
|
138 |
for (i = 1; i != argc; i++) |
if (1 < argc && strcmp(argv[1], "--html") == 0) { |
139 |
|
html = true; |
140 |
|
i++; |
141 |
|
} |
142 |
|
|
143 |
|
for (; i != argc; i++) |
144 |
check_url(argv[i]); |
check_url(argv[i]); |
145 |
|
|
146 |
curl_global_cleanup(); |
curl_global_cleanup(); |
183 |
"^HTTP/([0-9]+)[.]([0-9]+) ([0-9][0-9][0-9]) ([\t -~€-ÿ]*)$", |
"^HTTP/([0-9]+)[.]([0-9]+) ([0-9][0-9][0-9]) ([\t -~€-ÿ]*)$", |
184 |
REG_EXTENDED); |
REG_EXTENDED); |
185 |
regcomp_wrapper(&re_token, |
regcomp_wrapper(&re_token, |
186 |
"^([-0-9a-zA-Z_.]+)", |
"^([-0-9a-zA-Z_.!]+)", |
187 |
REG_EXTENDED); |
REG_EXTENDED); |
188 |
regcomp_wrapper(&re_token_value, |
regcomp_wrapper(&re_token_value, |
189 |
"^([-0-9a-zA-Z_.]+)(=([-0-9a-zA-Z_.]+|\"([^\"]|[\\].)*\"))?", |
"^([-0-9a-zA-Z_.!]+)(=([-0-9a-zA-Z_.!]+|\"([^\"]|[\\].)*\"))?", |
190 |
REG_EXTENDED); |
REG_EXTENDED); |
191 |
regcomp_wrapper(&re_content_type, |
regcomp_wrapper(&re_content_type, |
192 |
"^([-0-9a-zA-Z_.]+)/([-0-9a-zA-Z_.]+)[ \t]*" |
"^([-0-9a-zA-Z_.]+)/([-0-9a-zA-Z_.]+)[ \t]*" |
200 |
"^(W/[ \t]*)?\"([^\"]|[\\].)*\"$", |
"^(W/[ \t]*)?\"([^\"]|[\\].)*\"$", |
201 |
REG_EXTENDED); |
REG_EXTENDED); |
202 |
regcomp_wrapper(&re_server, |
regcomp_wrapper(&re_server, |
203 |
"^((([-0-9a-zA-Z_.]+(/[-0-9a-zA-Z_.]+)?)|(\\(.*\\)))[ \t]*)+$", |
"^((([-0-9a-zA-Z_.!]+(/[-0-9a-zA-Z_.]+)?)|(\\(.*\\)))[ \t]*)+$", |
204 |
REG_EXTENDED); |
REG_EXTENDED); |
205 |
regcomp_wrapper(&re_transfer_coding, |
regcomp_wrapper(&re_transfer_coding, |
206 |
"^([-0-9a-zA-Z_.]+)[ \t]*" |
"^([-0-9a-zA-Z_.]+)[ \t]*" |
228 |
"(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) ([ 12][0-9]) " |
"(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) ([ 12][0-9]) " |
229 |
"([012][0-9]):([0-5][0-9]):([0-5][0-9]) ([0-9]{4})$", |
"([012][0-9]):([0-5][0-9]):([0-5][0-9]) ([0-9]{4})$", |
230 |
REG_EXTENDED); |
REG_EXTENDED); |
231 |
|
regcomp_wrapper(&re_cookie_nameval, |
232 |
|
"^[^;, ]+=[^;, ]*$", |
233 |
|
REG_EXTENDED); |
234 |
|
regcomp_wrapper(&re_cookie_expires, |
235 |
|
"^(Mon|Tue|Wed|Thu|Fri|Sat|Sun), ([0123][0-9])-" |
236 |
|
"(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)-([0-9]{4}) " |
237 |
|
"([012][0-9]):([0-5][0-9]):([0-5][0-9]) GMT$", |
238 |
|
REG_EXTENDED); |
239 |
} |
} |
240 |
|
|
241 |
|
|
267 |
for (i = 0; i != sizeof header_table / sizeof header_table[0]; i++) |
for (i = 0; i != sizeof header_table / sizeof header_table[0]; i++) |
268 |
header_table[i].count = 0; |
header_table[i].count = 0; |
269 |
|
|
270 |
printf("Checking URL %s\n", url); |
if (!html) |
271 |
if (strncmp(url, "http", 4)) |
printf("Checking URL %s\n", url); |
272 |
warning("this is not an http or https url"); |
if (strncmp(url, "http", 4)) { |
273 |
|
if (html) |
274 |
|
printf("<p class='warning'>"); |
275 |
|
printf("Warning: this is not an http or https url"); |
276 |
|
if (html) |
277 |
|
printf("</p>"); |
278 |
|
printf("\n"); |
279 |
|
} |
280 |
|
|
281 |
if (curl_easy_setopt(curl, CURLOPT_URL, url)) |
if (curl_easy_setopt(curl, CURLOPT_URL, url)) |
282 |
die("Failed to set curl options"); |
die("Failed to set curl options"); |
283 |
|
|
284 |
|
if (html) |
285 |
|
printf("<ul>\n"); |
286 |
code = curl_easy_perform(curl); |
code = curl_easy_perform(curl); |
287 |
|
if (html) |
288 |
|
printf("</ul>\n"); |
289 |
if (code != CURLE_OK && code != CURLE_WRITE_ERROR) { |
if (code != CURLE_OK && code != CURLE_WRITE_ERROR) { |
290 |
error(error_buffer); |
if (html) |
291 |
|
printf("<p class='error'>"); |
292 |
|
printf("Error: "); |
293 |
|
print(error_buffer, strlen(error_buffer)); |
294 |
|
printf("."); |
295 |
|
if (html) |
296 |
|
printf("</p>"); |
297 |
|
printf("\n"); |
298 |
return; |
return; |
299 |
} else { |
} else { |
300 |
printf("\n"); |
printf("\n"); |
301 |
|
if (html) |
302 |
|
printf("<ul>"); |
303 |
for (i = 0; i != sizeof header_table / sizeof header_table[0]; i++) { |
for (i = 0; i != sizeof header_table / sizeof header_table[0]; i++) { |
304 |
if (header_table[i].count == 0 && header_table[i].missing) |
if (header_table[i].count == 0 && header_table[i].missing) |
305 |
lookup(header_table[i].missing); |
lookup(header_table[i].missing); |
309 |
r = regexec(&re_ugly, url, 0, 0, 0); |
r = regexec(&re_ugly, url, 0, 0, 0); |
310 |
if (r) |
if (r) |
311 |
lookup("ugly"); |
lookup("ugly"); |
312 |
|
|
313 |
|
if (html) |
314 |
|
printf("</ul>"); |
315 |
} |
} |
316 |
|
|
317 |
|
|
325 |
|
|
326 |
UNUSED(stream); |
UNUSED(stream); |
327 |
|
|
328 |
printf("* "); |
printf(html ? "<li><code>" : "* "); |
329 |
print(ptr, size); |
print(ptr, size); |
330 |
printf("\n"); |
printf(html ? "</code><ul>" : "\n"); |
331 |
|
|
332 |
if (size < 2 || ptr[size - 2] != 13 || ptr[size - 1] != 10) { |
if (size < 2 || ptr[size - 2] != 13 || ptr[size - 1] != 10) { |
333 |
lookup("notcrlf"); |
lookup("notcrlf"); |
334 |
|
if (html) |
335 |
|
printf("</ul></li>\n"); |
336 |
return size; |
return size; |
337 |
} |
} |
338 |
if (sizeof s <= size) { |
if (sizeof s <= size) { |
339 |
warning("header too long: ignored\n"); |
lookup("headertoolong"); |
340 |
|
if (html) |
341 |
|
printf("</ul></li>\n"); |
342 |
return size; |
return size; |
343 |
} |
} |
344 |
strncpy(s, ptr, size); |
strncpy(s, ptr, size); |
349 |
|
|
350 |
if (s[0] == 0) { |
if (s[0] == 0) { |
351 |
/* empty header indicates end of headers */ |
/* empty header indicates end of headers */ |
352 |
puts("End of headers."); |
lookup("endofheaders"); |
353 |
|
if (html) |
354 |
|
printf("</ul></li>\n"); |
355 |
return 0; |
return 0; |
356 |
|
|
357 |
} else if (start) { |
} else if (start) { |
369 |
check_header(name, skip_lws(value)); |
check_header(name, skip_lws(value)); |
370 |
} |
} |
371 |
|
|
372 |
|
if (html) |
373 |
|
printf("</ul></li>\n"); |
374 |
return size; |
return size; |
375 |
} |
} |
376 |
|
|
443 |
if (header) { |
if (header) { |
444 |
header->count++; |
header->count++; |
445 |
header->handler(value); |
header->handler(value); |
446 |
} else |
} else if ((name[0] == 'X' || name[0] == 'x') && name[1] == '-') { |
447 |
|
lookup("xheader"); |
448 |
|
} else { |
449 |
lookup("nonstandard"); |
lookup("nonstandard"); |
450 |
|
} |
451 |
} |
} |
452 |
|
|
453 |
|
|
602 |
do { |
do { |
603 |
r = regexec(preg, s, 20, pmatch, 0); |
r = regexec(preg, s, 20, pmatch, 0); |
604 |
if (r) { |
if (r) { |
605 |
|
if (html) |
606 |
|
printf("<li class='error'>"); |
607 |
printf(" Failed to match list item %i\n", items + 1); |
printf(" Failed to match list item %i\n", items + 1); |
608 |
|
if (html) |
609 |
|
printf("</li>\n"); |
610 |
return false; |
return false; |
611 |
} |
} |
612 |
|
|
619 |
if (*s == 0) |
if (*s == 0) |
620 |
break; |
break; |
621 |
if (*s != ',') { |
if (*s != ',') { |
622 |
|
if (html) |
623 |
|
printf("<li class='error'>"); |
624 |
printf(" Expecting , after list item %i\n", items); |
printf(" Expecting , after list item %i\n", items); |
625 |
|
if (html) |
626 |
|
printf("</li>\n"); |
627 |
return false; |
return false; |
628 |
} |
} |
629 |
while (*s == ',') |
while (*s == ',') |
631 |
} while (*s != 0); |
} while (*s != 0); |
632 |
|
|
633 |
if (items < n || m < items) { |
if (items < n || m < items) { |
634 |
|
if (html) |
635 |
|
printf("<li class='error'>"); |
636 |
printf(" %i items in list, but there should be ", items); |
printf(" %i items in list, but there should be ", items); |
637 |
if (m == UINT_MAX) |
if (m == UINT_MAX) |
638 |
printf("at least %i\n", n); |
printf("at least %i\n", n); |
639 |
else |
else |
640 |
printf("between %i and %i\n", n, m); |
printf("between %i and %i\n", n, m); |
641 |
|
if (html) |
642 |
|
printf("</li>\n"); |
643 |
return false; |
return false; |
644 |
} |
} |
645 |
|
|
709 |
(int (*)(const void *, const void *)) strcasecmp); |
(int (*)(const void *, const void *)) strcasecmp); |
710 |
|
|
711 |
if (!dir) { |
if (!dir) { |
712 |
printf(" Cache-Control directive '%s':\n", name); |
if (html) |
713 |
|
printf("<li class='warning'>"); |
714 |
|
printf(" Cache-Control directive '"); |
715 |
|
print(name, strlen(name)); |
716 |
|
printf("':\n"); |
717 |
|
if (html) |
718 |
|
printf("</li>\n"); |
719 |
lookup("unknowncachecont"); |
lookup("unknowncachecont"); |
720 |
} |
} |
721 |
} |
} |
760 |
sizeof content_coding_list[0], |
sizeof content_coding_list[0], |
761 |
(int (*)(const void *, const void *)) strcasecmp); |
(int (*)(const void *, const void *)) strcasecmp); |
762 |
if (!dir) { |
if (!dir) { |
763 |
|
if (html) |
764 |
|
printf("<li class='warning'>"); |
765 |
printf(" Content-Encoding '%s':\n", name); |
printf(" Content-Encoding '%s':\n", name); |
766 |
|
if (html) |
767 |
|
printf("</li>\n"); |
768 |
lookup("unknowncontenc"); |
lookup("unknowncontenc"); |
769 |
} |
} |
770 |
} |
} |
887 |
time0 = time(0); |
time0 = time(0); |
888 |
if (!parse_date(s, &tm)) |
if (!parse_date(s, &tm)) |
889 |
return; |
return; |
890 |
time1 = mktime(&tm); |
time1 = mktime_from_utc(&tm); |
891 |
|
|
892 |
diff = difftime(time1, time0); |
diff = difftime(time1, time0); |
893 |
if (10 < diff) |
if (10 < diff) |
979 |
sizeof transfer_coding_list[0], |
sizeof transfer_coding_list[0], |
980 |
(int (*)(const void *, const void *)) strcasecmp); |
(int (*)(const void *, const void *)) strcasecmp); |
981 |
if (!dir) { |
if (!dir) { |
982 |
|
if (html) |
983 |
|
printf("<li class='warning'>"); |
984 |
printf(" Transfer-Encoding '%s':\n", name); |
printf(" Transfer-Encoding '%s':\n", name); |
985 |
|
if (html) |
986 |
|
printf("</li>\n"); |
987 |
lookup("unknowntransenc"); |
lookup("unknowntransenc"); |
988 |
} |
} |
989 |
} |
} |
1012 |
lookup("via"); |
lookup("via"); |
1013 |
} |
} |
1014 |
|
|
1015 |
|
/* http://wp.netscape.com/newsref/std/cookie_spec.html */ |
1016 |
/** |
void header_set_cookie(const char *s) |
|
* Print an error message and exit. |
|
|
*/ |
|
|
void die(const char *error) |
|
1017 |
{ |
{ |
1018 |
fprintf(stderr, "httplint: %s\n", error); |
bool ok = true; |
1019 |
exit(EXIT_FAILURE); |
int r; |
1020 |
} |
const char *semi = strchr(s, ';'); |
1021 |
|
const char *s2; |
1022 |
|
struct tm tm; |
1023 |
|
double diff; |
1024 |
|
time_t time0, time1; |
1025 |
|
regmatch_t pmatch[20]; |
1026 |
|
|
1027 |
|
if (semi) |
1028 |
|
s2 = strndup(s, semi - s); |
1029 |
|
else |
1030 |
|
s2 = s; |
1031 |
|
|
1032 |
/** |
r = regexec(&re_cookie_nameval, s2, 0, 0, 0); |
1033 |
* Print a warning message. |
if (r) { |
1034 |
*/ |
lookup("cookiebadnameval"); |
1035 |
void warning(const char *message) |
ok = false; |
1036 |
{ |
} |
1037 |
printf("Warning: %s\n", message); |
|
1038 |
|
if (!semi) |
1039 |
|
return; |
1040 |
|
|
1041 |
|
s = skip_lws(semi + 1); |
1042 |
|
|
1043 |
|
while (*s) { |
1044 |
|
semi = strchr(s, ';'); |
1045 |
|
if (semi) |
1046 |
|
s2 = strndup(s, semi - s); |
1047 |
|
else |
1048 |
|
s2 = s; |
1049 |
|
|
1050 |
|
if (strncasecmp(s2, "expires=", 8) == 0) { |
1051 |
|
s2 += 8; |
1052 |
|
r = regexec(&re_cookie_expires, s2, 20, pmatch, 0); |
1053 |
|
if (r == 0) { |
1054 |
|
tm.tm_mday = atoi(s2 + pmatch[2].rm_so); |
1055 |
|
tm.tm_mon = month(s2 + pmatch[3].rm_so); |
1056 |
|
tm.tm_year = atoi(s2 + pmatch[4].rm_so) - 1900; |
1057 |
|
tm.tm_hour = atoi(s2 + pmatch[5].rm_so); |
1058 |
|
tm.tm_min = atoi(s2 + pmatch[6].rm_so); |
1059 |
|
tm.tm_sec = atoi(s2 + pmatch[7].rm_so); |
1060 |
|
|
1061 |
|
time0 = time(0); |
1062 |
|
time1 = mktime_from_utc(&tm); |
1063 |
|
|
1064 |
|
diff = difftime(time0, time1); |
1065 |
|
if (10 < diff) { |
1066 |
|
lookup("cookiepastdate"); |
1067 |
|
ok = false; |
1068 |
|
} |
1069 |
|
} else { |
1070 |
|
lookup("cookiebaddate"); |
1071 |
|
ok = false; |
1072 |
|
} |
1073 |
|
} else if (strncasecmp(s2, "domain=", 7) == 0) { |
1074 |
|
} else if (strncasecmp(s2, "path=", 5) == 0) { |
1075 |
|
if (s2[5] != '/') { |
1076 |
|
lookup("cookiebadpath"); |
1077 |
|
ok = false; |
1078 |
|
} |
1079 |
|
} else if (strcasecmp(s, "secure") == 0) { |
1080 |
|
} else { |
1081 |
|
if (html) |
1082 |
|
printf("<li class='warning'>"); |
1083 |
|
printf(" Set-Cookie field '%s':\n", s2); |
1084 |
|
if (html) |
1085 |
|
printf("</li>\n"); |
1086 |
|
lookup("cookieunknownfield"); |
1087 |
|
ok = false; |
1088 |
|
} |
1089 |
|
|
1090 |
|
if (semi) |
1091 |
|
s = skip_lws(semi + 1); |
1092 |
|
else |
1093 |
|
break; |
1094 |
|
} |
1095 |
|
|
1096 |
|
if (ok) |
1097 |
|
lookup("ok"); |
1098 |
} |
} |
1099 |
|
|
1100 |
|
|
1101 |
/** |
/** |
1102 |
* Print an error message. |
* Print an error message and exit. |
1103 |
*/ |
*/ |
1104 |
void error(const char *message) |
void die(const char *error) |
1105 |
{ |
{ |
1106 |
printf("Error: %s\n", message); |
fprintf(stderr, "httplint: %s\n", error); |
1107 |
|
exit(EXIT_FAILURE); |
1108 |
} |
} |
1109 |
|
|
1110 |
|
|
1115 |
{ |
{ |
1116 |
size_t i; |
size_t i; |
1117 |
for (i = 0; i != len; i++) { |
for (i = 0; i != len; i++) { |
1118 |
if (31 < s[i] && s[i] < 127) |
if (html && s[i] == '<') |
1119 |
|
printf("<"); |
1120 |
|
else if (html && s[i] == '>') |
1121 |
|
printf(">"); |
1122 |
|
else if (html && s[i] == '&') |
1123 |
|
printf("&"); |
1124 |
|
else if (31 < s[i] && s[i] < 127) |
1125 |
putchar(s[i]); |
putchar(s[i]); |
1126 |
else |
else { |
1127 |
|
if (html) |
1128 |
|
printf("<span class='cc'>"); |
1129 |
printf("[%.2x]", s[i]); |
printf("[%.2x]", s[i]); |
1130 |
|
if (html) |
1131 |
|
printf("</span>"); |
1132 |
|
} |
1133 |
} |
} |
1134 |
} |
} |
1135 |
|
|
1194 |
"of header names, or \"*\"." }, |
"of header names, or \"*\"." }, |
1195 |
{ "contentrange", "Warning: The Content-Range header should not be returned " |
{ "contentrange", "Warning: The Content-Range header should not be returned " |
1196 |
"by the server for this request." }, |
"by the server for this request." }, |
1197 |
|
{ "cookiebaddate", "Error: The expires date must be in the form " |
1198 |
|
"\"Wdy, DD-Mon-YYYY HH:MM:SS GMT\"." }, |
1199 |
|
{ "cookiebadnameval", "Error: A Set-Cookie header must start with " |
1200 |
|
"name=value, each excluding semi-colon, comma and " |
1201 |
|
"white space." }, |
1202 |
|
{ "cookiebadpath", "Error: The path does not start with \"/\"." }, |
1203 |
|
{ "cookiepastdate", "Warning: The expires date is in the past. The cookie " |
1204 |
|
"will be deleted by browsers." }, |
1205 |
|
{ "cookieunknownfield", "Warning: This is not a standard Set-Cookie " |
1206 |
|
"field." }, |
1207 |
|
{ "endofheaders", "End of headers." }, |
1208 |
{ "futurehttp", "Warning: I only understand HTTP/1.1. Check for a newer " |
{ "futurehttp", "Warning: I only understand HTTP/1.1. Check for a newer " |
1209 |
"version of this tool." }, |
"version of this tool." }, |
1210 |
{ "futurelastmod", "Error: The specified Last-Modified date-time is in " |
{ "futurelastmod", "Error: The specified Last-Modified date-time is in " |
1211 |
"the future." }, |
"the future." }, |
1212 |
|
{ "headertoolong", "Warning: Header too long: ignored." }, |
1213 |
{ "missingcolon", "Error: Headers must be of the form 'Name: value'." }, |
{ "missingcolon", "Error: Headers must be of the form 'Name: value'." }, |
1214 |
{ "missingcontenttype", "Warning: No Content-Type header was present. The " |
{ "missingcontenttype", "Warning: No Content-Type header was present. The " |
1215 |
"client will have to guess the media type or ask " |
"client will have to guess the media type or ask " |
1250 |
{ "via", "This header was added by a proxy, cache or gateway." }, |
{ "via", "This header was added by a proxy, cache or gateway." }, |
1251 |
{ "wrongdate", "Warning: The server date-time differs from this system's " |
{ "wrongdate", "Warning: The server date-time differs from this system's " |
1252 |
"date-time by more than 10 seconds. Check that both the " |
"date-time by more than 10 seconds. Check that both the " |
1253 |
"system clocks are correct." } |
"system clocks are correct." }, |
1254 |
|
{ "xheader", "This is an extension header. I don't know how to check it." } |
1255 |
}; |
}; |
1256 |
|
|
1257 |
|
|
1273 |
else |
else |
1274 |
s = key; |
s = key; |
1275 |
|
|
1276 |
printf(" "); |
if (html) { |
1277 |
x = 4; |
if (strncmp(s, "Warning:", 8) == 0) |
1278 |
while (*s) { |
printf("<li class='warning'>"); |
1279 |
spc = strchr(s, ' '); |
else if (strncmp(s, "Error:", 6) == 0) |
1280 |
if (!spc) |
printf("<li class='error'>"); |
1281 |
spc = s + strlen(s); |
else if (strncmp(s, "OK", 2) == 0) |
1282 |
if (75 < x + (spc - s)) { |
printf("<li class='ok'>"); |
|
printf("\n "); |
|
|
x = 4; |
|
|
} |
|
|
x += spc - s + 1; |
|
|
printf("%.*s ", spc - s, s); |
|
|
if (*spc) |
|
|
s = spc + 1; |
|
1283 |
else |
else |
1284 |
s = spc; |
printf("<li>"); |
1285 |
|
for (; *s; s++) { |
1286 |
|
if (strncmp(s, "http://", 7) == 0) { |
1287 |
|
spc = strchr(s, ' '); |
1288 |
|
printf("<a href='%.*s'>%.*s</a>", spc - s, s, spc - s, s); |
1289 |
|
s = spc; |
1290 |
|
} |
1291 |
|
switch (*s) { |
1292 |
|
case '<': printf("<"); break; |
1293 |
|
case '>': printf(">"); break; |
1294 |
|
case '&': printf("&"); break; |
1295 |
|
default: printf("%c", *s); break; |
1296 |
|
} |
1297 |
|
} |
1298 |
|
printf("</li>\n"); |
1299 |
|
|
1300 |
|
} else { |
1301 |
|
printf(" "); |
1302 |
|
x = 4; |
1303 |
|
while (*s) { |
1304 |
|
spc = strchr(s, ' '); |
1305 |
|
if (!spc) |
1306 |
|
spc = s + strlen(s); |
1307 |
|
if (75 < x + (spc - s)) { |
1308 |
|
printf("\n "); |
1309 |
|
x = 4; |
1310 |
|
} |
1311 |
|
x += spc - s + 1; |
1312 |
|
printf("%.*s ", spc - s, s); |
1313 |
|
if (*spc) |
1314 |
|
s = spc + 1; |
1315 |
|
else |
1316 |
|
s = spc; |
1317 |
|
} |
1318 |
|
printf("\n\n"); |
1319 |
} |
} |
|
printf("\n\n"); |
|
1320 |
} |
} |
1321 |
|
|