Fix crash when requesting nonexistent extensionless files
(but only if HTMLPATH does not contain a '.') Clean up overuse of strstr. (based on 259ce08f81eaaaa087b6b1994fce7dde81820c52)
This commit is contained in:
parent
e1d262d992
commit
d7c5047fd3
10
net_io.c
10
net_io.c
|
@ -1202,14 +1202,14 @@ int handleHTTPRequest(struct client *c, char *p) {
|
|||
content_type = MODES_CONTENT_TYPE_HTML; // Default content type
|
||||
ext = strrchr(getFile, '.');
|
||||
|
||||
if (strlen(ext) > 0) {
|
||||
if (strstr(ext, ".json")) {
|
||||
if (ext) {
|
||||
if (!strcmp(ext, ".json")) {
|
||||
content_type = MODES_CONTENT_TYPE_JSON;
|
||||
} else if (strstr(ext, ".css")) {
|
||||
} else if (!strcmp(ext, ".css")) {
|
||||
content_type = MODES_CONTENT_TYPE_CSS;
|
||||
} else if (strstr(ext, ".js")) {
|
||||
} else if (!strcmp(ext, ".js")) {
|
||||
content_type = MODES_CONTENT_TYPE_JS;
|
||||
} else if (strstr(ext, ".gif")) {
|
||||
} else if (!strcmp(ext, ".gif")) {
|
||||
content_type = MODES_CONTENT_TYPE_GIF;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue