Fixed crash on empty static and history objects.

This commit is contained in:
default 2023-07-14 14:59:50 +02:00
parent 43d2e80dc5
commit 3e21aafb26

10
html.c
View file

@ -1830,6 +1830,7 @@ int html_get_handler(const xs_dict *req, const char *q_path,
char *id = xs_list_get(l, 1); char *id = xs_list_get(l, 1);
int sz; int sz;
if (id && *id) {
status = static_get(&snac, id, body, &sz, status = static_get(&snac, id, body, &sz,
xs_dict_get(req, "if-none-match"), etag); xs_dict_get(req, "if-none-match"), etag);
@ -1838,20 +1839,25 @@ int html_get_handler(const xs_dict *req, const char *q_path,
*ctype = xs_mime_by_ext(id); *ctype = xs_mime_by_ext(id);
} }
} }
}
else else
if (xs_startswith(p_path, "h/")) { /** an entry from the history **/ if (xs_startswith(p_path, "h/")) { /** an entry from the history **/
xs *l = xs_split(p_path, "/"); xs *l = xs_split(p_path, "/");
char *id = xs_list_get(l, 1); char *id = xs_list_get(l, 1);
if (id && *id) {
if (xs_endswith(id, "timeline.html_")) { if (xs_endswith(id, "timeline.html_")) {
// Don't let them in. /* Don't let them in */
*b_size = 0; *b_size = 0;
status = 404; status = 404;
} else if ((*body = history_get(&snac, id)) != NULL) { }
else
if ((*body = history_get(&snac, id)) != NULL) {
*b_size = strlen(*body); *b_size = strlen(*body);
status = 200; status = 200;
} }
} }
}
else else
if (strcmp(p_path, ".rss") == 0) { /** public timeline in RSS format **/ if (strcmp(p_path, ".rss") == 0) { /** public timeline in RSS format **/
d_char *rss; d_char *rss;